{"id":26457217,"url":"https://github.com/karolinepauls/pytest-kafka","last_synced_at":"2026-01-24T22:06:03.188Z","repository":{"id":182717610,"uuid":"178266913","full_name":"karolinepauls/pytest-kafka","owner":"karolinepauls","description":"ZK and Kafka fixtures for Pytest. Mirror of https://gitlab.com/karolinepauls/pytest-kafka","archived":false,"fork":false,"pushed_at":"2024-08-14T15:12:07.000Z","size":54,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-04T18:04:14.494Z","etag":null,"topics":["fixture","kafka","pytest","zookeeper"],"latest_commit_sha":null,"homepage":"https://pytest-kafka.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karolinepauls.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-28T19:09:57.000Z","updated_at":"2024-08-14T15:12:06.000Z","dependencies_parsed_at":"2024-08-14T16:53:21.030Z","dependency_job_id":null,"html_url":"https://github.com/karolinepauls/pytest-kafka","commit_stats":null,"previous_names":["karolinepauls/pytest-kafka"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/karolinepauls/pytest-kafka","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolinepauls%2Fpytest-kafka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolinepauls%2Fpytest-kafka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolinepauls%2Fpytest-kafka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolinepauls%2Fpytest-kafka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karolinepauls","download_url":"https://codeload.github.com/karolinepauls/pytest-kafka/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolinepauls%2Fpytest-kafka/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28737933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T21:19:41.845Z","status":"ssl_error","status_checked_at":"2026-01-24T21:13:38.675Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fixture","kafka","pytest","zookeeper"],"created_at":"2025-03-18T22:58:24.879Z","updated_at":"2026-01-24T22:06:03.170Z","avatar_url":"https://github.com/karolinepauls.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pytest-kafka |pypi| |pyversions| |ci| |docs|\n============================================\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/pytest-kafka.svg\n    :target: https://pypi.org/project/pytest-kafka/\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/pytest-kafka.svg\n    :target: https://pypi.org/project/pytest-kafka/\n\n.. |ci| image:: https://gitlab.com/karolinepauls/pytest-kafka/badges/master/pipeline.svg\n    :target: https://gitlab.com/karolinepauls/pytest-kafka/pipelines\n\n.. |docs| image:: https://readthedocs.org/projects/pytest-kafka/badge/?version=latest\n    :target: https://pytest-kafka.readthedocs.io/en/latest/\n\n\nPytest fixture factories for Zookeeper, Kafka server and Kafka consumer.\n`Read the API docs \u003chttps://pytest-kafka.readthedocs.io\u003e`__.\n\n.. warning::\n\n    ``kafka-python`` doesn't work with Python 3.12. To solve this problem, pytest-kafka, from 0.8.x, no\n    longer depends on ``kafka-python``. You can depend on extras: ``pytest-kafka[kafka-python]`` or\n    ``pytest-kafka[kafka-python-ng]`` for Python\u003e3.12.\n\n.. code:: python\n\n    from pathlib import Path\n    from pytest_kafka import (\n        make_zookeeper_process, make_kafka_server, make_kafka_consumer,\n        terminate,\n    )\n\n    ROOT = Path(__file__).parent\n    KAFKA_SCRIPTS = ROOT / 'kafka/bin/'\n    KAFKA_BIN = str(KAFKA_SCRIPTS / 'kafka-server-start.sh')\n    ZOOKEEPER_BIN = str(KAFKA_SCRIPTS / 'zookeeper-server-start.sh')\n\n    # You can pass a custom teardown function (or parametrise ours). Just don't call it `teardown`\n    # or Pytest will interpret it as a module-scoped teardown function.\n    teardown_fn = partial(terminate, signal_fn=Popen.kill)\n    zookeeper_proc = make_zookeeper_process(ZOOKEEPER_BIN, teardown_fn=teardown_fn)\n    kafka_server = make_kafka_server(KAFKA_BIN, 'zookeeper_proc', teardown_fn=teardown_fn)\n    kafka_consumer = make_kafka_consumer(\n        'kafka_server', seek_to_beginning=True, kafka_topics=['topic'])\n\n\nThis creates 3 fixtures:\n\n#. ``zookeeper_proc`` - Zookeeper process\n#. ``kafka_server`` - Kafka process\n#. ``kafka_consumer`` - usable ``kafka.KafkaConsumer`` instance\n\n\n``ZOOKEEPER_BIN`` and ``KAFKA_BIN`` are paths to launch scripts in your Kafka distribution. Check\nthis project's setup.py to see a way of installing Kafka for development.\n\nIt is advised to pass ``seek_to_beginning=True`` because otherwise some messages may not be captured\nby the consumer. This requires knowing the topics upfront because without topics there's no\npartitions to seek.\n\nKafka server is known to take a couple of seconds to terminate gracefully. You probably don't\nneed that, so you can pass ``partial(terminate, signal_fn=Popen.kill)`` to make it killed with\nSIGKILL and waited for afterwards.\n\nIt's possible to create multiple Kafka fixtures forming a cluster by passing the same Zookeeper\nfixture to them. For an example, check the `tests\n\u003chttps://gitlab.com/karolinepauls/pytest-kafka/blob/master/test_pytest_kafka.py\u003e`__.\n\nSession-scoped fixtures are also available. Consult the `test suite\n\u003chttps://gitlab.com/karolinepauls/pytest-kafka/blob/master/test_pytest_kafka.py\u003e`__.\n\n\nSystem requirements\n-------------------\n\n- Python 3.6+\n- a JVM that can run Kafka and Zookeeper\n- Kafka - https://kafka.apache.org/downloads\n\n\nDevelopment\n-----------\n\n.. code:: sh\n\n   pip install -e .[dev]\n   ./pytest_kafka/install.py  # will install kafka to ./kafka\n\n\nAcknowledgements\n----------------\n\nThe library has been open-sourced from a codebase belonging to\n`Infectious Media \u003chttps://infectiousmedia.com\u003e`__.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarolinepauls%2Fpytest-kafka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarolinepauls%2Fpytest-kafka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarolinepauls%2Fpytest-kafka/lists"}