Azure / Azure/azure-sdk-for-python

Investigate fail a testsuite if any deprecated function is called

Offen
#38,752 0 Kommentare 2 Reaktionen 1 zugewiesene Person Beansprucht von @laiapat Auf GitHub ansehen
EngSys
Vorherrschende Sprache
Python
Sterne
5.6k
Forks
3.4k
Ø Merge
2 T.
Gemergte PRs (30 T.)
217

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.