@@ -531,6 +531,84 @@ def test2(self, x, y):
531
531
assert colitems [2 ].name == 'test2[a-c]'
532
532
assert colitems [3 ].name == 'test2[b-c]'
533
533
534
+ def test_parametrize_skipif (self , testdir ):
535
+ testdir .makepyfile ("""
536
+ import pytest
537
+
538
+ m = pytest.mark.skipif('True')
539
+
540
+ @pytest.mark.parametrize('x', [0, 1, m(2)])
541
+ def test_skip_if(x):
542
+ assert x < 2
543
+ """ )
544
+ result = testdir .runpytest ()
545
+ result .stdout .fnmatch_lines ('* 2 passed, 1 skipped in *' )
546
+
547
+ def test_parametrize_skip (self , testdir ):
548
+ testdir .makepyfile ("""
549
+ import pytest
550
+
551
+ m = pytest.mark.skip('')
552
+
553
+ @pytest.mark.parametrize('x', [0, 1, m(2)])
554
+ def test_skip(x):
555
+ assert x < 2
556
+ """ )
557
+ result = testdir .runpytest ()
558
+ result .stdout .fnmatch_lines ('* 2 passed, 1 skipped in *' )
559
+
560
+ def test_parametrize_skipif_no_skip (self , testdir ):
561
+ testdir .makepyfile ("""
562
+ import pytest
563
+
564
+ m = pytest.mark.skipif('False')
565
+
566
+ @pytest.mark.parametrize('x', [0, 1, m(2)])
567
+ def test_skipif_no_skip(x):
568
+ assert x < 2
569
+ """ )
570
+ result = testdir .runpytest ()
571
+ result .stdout .fnmatch_lines ('* 1 failed, 2 passed in *' )
572
+
573
+ def test_parametrize_xfail (self , testdir ):
574
+ testdir .makepyfile ("""
575
+ import pytest
576
+
577
+ m = pytest.mark.xfail('True')
578
+
579
+ @pytest.mark.parametrize('x', [0, 1, m(2)])
580
+ def test_xfail(x):
581
+ assert x < 2
582
+ """ )
583
+ result = testdir .runpytest ()
584
+ result .stdout .fnmatch_lines ('* 2 passed, 1 xfailed in *' )
585
+
586
+ def test_parametrize_passed (self , testdir ):
587
+ testdir .makepyfile ("""
588
+ import pytest
589
+
590
+ m = pytest.mark.xfail('True')
591
+
592
+ @pytest.mark.parametrize('x', [0, 1, m(2)])
593
+ def test_xfail(x):
594
+ pass
595
+ """ )
596
+ result = testdir .runpytest ()
597
+ result .stdout .fnmatch_lines ('* 2 passed, 1 xpassed in *' )
598
+
599
+ def test_parametrize_xfail_passed (self , testdir ):
600
+ testdir .makepyfile ("""
601
+ import pytest
602
+
603
+ m = pytest.mark.xfail('False')
604
+
605
+ @pytest.mark.parametrize('x', [0, 1, m(2)])
606
+ def test_passed(x):
607
+ pass
608
+ """ )
609
+ result = testdir .runpytest ()
610
+ result .stdout .fnmatch_lines ('* 3 passed in *' )
611
+
534
612
535
613
class TestSorting :
536
614
def test_check_equality (self , testdir ):
0 commit comments