comparison tests/test-manifest.py @ 25660:328739ea70c3

global: mass rewrite to use modern exception syntax Python 2.6 introduced the "except type as instance" syntax, replacing the "except type, instance" syntax that came before. Python 3 dropped support for the latter syntax. Since we no longer support Python 2.4 or 2.5, we have no need to continue supporting the "except type, instance". This patch mass rewrites the exception syntax to be Python 2.6+ and Python 3 compatible. This patch was produced by running `2to3 -f except -w -n .`.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 23 Jun 2015 22:20:08 -0700
parents 29c238e4a58a
children b502138f5faa
comparison
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
323 backwards = ''.join( 323 backwards = ''.join(
324 l + '\n' for l in reversed(A_SHORT_MANIFEST.split('\n')) if l) 324 l + '\n' for l in reversed(A_SHORT_MANIFEST.split('\n')) if l)
325 try: 325 try:
326 self.parsemanifest(backwards) 326 self.parsemanifest(backwards)
327 self.fail('Should have raised ValueError') 327 self.fail('Should have raised ValueError')
328 except ValueError, v: 328 except ValueError as v:
329 self.assertIn('Manifest lines not in sorted order.', str(v)) 329 self.assertIn('Manifest lines not in sorted order.', str(v))
330 330
331 def testNoTerminalNewline(self): 331 def testNoTerminalNewline(self):
332 try: 332 try:
333 self.parsemanifest(A_SHORT_MANIFEST + 'wat') 333 self.parsemanifest(A_SHORT_MANIFEST + 'wat')
334 self.fail('Should have raised ValueError') 334 self.fail('Should have raised ValueError')
335 except ValueError, v: 335 except ValueError as v:
336 self.assertIn('Manifest did not end in a newline.', str(v)) 336 self.assertIn('Manifest did not end in a newline.', str(v))
337 337
338 def testNoNewLineAtAll(self): 338 def testNoNewLineAtAll(self):
339 try: 339 try:
340 self.parsemanifest('wat') 340 self.parsemanifest('wat')
341 self.fail('Should have raised ValueError') 341 self.fail('Should have raised ValueError')
342 except ValueError, v: 342 except ValueError as v:
343 self.assertIn('Manifest did not end in a newline.', str(v)) 343 self.assertIn('Manifest did not end in a newline.', str(v))
344 344
345 def testHugeManifest(self): 345 def testHugeManifest(self):
346 m = self.parsemanifest(A_HUGE_MANIFEST) 346 m = self.parsemanifest(A_HUGE_MANIFEST)
347 self.assertEqual(HUGE_MANIFEST_ENTRIES, len(m)) 347 self.assertEqual(HUGE_MANIFEST_ENTRIES, len(m))