Azure / Azure/azure-sdk-for-python

Investigate fail a testsuite if any deprecated function is called

Aperta
#38,752 0 commenti 2 reazioni 1 assegnatario Rivendicata da @laiapat Vedi su GitHub
EngSys
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g 2h
PR unite (30g)
202

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.