comparison test/test_mailgw.py @ 5378:35ea9b1efc14

Python 3 preparation: "raise" syntax. Changing "raise Exception, value" to "raise Exception(value)". Tool-assisted patch. Particular cases to check carefully are the one place in frontends/ZRoundup/ZRoundup.py where a string exception needed to be fixed, and the one in roundup/cgi/client.py involving raising an exception with a traceback (requires three-argument form of raise in Python 2, which as I understand it requires exec() to avoid a Python 3 syntax error).
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 21:39:58 +0000
parents a4fe76fba54a
children 0942fe89e82e
comparison
equal deleted inserted replaced
5377:12fe83f90f0d 5378:35ea9b1efc14
143 res.append('') 143 res.append('')
144 res.extend(body_diff) 144 res.extend(body_diff)
145 145
146 if res: 146 if res:
147 res.insert(0, 'Generated message not correct (diff follows, expected vs. actual):') 147 res.insert(0, 'Generated message not correct (diff follows, expected vs. actual):')
148 raise AssertionError, '\n'.join(res) 148 raise AssertionError('\n'.join(res))
149 149
150 def compareStrings(self, s2, s1, replace={}): 150 def compareStrings(self, s2, s1, replace={}):
151 '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants 151 '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants
152 the first to be the "original" but in the calls in this file, 152 the first to be the "original" but in the calls in this file,
153 the second arg is the original. Ho hum. 153 the second arg is the original. Ho hum.
2569 2569
2570 Unknown address: fubar@bork.bork.bork 2570 Unknown address: fubar@bork.bork.bork
2571 """) 2571 """)
2572 assert not body_diff, body_diff 2572 assert not body_diff, body_diff
2573 else: 2573 else:
2574 raise AssertionError, "Unauthorized not raised when handling mail" 2574 raise AssertionError("Unauthorized not raised when handling mail")
2575 2575
2576 # Add Web Access role to anonymous, and try again to make sure 2576 # Add Web Access role to anonymous, and try again to make sure
2577 # we get a "please register at:" message this time. 2577 # we get a "please register at:" message this time.
2578 p = [ 2578 p = [
2579 self.db.security.getPermission('Register', 'user'), 2579 self.db.security.getPermission('Register', 'user'),
2592 2592
2593 Unknown address: fubar@bork.bork.bork 2593 Unknown address: fubar@bork.bork.bork
2594 """) 2594 """)
2595 assert not body_diff, body_diff 2595 assert not body_diff, body_diff
2596 else: 2596 else:
2597 raise AssertionError, "Unauthorized not raised when handling mail" 2597 raise AssertionError("Unauthorized not raised when handling mail")
2598 2598
2599 # Make sure list of users is the same as before. 2599 # Make sure list of users is the same as before.
2600 m = self.db.user.list() 2600 m = self.db.user.list()
2601 m.sort() 2601 m.sort()
2602 self.assertEqual(l, m) 2602 self.assertEqual(l, m)

Roundup Issue Tracker: http://roundup-tracker.org/