##// END OF EJS Templates
Add failing test for gh-4361
Thomas Kluyver -
Show More
@@ -138,3 +138,12 b' class SyntaxErrorTest(unittest.TestCase):'
138 138 # The SyntaxError should point to the correct line
139 139 with tt.AssertPrints(["7/", "SyntaxError"]):
140 140 ip.magic("run " + fname)
141
142 def test_non_syntaxerror(self):
143 # SyntaxTB may be called with an error other than a SyntaxError
144 # See e.g. gh-4361
145 try:
146 raise ValueError('QWERTY')
147 except ValueError:
148 with tt.AssertPrints('QWERTY'):
149 ip.showsyntaxerror()
@@ -357,6 +357,9 b' class AssertPrints(object):'
357 357 setattr(sys, self.channel, self.buffer if self.suppress else self.tee)
358 358
359 359 def __exit__(self, etype, value, traceback):
360 if value is not None:
361 # If an error was raised, don't check anything else
362 return False
360 363 self.tee.flush()
361 364 setattr(sys, self.channel, self.orig_stream)
362 365 printed = self.buffer.getvalue()
@@ -375,6 +378,9 b' class AssertNotPrints(AssertPrints):'
375 378
376 379 Counterpart of AssertPrints"""
377 380 def __exit__(self, etype, value, traceback):
381 if value is not None:
382 # If an error was raised, don't check anything else
383 return False
378 384 self.tee.flush()
379 385 setattr(sys, self.channel, self.orig_stream)
380 386 printed = self.buffer.getvalue()
General Comments 0
You need to be logged in to leave comments. Login now