@@ -234,7 +234,6 @@ def test_report_on_with_reruns(self, testdir):
234234 assert self ._substring_in_output ('1 rerun' , result .outlines )
235235 assert self ._substring_in_output ('RERUN test_report_on_with_reruns.py::test_flaky_test' , result .outlines )
236236
237-
238237 def test_report_on_without_reruns (self , testdir ):
239238 test_file = self .variety_of_tests (testdir )
240239
@@ -257,24 +256,71 @@ def test_report_on_without_reruns(self, testdir):
257256 assert not self ._substring_in_output ('RERUN test_report_on_without_reruns.py::test_flaky_test' , result .errlines )
258257 assert not self ._substring_in_output ('1 rerun' , result .outlines )
259258
260- def test_report_with_xdist_dash_n (self , testdir ):
261- '''This test is identical to test_flakey_test_report_normal except it
259+ # pytest-xdist -n compatibility tests
260+
261+ def test_report_off_with_reruns_with_xdist (self , testdir ):
262+ '''This test is identical to test_report_off_with_reruns except it
263+ also uses xdist's -n flag.
264+ '''
265+ # precondition: xdist installed
266+ self ._pytest_xdist_installed (testdir )
267+
268+ test_file = self .variety_of_tests (testdir )
269+
270+ result = testdir .runpytest ('--reruns=2' , '-n 1' )
271+
272+ assert self ._substring_in_output ('.FxXR' , result .outlines )
273+
274+ assert self ._substring_in_output ('1 passed' , result .outlines )
275+
276+ assert self ._substring_in_output ('1 failed' , result .outlines )
277+ assert not self ._substring_in_output ('FAIL test_report_off_with_reruns_with_xdist.py::test_fake_fail' , result .outlines )
278+
279+ assert self ._substring_in_output ('1 xpassed' , result .outlines )
280+ assert not self ._substring_in_output ('XPASS test_report_off_with_reruns_with_xdist.py::test_xpass' , result .outlines )
281+
282+ assert self ._substring_in_output ('1 xfailed' , result .outlines )
283+ assert not self ._substring_in_output ('XFAIL test_report_off_with_reruns_with_xdist.py::test_xfail' , result .outlines )
284+
285+ assert not self ._substring_in_output ('RERUN test_report_off_with_reruns_with_xdist.py::test_flaky_test' , result .outlines )
286+ assert self ._substring_in_output ('1 rerun' , result .outlines )
287+
288+ def test_report_on_with_reruns_with_xdist (self , testdir ):
289+ '''This test is identical to test_report_on_with_reruns except it
262290 also uses xdist's -n flag.
263291 '''
264292 # precondition: xdist installed
293+ self ._pytest_xdist_installed (testdir )
294+
295+ test_file = self .variety_of_tests (testdir )
296+
297+ result = testdir .runpytest ('--reruns=2' , '-r fsxXR' , '-n 1' )
298+
299+ assert self ._substring_in_output ('.FxXR' , result .outlines )
300+
301+ assert self ._substring_in_output (' 1 passed' , result .outlines )
302+
303+ assert self ._substring_in_output ('1 failed' , result .outlines )
304+ assert self ._substring_in_output ('FAIL test_report_on_with_reruns_with_xdist.py::test_fake_fail' , result .outlines )
305+
306+ assert self ._substring_in_output ('1 xpassed' , result .outlines )
307+ assert self ._substring_in_output ('XPASS test_report_on_with_reruns_with_xdist.py::test_xpass' , result .outlines )
308+
309+ assert self ._substring_in_output ('1 xfailed' , result .outlines )
310+ assert self ._substring_in_output ('XFAIL test_report_on_with_reruns_with_xdist.py::test_xfail' , result .outlines )
311+
312+ assert self ._substring_in_output ('1 rerun' , result .outlines )
313+ assert self ._substring_in_output ('RERUN test_report_on_with_reruns_with_xdist.py::test_flaky_test' , result .outlines )
314+
315+
316+ def _pytest_xdist_installed (self , testdir ):
265317 try :
266318 result = testdir .runpytest ('--version' )
267319 result .stderr .fnmatch_lines (['*pytest-xdist*' ])
268320 except Exception :
269321 import pytest
270322 pytest .skip ("this test requires pytest-xdist" )
271323
272- test_file = testdir .makepyfile (self .flakey_test )
273-
274- result = testdir .runpytest ('--reruns=2' , '-n 1' , '-r fsxXR' )
275- assert self ._substring_in_output ('RERUN test_report_with_xdist_dash_n.py::test_flaky_test' , result .outlines )
276- assert self ._substring_in_output ('1 rerun' , result .outlines )
277-
278324 def _substring_in_output (self , substring , output_lines ):
279325 print '-' * 30
280326 found = False
0 commit comments