add simpler exception message, assert that it is being used
This commit is contained in:
parent
5be436b81d
commit
bc7dea8bab
|
@ -826,9 +826,12 @@ class Wormholes(ServerBase, unittest.TestCase):
|
|||
code = yield w1.get_code()
|
||||
code_no_dashes = code.replace('-', ' ')
|
||||
|
||||
with self.assertRaises(KeyFormatError):
|
||||
with self.assertRaises(KeyFormatError) as ex:
|
||||
w2.set_code(code_no_dashes)
|
||||
|
||||
expected_msg = "code (%s) contains spaces." % (code_no_dashes,)
|
||||
self.assertEqual(expected_msg, str(ex.exception))
|
||||
|
||||
yield w1.close()
|
||||
yield w2.close()
|
||||
self.flushLoggedErrors(ValueError)
|
||||
|
|
|
@ -479,10 +479,7 @@ class _Wormhole:
|
|||
# bail out early if the password contains spaces...
|
||||
# this should raise a useful error
|
||||
if ' ' in code:
|
||||
raise KeyFormatError(
|
||||
"code (%s) contains spaces. Words must be separated by dashes"
|
||||
% code
|
||||
)
|
||||
raise KeyFormatError("code (%s) contains spaces." % code)
|
||||
self._code = code
|
||||
mo = re.search(r'^(\d+)-', code)
|
||||
if not mo:
|
||||
|
|
Loading…
Reference in New Issue
Block a user