-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session fixtures invoked multiple times with xdist #503
Comments
Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt): the problem very likely lies in SlaveInteractor.runtestloop/runtests and the interaction with nextitem, |
Original comment by BitBucket: davidkr, GitHub: davidkr: wasn't sure it was a bug, but I see what you mean now. I got the impression from http://holgerkrekel.net/2013/11/12/running-tests-against-multiple-devicesresources-in-parallel/ it was for the master and each of the slaves. I misunderstood how things work clearly. ..this stackoverflow post http://stackoverflow.com/questions/12586489/pytest-are-pytest-sessionstart-and-pytest-sessionfinish-valid-hooks clarified that when using xdist session-scoped fixtures are supposed to be only created once per test-slave. |
Original comment by Jeff Smith (BitBucket: ascarel, GitHub: ascarel): Is it possible that the following problem is exactly the same as the one described here? Here is some test code. This mimicks the behaviour of my test setup (it records REST API requests made throughout a series of tests and saves that into a file at the end, to avoid overwriting). If I run that without xdist, I get one file. If I run that with -n 2, I get a 38 files. I would expect only one file per test slave/process (that's why I tag the filename with a random part).
This seemed related, so I'm posting this here. I apologize in advance if this should be filed in a separate issue. |
Original comment by Andreas Pelme (BitBucket: pelme, GitHub: pelme): I can reliably reproduce this with latest pytest-xdist tip and have written a failing test: https://bitbucket.org/pelme/pytest-xdist/commits/36ca679583b06157d5c5aef00df73b5dc94dfd35?at=default |
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42): On Tue, Jul 08, 2014 at 20:42 -0000, Andreas Pelme wrote: Thanks, Andreas for the excellent work on pinpointing the issue and commit. In your failing test, "item" is the first test function, "nextitem" We need to re-instate the old behaviour that "pytest_runtest_item" is It is thus important that the "master" distributing the tests to the nodes If you feel like working on an according fix, you'd be most welcome to best, |
Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff): Hi @hpk42 |
This doesn't work for me if I'm using autouse=True
The same fixture is called multiple times. |
@dusans each process xdist makes is a own session, so thats currently working as intended - there is not yet a mechanism to inject new scopes and handling them (a "control-session" one might be needed |
I should mention that there is a new command-line option |
@trbedwards it shouldnt, since session ones would be process global, and each process owuld need one the loadscope details handle seregation by file by avoiding certain files, that cant be done for session scope |
Originally reported by: Andreas Pelme (BitBucket: pelme, GitHub: pelme)
Since https://bitbucket.org/hpk42/pytest-xdist/commits/05aa4f48306c905ae4d183a4b337f63cc4490466 session scoped fixtures runs multiple times.
To trace this, I have added this code to the problematic fixture:
This is what happends:
The same test works fine without xdist:
This also happends with -n2, -n3 etc. It happens with pytest-xdist from revision 169 to latest tip, and pytest 2.5.2 to latest tip.
The text was updated successfully, but these errors were encountered: