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 = yield w1.get_code()
|
||||||
code_no_dashes = code.replace('-', ' ')
|
code_no_dashes = code.replace('-', ' ')
|
||||||
|
|
||||||
with self.assertRaises(KeyFormatError):
|
with self.assertRaises(KeyFormatError) as ex:
|
||||||
w2.set_code(code_no_dashes)
|
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 w1.close()
|
||||||
yield w2.close()
|
yield w2.close()
|
||||||
self.flushLoggedErrors(ValueError)
|
self.flushLoggedErrors(ValueError)
|
||||||
|
|
|
@ -479,10 +479,7 @@ class _Wormhole:
|
||||||
# bail out early if the password contains spaces...
|
# bail out early if the password contains spaces...
|
||||||
# this should raise a useful error
|
# this should raise a useful error
|
||||||
if ' ' in code:
|
if ' ' in code:
|
||||||
raise KeyFormatError(
|
raise KeyFormatError("code (%s) contains spaces." % code)
|
||||||
"code (%s) contains spaces. Words must be separated by dashes"
|
|
||||||
% code
|
|
||||||
)
|
|
||||||
self._code = code
|
self._code = code
|
||||||
mo = re.search(r'^(\d+)-', code)
|
mo = re.search(r'^(\d+)-', code)
|
||||||
if not mo:
|
if not mo:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user