diff --git a/src/wormhole/test/test_wormhole.py b/src/wormhole/test/test_wormhole.py index eae68af..68d5679 100644 --- a/src/wormhole/test/test_wormhole.py +++ b/src/wormhole/test/test_wormhole.py @@ -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) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 1607413..7392433 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -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: