---
title: "Turn deprecation warnings into test · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/test-quality/deprecations-fail-tests
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Turn deprecation warnings into test failures

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Test quality](https://agentwranglers.se/playbook/testing/test-quality.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- ID: TST-52
- Level: Recommended
- Chapter: [Test quality](https://agentwranglers.se/playbook/testing/test-quality)
- Rule: The test run fails on any deprecation warning from your own code or a dependency. Each warning you choose to ignore is listed with an issue link.
- How: Libraries warn a version or more before they remove a feature. The warnings scroll past in the test log, and the next update breaks the build or production. Make the test runner treat them as errors, such as `filterwarnings = error` in pytest or `node --throw-deprecation` for Node.js. When a dependency warns and no fix exists yet, ignore that one message by its text, with a link to the issue. Remove the ignore when the dependency is fixed. This keeps [automatic dependency updates](https://agentwranglers.se/playbook/engineering/version-control-and-review/automated-dependency-updates) safe to merge.
- Check: Add a call to a deprecated function in a test. The run fails. Every ignore entry in the test settings has a comment with an issue link.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TOML example

```toml
# pyproject.toml
[tool.pytest.ini_options]
filterwarnings = [
    "error",
    # https://github.com/example/shop/issues/412 until payments-sdk stops calling datetime.utcnow()
    "ignore:datetime.datetime.utcnow:DeprecationWarning:payments_sdk",
]
```

### JSON example

```json
{
  "scripts": {
    "test": "node --throw-deprecation --test"
  }
}
```

## Sources

- [pytest warnings](https://docs.pytest.org/en/stable/how-to/capture-warnings.html)
- [Node.js command-line options](https://nodejs.org/api/cli.html)

## Related rules

- [Update dependencies in small automatic steps](https://agentwranglers.se/playbook/engineering/version-control-and-review/automated-dependency-updates) in Engineering

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/testing/test-quality/deprecations-fail-tests">Agent Wranglers testing playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Keep snapshot tests small and reviewed](https://agentwranglers.se/playbook/testing/test-quality/small-snapshots)
- [Test quality](https://agentwranglers.se/playbook/testing/test-quality)
