{"id":23025,"library":"zope-testrunner","title":"zope.testrunner","description":"Zope test runner script for running Python unit tests with support for layers, test fixtures, and flexible reporting. Current version is 8.2, compatible with Python >=3.10. Released under the Zope Foundation, maintenance mode with occasional updates.","status":"maintenance","version":"8.2","language":"python","source_language":"en","source_url":"https://github.com/zopefoundation/zope.testrunner","tags":["testing","zope","test-runner","layers","unit-test"],"install":[{"cmd":"pip install zope.testrunner","lang":"bash","label":"pip"}],"dependencies":[{"reason":"Required for test layer support","package":"zope.interface","optional":false},{"reason":"Used for Python 2/3 compatibility, still present","package":"six","optional":false}],"imports":[{"note":"TestRunner was removed in version 5.0; use Runner instead.","wrong":"from zope.testrunner import TestRunner","symbol":"TestRunner","correct":"from zope.testrunner.runner import Runner"}],"quickstart":{"code":"import sys\nfrom zope.testrunner.runner import Runner\n\nclass CustomOptions:\n    verbose = 2\n    tests_pattern = 'test*.py'\n    test_path = ['.']\n    at_level = None\n    unit = True\n    layer = None\n    all = False\n    repeat = 0\n    test_filter = None\n    report_modules = False\n    module_path = []\n    startup = None\n\nrunner = Runner(CustomOptions())\nrunner.run()\n\n# To run tests from command line:\n# $ python -m zope.testrunner --test-path .","lang":"python","description":"Basic example to run tests programmatically."},"warnings":[{"fix":"Change imports to `from zope.testrunner.runner import Runner` and use the new API.","message":"In version 5.0, the Runner class moved from `zope.testrunner` to `zope.testrunner.runner`. Code importing `TestRunner` or using old import path `from zope.testrunner import Runner` will break.","severity":"breaking","affected_versions":"<5.0"},{"fix":"Use positional arguments instead: `zope-testrunner .`","message":"The command-line option `--test-path` is deprecated in favor of positional arguments. Usage like `zope-testrunner --test-path .` will produce a warning.","severity":"deprecated","affected_versions":">=8.0"},{"fix":"Ensure layers are imported in the test module or listed via `--layer` option.","message":"Test layers from `zope.testing` are not automatically discovered; they must be explicitly listed or imported. Many users assume layers are auto-detected.","severity":"gotcha","affected_versions":"all"},{"fix":"Create a plain object with required attributes as shown in quickstart.","message":"When running tests programmatically, the `Options` class is not exported. Use a simple object or dict, not the undocumented `Options` class.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from zope.testrunner.runner import Runner`","cause":"Incorrect import path; Runner moved to zope.testrunner.runner in version 5.0.","error":"ImportError: cannot import name 'Runner' from 'zope.testrunner'"},{"fix":"Replace `TestRunner` with `Runner` from zope.testrunner.runner.","cause":"TestRunner was removed in version 5.0.","error":"AttributeError: module 'zope.testrunner' has no attribute 'TestRunner'"},{"fix":"Check that `test_path` points to a directory with test files matching `tests_pattern`. Use `--all` to include all files.","cause":"The test path or pattern did not match any test files.","error":"zope.testrunner.runner.RunnerError: No tests found"},{"fix":"Ensure all layer classes implement `setUp(self)` and `tearDown(self)` methods.","cause":"A test layer's `setUp` or `tearDown` method is not defined or not found.","error":"TypeError: 'NoneType' object is not callable (when using layers)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}