Replaced --forked in internal tests#205
Conversation
There was a problem hiding this comment.
This is great, thanks so much!
Thanks also for making your change so easy to review.
Would you want to rename make pytest-forked to something else?
Yes, I agree - see comment inline for the azure version.
We'll be happy to accept this PR, but before merging I want to discuss two aspects. One is covered in the comments (i.e. "distribution algorithm"); the other is:
Tests like test_basic_runWithReturn_pass and 4 others do not want to have the file
__cell_coverage_test.pyalready created. I grouped all these 5 tests under a classTestCoverageso that these tests are run sequentially by a worker spawn by pytest-xdist
Please can you explain again why you are grouping these? I can see 3 possible reasons: (a) reduction of duplicated code, (b) grouping genuinely related tests together, i.e. in a "semantically meaningful way", (c) because otherwise the tests don't pass e.g. in the distributed case.
I can't quite tell which of those reasons (or maybe another?) applies here from your comment.
Is the class name TestCoverage apt for grouping these tests
Ideally I would like to group only if it makes real sense to do so, not if it's fixing some problem we could solve another way. So the answer to this one depends on the outcome of the discussion above.
You guessed it right, without grouping the tests will not always pass. Those tests first check if nbcelltests/nbcelltests/tests/test_test.py Line 690 in aef8e32 So, those 5 tests cannot be parallelized. One way to make
|
|
Quick comment from my phone... I think those tests (or the underlying functions they test) should be fixed. E.g. they should use a unique temporary file. We should either do that here in this PR, or open an issue to do it in the future. Up to you! (Off the top of my head I don't know if it's a big change or not.) |
ceball
left a comment
There was a problem hiding this comment.
I do not think it is different from the invocation on Azure. I think it just callsmake testpy-distributed now which will come to Makefile and run the command with --dist=loadscope. Does it not?
Ok, great. (Likely I misread the diff :) )
|
I am not sure at all why TestSkips is failing to setup once on Linux Python37. I am trying to duplicate that on my local machine. Let's open another issue to make those tests independent. There are two files involved: |
Looked like a timeout to me, probably just from azure. So I re-ran, and it passed. (If it was down to some bad interaction between the tests that only shows up sometimes in the distributed case, we'll address it if we see it again in the future...) |
|
One last thing to ask: Would you like to be able to do Apart from that, I am all done with this PR! |
Are you able to make the issue (extracting and summarizing our discussion here)? (No obligation; if not, I will do it.) |
Please could you make that as a separate PR, after this one? I am not at all against adding an option for varying n when running the tests (I think it's useful), but I don't own the Makefile so would want a teammate to ok it. |
|
OK, I will make another PR to master after this PR is merged. I can make the issue about those tests too. Thanks! |
ceball
left a comment
There was a problem hiding this comment.
Just requested some comments (and ideally a new issue), otherwise this PR is fine with me. Thanks!
ceball
left a comment
There was a problem hiding this comment.
Thanks for all the follow-up work!
|
I'll merge once the tests pass (can't merge until then). |

Resolves #107:
pytest-xdistwill now be installed on Windows--forkedwith-n 2test_basic_runWithReturn_passand 4 others do not want to have the file__cell_coverage_test.pyalready created. I grouped all these 5 tests under a classTestCoverageso that these tests are run sequentially by a worker spawn bypytest-xdist--forked. Now, tests liketest_statebehave as if it's alwaysFORKED=False.Naming Choices:
make pytest-forkedto something else?pytest --forkedrenames topytest -n 2TestCoverageapt for grouping these tests?test_basic_runWithReturn_pass,test_basic_runWithReturn_fail,test_basic_runWithReport_pass,test_basic_runWithHTMLReturn_pass,test_basic_runWithHTMLReturn_failIt is not apparent looking at the diff of
test_test.py TestCoverage, but I have only added those five tests to the class and I have not changed those tests.