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

Method check_line_extraction

Lib/test/test_tokenize.py:2037–2046  ·  view source on GitHub ↗
(self, f)

Source from the content-addressed store, hash-verified

2035 self.assertEqual(code_without_bom, untokenized_code)
2036
2037 def check_line_extraction(self, f):
2038 if isinstance(f, str):
2039 code = f.encode('utf-8')
2040 else:
2041 code = f.read()
2042 readline = iter(code.splitlines(keepends=True)).__next__
2043 for tok in tokenize.tokenize(readline):
2044 if tok.type in {tokenize.ENCODING, tokenize.ENDMARKER}:
2045 continue
2046 self.assertEqual(tok.string, tok.line[tok.start[1]: tok.end[1]])
2047
2048 def test_roundtrip(self):
2049 # There are some standard formatting practices that are easy to get right.

Callers 1

test_random_filesMethod · 0.95

Calls 4

encodeMethod · 0.45
readMethod · 0.45
splitlinesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected