File tree 4 files changed +21
-0
lines changed
4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ :class: `RunResult <_pytest.pytester.RunResult> ` method :meth: `assert_outcomes <_pytest.pytester.RunResult.assert_outcomes> ` now accepts a
2
+ ``deselected `` argument to assert the total number of deselected tests.
Original file line number Diff line number Diff line change @@ -589,6 +589,7 @@ def assert_outcomes(
589
589
xpassed : int = 0 ,
590
590
xfailed : int = 0 ,
591
591
warnings : int = 0 ,
592
+ deselected : int = 0 ,
592
593
) -> None :
593
594
"""Assert that the specified outcomes appear with the respective
594
595
numbers (0 means it didn't occur) in the text output from a test run."""
@@ -605,6 +606,7 @@ def assert_outcomes(
605
606
xpassed = xpassed ,
606
607
xfailed = xfailed ,
607
608
warnings = warnings ,
609
+ deselected = deselected ,
608
610
)
609
611
610
612
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ def assert_outcomes(
43
43
xpassed : int = 0 ,
44
44
xfailed : int = 0 ,
45
45
warnings : int = 0 ,
46
+ deselected : int = 0 ,
46
47
) -> None :
47
48
"""Assert that the specified outcomes appear with the respective
48
49
numbers (0 means it didn't occur) in the text output from a test run."""
@@ -56,6 +57,7 @@ def assert_outcomes(
56
57
"xpassed" : outcomes .get ("xpassed" , 0 ),
57
58
"xfailed" : outcomes .get ("xfailed" , 0 ),
58
59
"warnings" : outcomes .get ("warnings" , 0 ),
60
+ "deselected" : outcomes .get ("deselected" , 0 ),
59
61
}
60
62
expected = {
61
63
"passed" : passed ,
@@ -65,5 +67,6 @@ def assert_outcomes(
65
67
"xpassed" : xpassed ,
66
68
"xfailed" : xfailed ,
67
69
"warnings" : warnings ,
70
+ "deselected" : deselected ,
68
71
}
69
72
assert obtained == expected
Original file line number Diff line number Diff line change @@ -861,3 +861,17 @@ def test_with_warning():
861
861
)
862
862
result = pytester .runpytest ()
863
863
result .assert_outcomes (passed = 1 , warnings = 1 )
864
+
865
+
866
+ def test_pytester_outcomes_deselected (pytester : Pytester ) -> None :
867
+ pytester .makepyfile (
868
+ """
869
+ def test_one():
870
+ pass
871
+
872
+ def test_two():
873
+ pass
874
+ """
875
+ )
876
+ result = pytester .runpytest ("-k" , "test_one" )
877
+ result .assert_outcomes (passed = 1 , deselected = 1 )
You can’t perform that action at this time.
0 commit comments