You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently working on a large project and I'm coming across a weird issue when trying to run my pytests. I created a Gist here that recreates the error I'm having.
I don't know if this is deliberate behavior or if I messed something up but when I run the two tests together (either as a file, or as a project wide pytest), the second test fails because it seems to preserve the same copy of an object from the previous test. The class being tested is a wrapper around a class with some non-implemented features with the ones already implemented being tested. The stuff being tested is iterators and subscripting.
This remains the same if I order them differently in the file, also if I change the names. Not too sure what's going on here, so I don't know what else I can tell you.
GitMate.io thinks possibly related issues are #1591 (pytest-xdist fails when running same tests several times), #747 (flakes test fail), #2047 (pytest fails at first test with Exit: FATAL), #1777 (sigalrm fails test), and #2479 (Running tests generated by pytest_generate_tests with the -k flag fails.).
I took a quick look and the problem seems to be that ProfileBase._providers is a class attribute and therefore lives at class level. This means it will be created once the class is imported and there is only one dict shared by all instances. (Take a look at this StackOverflow thread on the difference of class and instance attributes)
Since pytest doesn't re-import code for each run, the same class is used in your second test, with _providers already populated. The easiest fix is to move _providers from class to instance level, by moving it to the constructor.
Currently working on a large project and I'm coming across a weird issue when trying to run my pytests. I created a Gist here that recreates the error I'm having.
I don't know if this is deliberate behavior or if I messed something up but when I run the two tests together (either as a file, or as a project wide pytest), the second test fails because it seems to preserve the same copy of an object from the previous test. The class being tested is a wrapper around a class with some non-implemented features with the ones already implemented being tested. The stuff being tested is iterators and subscripting.
This remains the same if I order them differently in the file, also if I change the names. Not too sure what's going on here, so I don't know what else I can tell you.
Here's the output:
pip list
output of the fresh pyenv it's running in:OS is Ubuntu 16.04 on Windows Subsystem for Linux.
Here's a quick checklist in what to include:
pip list
of the virtual environment you are usingThe text was updated successfully, but these errors were encountered: