Azure / Azure/azure-sdk-for-python
Investigate fail a testsuite if any deprecated function is called
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 193
Description
In Python, you can tag a function was deprecated using the `warnings` module:
https://docs.python.org/3/library/warnings.html
That's a `DeprecationWarning`.
The goal here, would be to be able to catch those events while running a testsuite and fail the testsuite with a message saying that there are some tests that used deprecated function. Long term, this may help reduce the risk that a new release of a dependency drop a function entirely and we detect it only when it happens.
Possible solutions:
- Investigate if pytest has a plugin already for that
- Redirect warnings to the `py.warnings` logger, see for instance: https://docs.python.org/3/library/logging.html#logging.captureWarnings. This should be possible if we redirect it with a custom handler registered to the `py.warnings` logger, to check in teardown (post-fixture) that the last running test didn't call any deprecation function.
We need a supression mechanism as well, just in case we have no other choice. For instance, if Azure SDK has deprecated functions itself that we test, we should make sure we can test them (deprecated doesn't mean not supported). And there may be situations where the new path proposed by a library is yet too complex and we need to wait a little.
Contributor guide
Assessment
This issue has not been assessed yet.