Skip to content

Commit feb0bfd

Browse files
committed
handle pytest < 5.3.0 for continued python2.7 support
1 parent 6bd28a6 commit feb0bfd

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

testing/test_basic.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
import sys
23
import textwrap
34

@@ -12,6 +13,8 @@
1213

1314
timeout = 15
1415

16+
pytest_version = tuple(int(segment) for segment in pytest.__version__.split(".")[:3])
17+
1518

1619
# https://github.com/pytest-dev/pytest/issues/6505
1720
def force_plural(name):
@@ -1163,7 +1166,13 @@ def test_should_not_run():
11631166
# on Windows pytest isn't even reporting the status, just stopping...
11641167
assert_outcomes(rr, {})
11651168
rr.stdout.re_match_lines(lines2=[r".* no tests ran in .*"])
1166-
rr.stdout.no_re_match_line(pat=r".*test_should_not_run.*")
1169+
1170+
pattern = r".*test_should_not_run.*"
1171+
1172+
if pytest_version >= (5, 3, 0):
1173+
rr.stdout.no_re_match_line(pat=pattern)
1174+
else:
1175+
assert re.match(pattern, rr.stdout.str()) is None
11671176

11681177

11691178
def test_sigint_for_inline_callbacks_tests(testdir, cmd_opts):
@@ -1196,4 +1205,10 @@ def test_should_not_run():
11961205
# on Windows pytest isn't even reporting the status, just stopping...
11971206
assert_outcomes(rr, {})
11981207
rr.stdout.re_match_lines(lines2=[r".* no tests ran in .*"])
1199-
rr.stdout.no_re_match_line(pat=r".*test_should_not_run.*")
1208+
1209+
pattern = r".*test_should_not_run.*"
1210+
1211+
if pytest_version >= (5, 3, 0):
1212+
rr.stdout.no_re_match_line(pat=pattern)
1213+
else:
1214+
assert re.match(pattern, rr.stdout.str()) is None

0 commit comments

Comments
 (0)