33import logging
44import os
55import subprocess
6+ import sys
67import textwrap
78from pathlib import Path
89from typing import Iterator
1516logger = logging .getLogger (__name__ )
1617
1718
19+ def assert_1_item_passed (output ):
20+ if sys .version_info >= (3 , 13 ):
21+ assert "1 item passed all tests" in output
22+ else :
23+ assert "1 items passed all tests" in output
24+
25+
1826class SphinxDoctestRunner :
1927 def __init__ (self , tmp_path : Path ) -> None :
2028 self .tmp_path : Path = tmp_path
@@ -105,7 +113,7 @@ def test_simple_doctest_success(sphinx_tester: SphinxDoctestRunner) -> None:
105113 6
106114 """
107115 )
108- assert "1 items passed all tests" in output
116+ assert_1_item_passed ( output )
109117
110118
111119class TestDirectives :
@@ -123,7 +131,7 @@ def test_testcode(
123131 """
124132
125133 sphinx_output = sphinx_tester (code )
126- assert "1 items passed all tests" in sphinx_output
134+ assert_1_item_passed ( sphinx_output )
127135
128136 plugin_result = testdir .runpytest ("--doctest-glob=index.rst" ).stdout
129137 plugin_result .fnmatch_lines (["*=== 1 passed in *" ])
@@ -139,7 +147,7 @@ def test_doctest(
139147 """
140148
141149 sphinx_output = sphinx_tester (code )
142- assert "1 items passed all tests" in sphinx_output
150+ assert_1_item_passed ( sphinx_output )
143151
144152 plugin_result = testdir .runpytest ("--doctest-glob=index.rst" ).stdout
145153 plugin_result .fnmatch_lines (["*=== 1 passed in *" ])
@@ -170,7 +178,7 @@ def test_doctest_multiple(
170178 """
171179
172180 sphinx_output = sphinx_tester (code )
173- assert "1 items passed all tests" in sphinx_output
181+ assert_1_item_passed ( sphinx_output )
174182
175183 plugin_result = testdir .runpytest ("--doctest-glob=index.rst" ).stdout
176184 plugin_result .fnmatch_lines (["*=== 1 passed in *" ])
@@ -201,7 +209,7 @@ def test_skipif_true(
201209 assert "1 failure in tests" in sphinx_output
202210 plugin_output .fnmatch_lines (["*=== 1 failed in *" ])
203211 else :
204- assert "1 items passed all tests" in sphinx_output
212+ assert_1_item_passed ( sphinx_output )
205213 plugin_output .fnmatch_lines (["*=== 1 passed in *" ])
206214
207215 @pytest .mark .parametrize (
@@ -230,7 +238,7 @@ def test_skipif_false(
230238 assert "1 failure in tests" in sphinx_output
231239 plugin_output .fnmatch_lines (["*=== 1 failed in *" ])
232240 else :
233- assert "1 items passed all tests" in sphinx_output
241+ assert_1_item_passed ( sphinx_output )
234242 plugin_output .fnmatch_lines (["*=== 1 passed in *" ])
235243
236244 @pytest .mark .parametrize ("wrong_output_assertion" , [True , False ])
@@ -272,7 +280,7 @@ def test_skipif_multiple_testoutput(
272280 assert "1 failure in tests" in sphinx_output
273281 plugin_output .fnmatch_lines (["*=== 1 failed in *" ])
274282 else :
275- assert "1 items passed all tests" in sphinx_output
283+ assert_1_item_passed ( sphinx_output )
276284 plugin_output .fnmatch_lines (["*=== 1 passed in *" ])
277285
278286 @pytest .mark .parametrize ("testcode" , ["raise RuntimeError" , "pass" , "print(1234)" ])
0 commit comments