@@ -109,9 +109,12 @@ def test_fail():
109109'''
110110
111111SCRIPT_RESULT = '9 * 89%'
112+ SCRIPT2_RESULT = '3 * 100%'
112113CHILD_SCRIPT_RESULT = '6 * 100%'
113114PARENT_SCRIPT_RESULT = '8 * 100%'
114115
116+ xdist = pytest .mark .parametrize ('opts' , ['' , '-n 1' ], ids = ['nodist' , 'xdist' ])
117+
115118
116119def test_central (testdir ):
117120 script = testdir .makepyfile (SCRIPT )
@@ -750,6 +753,7 @@ def test_external_data_file_xdist(testdir):
750753 assert result .ret == 0
751754 assert glob .glob (str (testdir .tmpdir .join ('some/special/place/coverage-data*' )))
752755
756+
753757def test_external_data_file_negative (testdir ):
754758 script = testdir .makepyfile (SCRIPT )
755759 testdir .tmpdir .join ('.coveragerc' ).write ("" )
@@ -760,35 +764,48 @@ def test_external_data_file_negative(testdir):
760764 assert result .ret == 0
761765 assert glob .glob (str (testdir .tmpdir .join ('.coverage*' )))
762766
763- def test_append_coverage (testdir ):
767+
768+ @xdist
769+ def test_append_coverage (testdir , opts ):
764770 script = testdir .makepyfile (test_1 = SCRIPT )
765771 testdir .tmpdir .join ('.coveragerc' ).write ("" )
766772 result = testdir .runpytest ('-v' ,
767773 '--cov=%s' % script .dirpath (),
768- script )
769- size1 = script .dirpath ().join ('.coverage' ).size ()
770- assert (size1 > 0 )
771- script .remove ()
774+ script ,
775+ * opts .split ())
776+ result .stdout .fnmatch_lines ([
777+ 'test_1* %s*' % SCRIPT_RESULT ,
778+ ])
772779 script2 = testdir .makepyfile (test_2 = SCRIPT2 )
773- result = testdir .runpytest ('-v' , '--cov-append' ,
780+ result = testdir .runpytest ('-v' ,
781+ '--cov-append' ,
774782 '--cov=%s' % script2 .dirpath (),
775- script2 )
776- size2 = script2 .dirpath ().join ('.coverage' ).size ()
777- assert (size2 > size1 )
783+ script2 ,
784+ * opts .split ())
785+ result .stdout .fnmatch_lines ([
786+ 'test_1* %s*' % SCRIPT_RESULT ,
787+ 'test_2* %s*' % SCRIPT2_RESULT ,
788+ ])
789+
778790
779- def test_do_not_append_coverage (testdir ):
791+ @xdist
792+ def test_do_not_append_coverage (testdir , opts ):
780793 script = testdir .makepyfile (test_1 = SCRIPT )
781794 testdir .tmpdir .join ('.coveragerc' ).write ("" )
782795 result = testdir .runpytest ('-v' ,
783796 '--cov=%s' % script .dirpath (),
784- script )
785- size1 = script .dirpath ().join ('.coverage' ).size ()
786- assert (size1 > 0 )
787- script .remove ()
797+ script ,
798+ * opts .split ())
799+ result .stdout .fnmatch_lines ([
800+ 'test_1* %s*' % SCRIPT_RESULT ,
801+ ])
788802 script2 = testdir .makepyfile (test_2 = SCRIPT2 )
789803 result = testdir .runpytest ('-v' ,
790804 '--cov=%s' % script2 .dirpath (),
791- script2 )
792- size2 = script2 .dirpath ().join ('.coverage' ).size ()
793- assert (size1 > size2 )
794- assert (size2 > 0 )
805+ script2 ,
806+ * opts .split ())
807+ result .stdout .fnmatch_lines ([
808+ 'test_1* 0%' ,
809+ 'test_2* %s*' % SCRIPT2_RESULT ,
810+ ])
811+
0 commit comments