MCPcopy Index your code
hub / github.com/python/cpython / test_indentation_semantics_retained

Method test_indentation_semantics_retained

Lib/test/test_tokenize.py:2199–2207  ·  view source on GitHub ↗

Ensure that although whitespace might be mutated in a roundtrip, the semantic meaning of the indentation remains consistent.

(self)

Source from the content-addressed store, hash-verified

2197 return tokenize.untokenize(tokenize.tokenize(BytesIO(code).readline)).decode('utf-8')
2198
2199 def test_indentation_semantics_retained(self):
2200 """
2201 Ensure that although whitespace might be mutated in a roundtrip,
2202 the semantic meaning of the indentation remains consistent.
2203 """
2204 code = "if False:\n\tx=3\n\tx=3\n"
2205 codelines = self.roundtrip(code).split('\n')
2206 self.assertEqual(codelines[1], codelines[2])
2207 self.check_roundtrip(code)
2208
2209
2210class InvalidPythonTests(TestCase):

Callers

nothing calls this directly

Calls 4

roundtripMethod · 0.95
check_roundtripMethod · 0.95
splitMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected