##// END OF EJS Templates
use assertEqual instead of assertFalse or assertTrue
Srinivas Reddy Thatiparthy -
Show More
@@ -142,7 +142,7 b' class InputSplitterTestCase(unittest.TestCase):'
142 self.isp._store('1')
142 self.isp._store('1')
143 self.isp._store('2')
143 self.isp._store('2')
144 self.assertEqual(self.isp.source, '1\n2\n')
144 self.assertEqual(self.isp.source, '1\n2\n')
145 self.assertTrue(len(self.isp._buffer)>0)
145 self.assertEqual(len(self.isp._buffer)>0, True)
146 self.assertEqual(self.isp.source_reset(), '1\n2\n')
146 self.assertEqual(self.isp.source_reset(), '1\n2\n')
147 self.assertEqual(self.isp._buffer, [])
147 self.assertEqual(self.isp._buffer, [])
148 self.assertEqual(self.isp.source, '')
148 self.assertEqual(self.isp.source, '')
@@ -244,39 +244,39 b' class InputSplitterTestCase(unittest.TestCase):'
244
244
245 def test_push(self):
245 def test_push(self):
246 isp = self.isp
246 isp = self.isp
247 self.assertTrue(isp.push('x=1'))
247 self.assertEqual(isp.push('x=1'), True)
248
248
249 def test_push2(self):
249 def test_push2(self):
250 isp = self.isp
250 isp = self.isp
251 self.assertFalse(isp.push('if 1:'))
251 self.assertEqual(isp.push('if 1:'), False)
252 for line in [' x=1', '# a comment', ' y=2']:
252 for line in [' x=1', '# a comment', ' y=2']:
253 print(line)
253 print(line)
254 self.assertTrue(isp.push(line))
254 self.assertEqual(isp.push(line), True)
255
255
256 def test_push3(self):
256 def test_push3(self):
257 isp = self.isp
257 isp = self.isp
258 isp.push('if True:')
258 isp.push('if True:')
259 isp.push(' a = 1')
259 isp.push(' a = 1')
260 self.assertFalse(isp.push('b = [1,'))
260 self.assertEqual(isp.push('b = [1,'), False)
261
261
262 def test_push_accepts_more(self):
262 def test_push_accepts_more(self):
263 isp = self.isp
263 isp = self.isp
264 isp.push('x=1')
264 isp.push('x=1')
265 self.assertFalse(isp.push_accepts_more())
265 self.assertEqual(isp.push_accepts_more(), False)
266
266
267 def test_push_accepts_more2(self):
267 def test_push_accepts_more2(self):
268 isp = self.isp
268 isp = self.isp
269 isp.push('if 1:')
269 isp.push('if 1:')
270 self.assertTrue(isp.push_accepts_more())
270 self.assertEqual(isp.push_accepts_more(), True)
271 isp.push(' x=1')
271 isp.push(' x=1')
272 self.assertTrue(isp.push_accepts_more())
272 self.assertEqual(isp.push_accepts_more(), True)
273 isp.push('')
273 isp.push('')
274 self.assertFalse(isp.push_accepts_more())
274 self.assertEqual(isp.push_accepts_more(), False)
275
275
276 def test_push_accepts_more3(self):
276 def test_push_accepts_more3(self):
277 isp = self.isp
277 isp = self.isp
278 isp.push("x = (2+\n3)")
278 isp.push("x = (2+\n3)")
279 self.assertFalse(isp.push_accepts_more())
279 self.assertEqual(isp.push_accepts_more(), False)
280
280
281 def test_push_accepts_more4(self):
281 def test_push_accepts_more4(self):
282 isp = self.isp
282 isp = self.isp
@@ -290,11 +290,11 b' class InputSplitterTestCase(unittest.TestCase):'
290 isp.push("if 1:")
290 isp.push("if 1:")
291 isp.push(" x = (2+")
291 isp.push(" x = (2+")
292 isp.push(" 3)")
292 isp.push(" 3)")
293 self.assertTrue(isp.push_accepts_more())
293 self.assertEqual(isp.push_accepts_more(), True)
294 isp.push(" y = 3")
294 isp.push(" y = 3")
295 self.assertTrue(isp.push_accepts_more())
295 self.assertEqual(isp.push_accepts_more(), True)
296 isp.push('')
296 isp.push('')
297 self.assertFalse(isp.push_accepts_more())
297 self.assertEqual(isp.push_accepts_more(), False)
298
298
299 def test_push_accepts_more5(self):
299 def test_push_accepts_more5(self):
300 isp = self.isp
300 isp = self.isp
@@ -304,14 +304,14 b' class InputSplitterTestCase(unittest.TestCase):'
304 isp.push(' raise')
304 isp.push(' raise')
305 # We want to be able to add an else: block at this point, so it should
305 # We want to be able to add an else: block at this point, so it should
306 # wait for a blank line.
306 # wait for a blank line.
307 self.assertTrue(isp.push_accepts_more())
307 self.assertEqual(isp.push_accepts_more(), True)
308
308
309 def test_continuation(self):
309 def test_continuation(self):
310 isp = self.isp
310 isp = self.isp
311 isp.push("import os, \\")
311 isp.push("import os, \\")
312 self.assertTrue(isp.push_accepts_more())
312 self.assertEqual(isp.push_accepts_more(), True)
313 isp.push("sys")
313 isp.push("sys")
314 self.assertFalse(isp.push_accepts_more())
314 self.assertEqual(isp.push_accepts_more(), False)
315
315
316 def test_syntax_error(self):
316 def test_syntax_error(self):
317 isp = self.isp
317 isp = self.isp
@@ -319,7 +319,7 b' class InputSplitterTestCase(unittest.TestCase):'
319 # Python can be sent to the kernel for evaluation with possible ipython
319 # Python can be sent to the kernel for evaluation with possible ipython
320 # special-syntax conversion.
320 # special-syntax conversion.
321 isp.push('run foo')
321 isp.push('run foo')
322 self.assertFalse(isp.push_accepts_more())
322 self.assertEqual(isp.push_accepts_more(), False)
323
323
324 def test_unicode(self):
324 def test_unicode(self):
325 self.isp.push(u"Pérez")
325 self.isp.push(u"Pérez")
@@ -331,16 +331,16 b' class InputSplitterTestCase(unittest.TestCase):'
331 isp = self.isp
331 isp = self.isp
332 # A blank line after a line continuation should not accept more
332 # A blank line after a line continuation should not accept more
333 isp.push("1 \\\n\n")
333 isp.push("1 \\\n\n")
334 self.assertFalse(isp.push_accepts_more())
334 self.assertEqual(isp.push_accepts_more(), False)
335 # Whitespace after a \ is a SyntaxError. The only way to test that
335 # Whitespace after a \ is a SyntaxError. The only way to test that
336 # here is to test that push doesn't accept more (as with
336 # here is to test that push doesn't accept more (as with
337 # test_syntax_error() above).
337 # test_syntax_error() above).
338 isp.push(r"1 \ ")
338 isp.push(r"1 \ ")
339 self.assertFalse(isp.push_accepts_more())
339 self.assertEqual(isp.push_accepts_more(), False)
340 # Even if the line is continuable (c.f. the regular Python
340 # Even if the line is continuable (c.f. the regular Python
341 # interpreter)
341 # interpreter)
342 isp.push(r"(1 \ ")
342 isp.push(r"(1 \ ")
343 self.assertFalse(isp.push_accepts_more())
343 self.assertEqual(isp.push_accepts_more(), False)
344
344
345 def test_check_complete(self):
345 def test_check_complete(self):
346 isp = self.isp
346 isp = self.isp
General Comments 0
You need to be logged in to leave comments. Login now