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

Method test_EOFS_with_file

Lib/test/test_eof.py:48–85  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

46
47 @force_not_colorized
48 def test_EOFS_with_file(self):
49 expect = ("(<string>, line 1)")
50 with os_helper.temp_dir() as temp_dir:
51 file_name = script_helper.make_script(temp_dir, 'foo',
52 """ä = '''thîs is \na \ntest""")
53 rc, out, err = script_helper.assert_python_failure('-X', 'utf8', file_name)
54 err = err.decode().splitlines()
55 self.assertEqual(err[-3:], [
56 " ä = '''thîs is ",
57 ' ^',
58 'SyntaxError: unterminated triple-quoted string literal (detected at line 3)'])
59
60 file_name = script_helper.make_script(temp_dir, 'foo',
61 """ä = '''thîs is \na \ntest""".encode())
62 rc, out, err = script_helper.assert_python_failure('-X', 'utf8', file_name)
63 err = err.decode().splitlines()
64 self.assertEqual(err[-3:], [
65 " ä = '''thîs is ",
66 ' ^',
67 'SyntaxError: unterminated triple-quoted string literal (detected at line 3)'])
68
69 file_name = script_helper.make_script(temp_dir, 'foo',
70 BOM_UTF8 + """ä = '''thîs is \na \ntest""".encode())
71 rc, out, err = script_helper.assert_python_failure('-X', 'utf8', file_name)
72 err = err.decode().splitlines()
73 self.assertEqual(err[-3:], [
74 " ä = '''thîs is ",
75 ' ^',
76 'SyntaxError: unterminated triple-quoted string literal (detected at line 3)'])
77
78 file_name = script_helper.make_script(temp_dir, 'foo',
79 """# coding: latin1\nä = '''thîs is \na \ntest""".encode('latin1'))
80 rc, out, err = script_helper.assert_python_failure('-X', 'utf8', file_name)
81 err = err.decode().splitlines()
82 self.assertEqual(err[-3:], [
83 " ä = '''thîs is ",
84 ' ^',
85 'SyntaxError: unterminated triple-quoted string literal (detected at line 4)'])
86
87 @warnings_helper.ignore_warnings(category=SyntaxWarning)
88 def test_eof_with_line_continuation(self):

Callers

nothing calls this directly

Calls 7

temp_dirMethod · 0.80
assert_python_failureMethod · 0.80
make_scriptMethod · 0.45
splitlinesMethod · 0.45
decodeMethod · 0.45
assertEqualMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected