File tree Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Expand file tree Collapse file tree 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(
588588 xpassed : int = 0 ,
589589 xfailed : int = 0 ,
590590 warnings : int = 0 ,
591+ deselected : int = 0 ,
591592 ) -> None :
592593 """Assert that the specified outcomes appear with the respective
593594 numbers (0 means it didn't occur) in the text output from a test run."""
@@ -604,6 +605,7 @@ def assert_outcomes(
604605 xpassed = xpassed ,
605606 xfailed = xfailed ,
606607 warnings = warnings ,
608+ deselected = deselected ,
607609 )
608610
609611
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ def assert_outcomes(
4343 xpassed : int = 0 ,
4444 xfailed : int = 0 ,
4545 warnings : int = 0 ,
46+ deselected : int = 0 ,
4647) -> None :
4748 """Assert that the specified outcomes appear with the respective
4849 numbers (0 means it didn't occur) in the text output from a test run."""
@@ -56,6 +57,7 @@ def assert_outcomes(
5657 "xpassed" : outcomes .get ("xpassed" , 0 ),
5758 "xfailed" : outcomes .get ("xfailed" , 0 ),
5859 "warnings" : outcomes .get ("warnings" , 0 ),
60+ "deselected" : outcomes .get ("deselected" , 0 ),
5961 }
6062 expected = {
6163 "passed" : passed ,
@@ -65,5 +67,6 @@ def assert_outcomes(
6567 "xpassed" : xpassed ,
6668 "xfailed" : xfailed ,
6769 "warnings" : warnings ,
70+ "deselected" : deselected ,
6871 }
6972 assert obtained == expected
Original file line number Diff line number Diff line change @@ -861,3 +861,17 @@ def test_with_warning():
861861 )
862862 result = pytester .runpytest ()
863863 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