{"id":7622,"library":"pytest-timestamper","title":"Pytest Timestamper","description":"pytest-timestamper is a pytest plugin that enhances test output by adding a timestamp prefix to each line of the test session output. This helps users track the duration of individual tests and overall test suite progress. The current version is 0.0.10, with releases occurring periodically to maintain compatibility with `pytest` and address minor improvements.","status":"active","version":"0.0.10","language":"en","source_language":"en","source_url":"https://github.com/mbkroese/pytest-timestamper","tags":["pytest","plugin","testing","timestamps","output"],"install":[{"cmd":"pip install pytest-timestamper","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This is a plugin for pytest and requires pytest to function. Specific version compatibility depends on the pytest-timestamper version.","package":"pytest"}],"imports":[{"note":"pytest plugins are discovered and loaded by the pytest framework when installed in the same environment, so explicit imports in test files are generally not required for activation.","symbol":"pytest-timestamper","correct":"No direct import is typically needed; the plugin activates automatically upon installation."}],"quickstart":{"code":"import pytest\n\ndef test_example_one():\n    print(\"This is the first example test.\")\n    assert True\n\ndef test_example_two():\n    print(\"This is the second example test.\")\n    assert 1 + 1 == 2\n\n# To run this, save as 'test_timestamps.py' and execute in terminal:\n# pytest -v --prefixfmt=\"[%H:%M:%S]\" --datefmt=\"%Y-%m-%d\"","lang":"python","description":"Create a simple test file (e.g., `test_timestamps.py`) and run pytest. The plugin will automatically add timestamps. You can customize the timestamp format using `--prefixfmt` and `--datefmt` command-line options."},"warnings":[{"fix":"Upgrade to the latest version of `pytest-timestamper` (`0.0.10` or newer) to ensure compatibility with recent `pytest` versions.","message":"Version 0.0.10 removed deprecated decorators. Older versions of `pytest-timestamper` might rely on internal `pytest` APIs that have since been deprecated or removed in newer `pytest` releases, potentially leading to breakage or unexpected behavior if not updated.","severity":"breaking","affected_versions":"<0.0.10"},{"fix":"To include timestamps within captured log output, configure Python's `logging` module with `%(asctime)s` in its format string and potentially adjust `pytest`'s log capture settings (e.g., `--show-capture=no` or custom `pytest_logger` hooks) if standard `logging` output is still not as expected. This plugin focuses on prefixing the main pytest output lines.","message":"Timestamps added by `pytest-timestamper` apply to the overall test output, not necessarily to captured log messages (e.g., from `logging`). `pytest`'s default log capture mechanism often re-formats logs, which can strip custom timestamps from `logging` calls.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you install only `pytest-timestamper` if you intend to use its specific features, and review its documentation for usage. Avoid installing both `pytest-timestamper` and `pytest-timestamps` simultaneously unless their compatibility is explicitly confirmed.","message":"There is another plugin named `pytest-timestamps` which provides similar functionality but with different implementation and options. Users might confuse the two or accidentally install both.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `pytest-timestamper` is installed in the same Python environment where `pytest` is being run (`pip install pytest-timestamper`). No further activation steps are required as it's an auto-activating plugin.","cause":"The `pytest-timestamper` plugin is not installed or not active in the pytest environment.","error":"Pytest output does not show any timestamps."},{"fix":"Verify the plugin is installed and up-to-date (`pip install --upgrade pytest-timestamper`). Double-check the spelling of the command-line arguments: `--prefixfmt` and `--datefmt`.","cause":"The plugin is not installed, or pytest is running an older version of the plugin that doesn't support these specific command-line arguments, or the options are misspelled.","error":"Command line options --prefixfmt or --datefmt are not recognized."}]}