46
46
count = withStderrTo(err, lambda: checkPath('extremo'))
47
47
self.assertEquals(err.getvalue(), 'extremo: no such file\n')
48
48
self.assertEquals(count, 1)
51
def test_multilineSyntaxError(self):
53
Source which includes a syntax error which results in the raised
54
L{SyntaxError.text} containing multiple lines of source are reported
55
with only the last line of that source.
68
# Sanity check - SyntaxError.text should be multiple lines, if it
69
# isn't, something this test was unprepared for has happened.
72
exc = self.assertRaises(SyntaxError, evaluate, source)
73
self.assertTrue(exc.text.count('\n') > 1)
75
sourcePath = FilePath(self.mktemp())
76
sourcePath.setContent(source)
78
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
79
self.assertEqual(count, 1)
87
""" % (sourcePath.path,))
90
def test_eofSyntaxError(self):
92
The error reported for source files which end prematurely causing a
93
syntax error reflects the cause for the syntax error.
96
sourcePath = FilePath(self.mktemp())
97
sourcePath.setContent(source)
99
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
100
self.assertEqual(count, 1)
104
%s:1: unexpected EOF while parsing
107
""" % (sourcePath.path,))