Registry / testing / pytest-custom-exit-code

pytest-custom-exit-code

JSON →
library0.3.0pypypiunverified

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.

pip install pytest-custom-exit-code
INSTALL
IMPORT
SIG · PYTEST-CUSTOM-EXIT
P
pytest-custom-exit-code
testingpythonv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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.

# To install the plugin pip install pytest-custom-exit-code # --- Example: pytest.ini configuration to suppress 'no tests collected' exit code --- # Create a pytest.ini file in your project root with the following content: # [pytest] # addopts = --suppress-no-test-exit-code # To demonstrate, create an empty test file (e.g., test_nothing.py) # Then run pytest: # pytest test_nothing.py # This would normally exit with code 5 (no tests collected). With the plugin and config, # it will exit with code 0. If you delete the pytest.ini or remove the addopt, it will revert. # --- Example: Using command-line options directly --- # Suppress exit code when no tests are collected: # pytest --suppress-no-test-exit-code # Suppress exit code when tests fail: # pytest --suppress-tests-failed-exit-code
pytest --version
Debug
Known issues
breakingThis 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.
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.
affects: <=0.3.0
gotchaThe 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.
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`.
affects: All
gotchaThe 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.
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.
affects: All
Upgrade
Version history
0.3.0latest on PyPI · released Aug 7, 2019
Audit
Dependencies
pytestrequiredThis is a pytest plugin and requires pytest to function. Specifically, it was last released compatible with pytest >= 4.0.2.
pythonrequiredCompatible with Python >2.7, and versions excluding 3.0-3.3. Explicitly tested up to Python 3.7 according to its PyPI classifiers.
Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources
pytest-custom-exit-code — pip install pytest-custom-exit-code · libregistry