MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_errors_in_xfail_skip_expressions

Function test_errors_in_xfail_skip_expressions

testing/test_skipping.py:1126–1171  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1124
1125
1126def test_errors_in_xfail_skip_expressions(pytester: Pytester) -> None:
1127 pytester.makepyfile(
1128 """
1129 import pytest
1130 @pytest.mark.skipif("asd")
1131 def test_nameerror():
1132 pass
1133 @pytest.mark.xfail("syntax error")
1134 def test_syntax():
1135 pass
1136
1137 def test_func():
1138 pass
1139 """
1140 )
1141 result = pytester.runpytest()
1142 markline = " ^"
1143 pypy_version_info = getattr(sys, "pypy_version_info", None)
1144 if pypy_version_info is not None and pypy_version_info < (6,):
1145 markline = markline[5:]
1146 elif sys.version_info >= (3, 8) or hasattr(sys, "pypy_version_info"):
1147 markline = markline[4:]
1148
1149 if sys.version_info[:2] >= (3, 10):
1150 expected = [
1151 "*ERROR*test_nameerror*",
1152 "*asd*",
1153 "",
1154 "During handling of the above exception, another exception occurred:",
1155 ]
1156 else:
1157 expected = [
1158 "*ERROR*test_nameerror*",
1159 ]
1160
1161 expected += [
1162 "*evaluating*skipif*condition*",
1163 "*asd*",
1164 "*ERROR*test_syntax*",
1165 "*evaluating*xfail*condition*",
1166 " syntax error",
1167 markline,
1168 "SyntaxError: invalid syntax",
1169 "*1 pass*2 errors*",
1170 ]
1171 result.stdout.fnmatch_lines(expected)
1172
1173
1174def test_xfail_skipif_with_globals(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected