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 @@ -588,6 +588,7 @@ def assert_outcomes(
588
588
xpassed : int = 0 ,
589
589
xfailed : int = 0 ,
590
590
warnings : int = 0 ,
591
+ deselected : int = 0 ,
591
592
) -> None :
592
593
"""Assert that the specified outcomes appear with the respective
593
594
numbers (0 means it didn't occur) in the text output from a test run."""
@@ -604,6 +605,7 @@ def assert_outcomes(
604
605
xpassed = xpassed ,
605
606
xfailed = xfailed ,
606
607
warnings = warnings ,
608
+ deselected = deselected ,
607
609
)
608
610
609
611
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