Mercurial > p > roundup > code
comparison test/test_actions.py @ 5248:198b6e810c67
Use Python-3-compatible 'as' syntax for except statements
Many raise statements near these are also fixed.
So are two ivorrect file encoding marks ('utf8'->'utf-8').
| author | Eric S. Raymond <esr@thyrsus.com> |
|---|---|
| date | Thu, 24 Aug 2017 22:21:37 -0400 |
| parents | 114d9628fd77 |
| children | 64b05e24dbd8 |
comparison
equal
deleted
inserted
replaced
| 5247:7f00a47b3559 | 5248:198b6e810c67 |
|---|---|
| 35 message. We need this because we rely on exception messages when | 35 message. We need this because we rely on exception messages when |
| 36 redirecting. | 36 redirecting. |
| 37 """ | 37 """ |
| 38 try: | 38 try: |
| 39 callable(*args, **kwargs) | 39 callable(*args, **kwargs) |
| 40 except exception, msg: | 40 except exception as msg: |
| 41 self.assertEqual(str(msg), message) | 41 self.assertEqual(str(msg), message) |
| 42 else: | 42 else: |
| 43 if hasattr(exception, '__name__'): | 43 if hasattr(exception, '__name__'): |
| 44 excName = exception.__name__ | 44 excName = exception.__name__ |
| 45 else: | 45 else: |
| 244 message. We need this because we rely on exception messages when | 244 message. We need this because we rely on exception messages when |
| 245 redirecting. | 245 redirecting. |
| 246 """ | 246 """ |
| 247 try: | 247 try: |
| 248 callable(*args, **kwargs) | 248 callable(*args, **kwargs) |
| 249 except exception, msg: | 249 except exception as msg: |
| 250 self.assertEqual(str(msg), message) | 250 self.assertEqual(str(msg), message) |
| 251 else: | 251 else: |
| 252 if hasattr(exception, '__name__'): | 252 if hasattr(exception, '__name__'): |
| 253 excName = exception.__name__ | 253 excName = exception.__name__ |
| 254 else: | 254 else: |
| 394 ( {('msg','-1'):{'content':'t'},('issue','4711'):{}} | 394 ( {('msg','-1'):{'content':'t'},('issue','4711'):{}} |
| 395 , [('issue','4711','messages',[('msg','-1')])] | 395 , [('issue','4711','messages',[('msg','-1')])] |
| 396 ) | 396 ) |
| 397 try : | 397 try : |
| 398 self.action.handle() | 398 self.action.handle() |
| 399 except Redirect, msg: | 399 except Redirect as msg: |
| 400 pass | 400 pass |
| 401 self.assertEqual(expect, self.result) | 401 self.assertEqual(expect, self.result) |
| 402 | 402 |
| 403 def testMessageMultiAttach(self): | 403 def testMessageMultiAttach(self): |
| 404 expect = \ | 404 expect = \ |
| 412 , ('issue','4711'):{}} | 412 , ('issue','4711'):{}} |
| 413 , [('issue','4711','messages',[('msg','-1'),('msg','-2')])] | 413 , [('issue','4711','messages',[('msg','-1'),('msg','-2')])] |
| 414 ) | 414 ) |
| 415 try : | 415 try : |
| 416 self.action.handle() | 416 self.action.handle() |
| 417 except Redirect, msg: | 417 except Redirect as msg: |
| 418 pass | 418 pass |
| 419 self.assertEqual(expect, self.result) | 419 self.assertEqual(expect, self.result) |
| 420 | 420 |
| 421 def testFileAttach(self): | 421 def testFileAttach(self): |
| 422 expect = \ | 422 expect = \ |
| 433 ,('msg','-1','files',[('file','-1')]) | 433 ,('msg','-1','files',[('file','-1')]) |
| 434 ] | 434 ] |
| 435 ) | 435 ) |
| 436 try : | 436 try : |
| 437 self.action.handle() | 437 self.action.handle() |
| 438 except Redirect, msg: | 438 except Redirect as msg: |
| 439 pass | 439 pass |
| 440 self.assertEqual(expect, self.result) | 440 self.assertEqual(expect, self.result) |
| 441 | 441 |
| 442 def testLinkExisting(self): | 442 def testLinkExisting(self): |
| 443 expect = [('set',('4711',),{'messages':['23','42','1']})] | 443 expect = [('set',('4711',),{'messages':['23','42','1']})] |
| 446 ( {('issue','4711'):{},('msg','1'):{}} | 446 ( {('issue','4711'):{},('msg','1'):{}} |
| 447 , [('issue','4711','messages',[('msg','1')])] | 447 , [('issue','4711','messages',[('msg','1')])] |
| 448 ) | 448 ) |
| 449 try : | 449 try : |
| 450 self.action.handle() | 450 self.action.handle() |
| 451 except Redirect, msg: | 451 except Redirect as msg: |
| 452 pass | 452 pass |
| 453 self.assertEqual(expect, self.result) | 453 self.assertEqual(expect, self.result) |
| 454 | 454 |
| 455 def testLinkNewToExisting(self): | 455 def testLinkNewToExisting(self): |
| 456 expect = [('create',(),{'msg':'1','title':'TEST'})] | 456 expect = [('create',(),{'msg':'1','title':'TEST'})] |
| 459 ( {('issue','-1'):{'title':'TEST'},('msg','1'):{}} | 459 ( {('issue','-1'):{'title':'TEST'},('msg','1'):{}} |
| 460 , [('issue','-1','msg',[('msg','1')])] | 460 , [('issue','-1','msg',[('msg','1')])] |
| 461 ) | 461 ) |
| 462 try : | 462 try : |
| 463 self.action.handle() | 463 self.action.handle() |
| 464 except Redirect, msg: | 464 except Redirect as msg: |
| 465 pass | 465 pass |
| 466 self.assertEqual(expect, self.result) | 466 self.assertEqual(expect, self.result) |
| 467 | 467 |
| 468 # vim: set et sts=4 sw=4 : | 468 # vim: set et sts=4 sw=4 : |
