{"id":16417500,"url":"https://github.com/adamchainz/pytest-is-running","last_synced_at":"2025-10-26T20:30:46.062Z","repository":{"id":37941144,"uuid":"435480298","full_name":"adamchainz/pytest-is-running","owner":"adamchainz","description":"pytest plugin providing a function to check if pytest is running.","archived":true,"fork":false,"pushed_at":"2024-01-02T23:05:40.000Z","size":250,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-04T16:48:55.641Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/adamchainz.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://adamj.eu/books/"]}},"created_at":"2021-12-06T12:02:03.000Z","updated_at":"2024-04-14T21:54:47.000Z","dependencies_parsed_at":"2023-10-26T23:24:48.715Z","dependency_job_id":"55c5a47b-c6fb-470c-a75d-fc426924d6a3","html_url":"https://github.com/adamchainz/pytest-is-running","commit_stats":{"total_commits":125,"total_committers":3,"mean_commits":"41.666666666666664","dds":"0.29600000000000004","last_synced_commit":"3aced9ad80abaf42c167c579d435c97d7084f3f2"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamchainz%2Fpytest-is-running","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamchainz%2Fpytest-is-running/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamchainz%2Fpytest-is-running/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamchainz%2Fpytest-is-running/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamchainz","download_url":"https://codeload.github.com/adamchainz/pytest-is-running/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238394323,"owners_count":19464583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-11T07:11:32.625Z","updated_at":"2025-10-26T20:30:40.747Z","avatar_url":"https://github.com/adamchainz.png","language":"Python","funding_links":["https://adamj.eu/books/"],"categories":["Python"],"sub_categories":[],"readme":"=================\npytest-is-running\n=================\n\n.. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/pytest-is-running/main.yml?branch=main\u0026style=for-the-badge\n   :target: https://github.com/adamchainz/pytest-is-running/actions?workflow=CI\n\n.. image:: https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge\n  :target: https://github.com/adamchainz/pytest-is-running/actions?workflow=CI\n\n.. image:: https://img.shields.io/pypi/v/pytest-is-running.svg?style=for-the-badge\n   :target: https://pypi.org/project/pytest-is-running/\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge\n   :target: https://github.com/psf/black\n\n.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white\u0026style=for-the-badge\n   :target: https://github.com/pre-commit/pre-commit\n   :alt: pre-commit\n\npytest plugin providing a function to check if pytest is running.\n\nUnmaintained (2024-01-02)\n=========================\n\nI stopped maintaining this package as it doesn’t provide much value over checking whether pytest has been imported:\n\n.. code-block:: python\n\n    import sys\n\n    if \"pytest\" in sys.modules:\n        ...\n\nIn every project I’ve seen, pytest is only imported when running.\n\n----\n\n**Working on a Django project?**\nCheck out my book `Boost Your Django DX \u003chttps://adamchainz.gumroad.com/l/byddx\u003e`__ which covers many ways to improve your development experience.\nI created pytest-is-running whilst working on the book!\n\n----\n\nInstallation\n============\n\nInstall with:\n\n.. code-block:: bash\n\n    python -m pip install pytest-is-running\n\nPython 3.8 to 3.12 supported.\n\nUsage\n=====\n\npytest will automatically find the plugin and use it when you run ``pytest``.\nYou can check if pytest is running with the ``is_running()`` function:\n\n.. code-block:: python\n\n    import pytest_is_running\n\n\n    if pytest_is_running.is_running():\n        ...\n\nThe package avoids importing pytest if it is not running, so that you don’t incur that overhead in non-test paths.\n\nThe package registers its plugin hooks as early as possible in pytest’s process, so it should be loaded before any of your non-test modules.\n\nRationale\n=========\n\nThis plugin is an alternative to re-implementing `the pattern in the pytest documentation \u003chttps://docs.pytest.org/en/latest/example/simple.html#detect-if-running-from-within-a-pytest-run\u003e`__.\nAs a plugin, it is loaded earlier than ``conftest.py`` or any other code in your project.\nThis makes it a more robust way of checking whether pytest is currently running.\n\nUpstream `issue #9502 \u003chttps://github.com/pytest-dev/pytest/issues/9502\u003e`__ discusses adding a feature to pytest.\nIt also covers an alternative which is often “good enough” - a simple check if pytest has been imported with:\n\n.. code-block:: python\n\n    \"pytest\" in sys.modules\n\nThis won’t be strictly accurate if you happen to import pytest outside of your test run, but that is not very common.\nYou may prefer to using this simpler technique instead of this plugin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamchainz%2Fpytest-is-running","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamchainz%2Fpytest-is-running","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamchainz%2Fpytest-is-running/lists"}