{"id":5704,"library":"pytest-custom-exit-code","title":"pytest-custom-exit-code","description":"pytest-custom-exit-code is a pytest plugin that allows users to customize the exit code of a pytest test session in specific scenarios. Currently at version 0.3.0, its primary function is to alter the default exit codes, such as when no tests are collected or when tests fail. The library has had a slow release cadence, with the last update in August 2019.","status":"maintenance","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/yashtodi94/pytest-custom_exit_code","tags":["pytest","plugin","exit code","testing","ci/cd"],"install":[{"cmd":"pip install pytest-custom-exit-code","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This is a pytest plugin and requires pytest to function. Specifically, it was last released compatible with pytest >= 4.0.2.","package":"pytest","optional":false},{"reason":"Compatible with Python >2.7, and versions excluding 3.0-3.3. Explicitly tested up to Python 3.7 according to its PyPI classifiers.","package":"python","optional":false}],"imports":[],"quickstart":{"code":"# To install the plugin\npip install pytest-custom-exit-code\n\n# --- Example: pytest.ini configuration to suppress 'no tests collected' exit code ---\n# Create a pytest.ini file in your project root with the following content:\n# [pytest]\n# addopts = --suppress-no-test-exit-code\n\n# To demonstrate, create an empty test file (e.g., test_nothing.py)\n# Then run pytest:\n# pytest test_nothing.py\n# This would normally exit with code 5 (no tests collected). With the plugin and config,\n# it will exit with code 0. If you delete the pytest.ini or remove the addopt, it will revert.\n\n# --- Example: Using command-line options directly ---\n# Suppress exit code when no tests are collected:\n# pytest --suppress-no-test-exit-code\n\n# Suppress exit code when tests fail:\n# pytest --suppress-tests-failed-exit-code\n","lang":"bash","description":"The plugin is typically used by passing command-line options to `pytest` or by configuring them in a `pytest.ini` file. There are no direct Python imports from the plugin itself for its core functionality. The primary options are `--suppress-no-test-exit-code` to change exit code 5 (no tests collected) to 0, and `--suppress-tests-failed-exit-code` to change exit code 1 (tests failed) to 0."},"warnings":[{"fix":"Consider updating to a newer, actively maintained pytest plugin if one exists for custom exit code logic, or carefully test this plugin with your specific Python and pytest versions. If compatibility issues arise, manual patching or refactoring might be necessary.","message":"This plugin (version 0.3.0) was last released in August 2019 and explicitly declared compatibility up to Python 3.7. It is highly likely to be incompatible with newer Python versions (3.8+) and recent pytest versions (8.x, 9.x) due to breaking changes in both Python and pytest APIs over time. For example, pytest 9.0.0 dropped support for Python 3.8.","severity":"breaking","affected_versions":"<=0.3.0"},{"fix":"Always use the provided command-line flags or `pytest.ini` configuration to leverage this plugin's features. Do not attempt to import symbols from `pytest_custom_exit_code`.","message":"The plugin's functionality is activated via pytest command-line arguments (`--suppress-no-test-exit-code`, `--suppress-tests-failed-exit-code`) or through the `pytest.ini` configuration file. It does not expose a direct Python API for programmatic use. Users expecting to import and interact with the plugin's logic directly from Python code will find no such interface.","severity":"gotcha","affected_versions":"All"},{"fix":"Be explicit about the expected exit codes in your CI/CD pipelines. If using `--suppress-tests-failed-exit-code`, ensure that test failure reports are still thoroughly checked. If using `--suppress-no-test-exit-code`, verify that tests are indeed being collected and run, especially in environments where test discovery might be flaky.","message":"The plugin modifies pytest's default exit codes for specific scenarios (e.g., no tests collected or tests failed). Relying on these modified exit codes in CI/CD pipelines or scripts without explicit awareness can lead to misinterpretation of test results, as a 'successful' exit code (0) might mask actual test failures or absence of tests.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}