question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enfore no new warnings in test suite

See original GitHub issue

Our integration tests emit quite a few warnings. From skimming them, they are all caused by testing deprecated behavior. We should do two things to clean this up:

  1. Add some functionality to capture deprecation warnings, but let all others pass through. I’m thinking of a decorator than can be slapped onto a test case or test.
  2. Configure pytest to fail on warnings.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
pmeiercommented, Aug 12, 2021

Hey Kush, awesome to have you here! Go ahead, pleased to have you working on this.

What do we mean by: “capturing deprecation warnings but let all others pass through”?

Let me illustrate this with an example. Let’s say we have a function foo. This function calls into torch and in a newer release they emit a warning that for example the default arguments will be changed in the future. This warning is legitimate and should not be suppressed by the test suite. On the other hand if we decide to deprecate foo it will emit some warning (more details below) until the next major release.

def foo():
    torch.bar()  # emits a warning 
    warnings.warn(...)

Since we have tests for foo in our test suite, we will now also see the deprecation warning in the test log. If we enforce the warnings equal failures rule, the test will also fail.

My idea is the following: we create a decorator, e.g. @deprecated, that we can slap on every test and that captures our deprecation warnings, i.e. suppresses them, while legitimate warnings will be emitted and in turn fail the test. We have very basic functionality like this already in

https://github.com/pystiche/pystiche/blob/4324f34f74f53ef0c143b7f0d6eac99ae082636c/pystiche/misc.py#L283

In my current understand we would ignore warnings

  1. if they are emitted from pystiche and
  2. if they are either a DeprecationWarning or a Userwarning containing the word deprecate.

We will probably need to play with the warnings package and its filters. pytest also has a recwarn fixture that captures all warnings. Maybe we could use that to filter after the test was run. We are doing something similar in our gallery tests:

https://github.com/pystiche/pystiche/blob/4324f34f74f53ef0c143b7f0d6eac99ae082636c/tests/galleries/test_galleries.py#L163

Hopefully, my intention is clearer now. Let me know if you still have questions.

1reaction
pmeiercommented, Sep 18, 2021

Hey @krshrimali, do you have an update on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

MSBuild - Treat Warnings from editorconfig as Errors (enforce ...
However, I would like to enforce the warnings from my editorconfig as errors during Build so that it fails. Is there any way...
Read more >
KB5014754—Certificate-based authentication changes on ...
The May 10, 2022 update will provide audit events that identify certificates that are not compatible with Full Enforcement mode. If no audit...
Read more >
FAQs - Pennsylvania Automated Work Zone Speed Enforcement
A first-time notice of violation will be a warning carrying no financial penalty. Second and subsequent warnings will carry a financial penalty in...
Read more >
Test your apps with the ATF
Test your apps with the ATF · Benefits · Automated Test Framework records and components · Test · Test suite · Quick start...
Read more >
Advanced testing topics - Django documentation
It's used to optimize Django's own test suite, which contains hundreds of models but no relations between models in different applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found