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

Method test_location_is_set

testing/test_assertrewrite.py:114–134  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

112 assert isinstance(m.body[3], ast.Expr)
113
114 def test_location_is_set(self) -> None:
115 s = textwrap.dedent(
116 """
117
118 assert False, (
119
120 "Ouch"
121 )
122
123 """
124 )
125 m = rewrite(s)
126 for node in m.body:
127 if isinstance(node, ast.Import):
128 continue
129 for n in [node, *ast.iter_child_nodes(node)]:
130 assert n.lineno == 3
131 assert n.col_offset == 0
132 if sys.version_info >= (3, 8):
133 assert n.end_lineno == 6
134 assert n.end_col_offset == 3
135
136 def test_dont_rewrite(self) -> None:
137 s = """'PYTEST_DONT_REWRITE'\nassert 14"""

Callers

nothing calls this directly

Calls 1

rewriteFunction · 0.85

Tested by

no test coverage detected