Include both involved backends in the error message

This commit is contained in:
Stein Magnus Jodal 2012-10-29 10:50:18 +01:00
parent 4a79b559d5
commit 1014c6e373
2 changed files with 9 additions and 3 deletions

View File

@ -63,6 +63,9 @@ class Backends(list):
uri_schemes = backend.uri_schemes.get()
for uri_scheme in uri_schemes:
assert uri_scheme not in self.by_uri_scheme, (
'URI scheme %s is already handled by %s'
% (uri_scheme, backend.__class__.__name__))
'Cannot add URI scheme %s for %s, '
'it is already handled by %s'
) % (
uri_scheme, backend.__class__.__name__,
self.by_uri_scheme[uri_scheme].__class__.__name__)
self.by_uri_scheme[uri_scheme] = backend

View File

@ -26,7 +26,10 @@ class CoreActorTest(unittest.TestCase):
self.assertIn('dummy2', result)
def test_backends_with_colliding_uri_schemes_fails(self):
self.backend1.__class__.__name__ = 'B1'
self.backend2.__class__.__name__ = 'B2'
self.backend2.uri_schemes.get.return_value = ['dummy1', 'dummy2']
self.assertRaisesRegexp(
AssertionError, 'URI scheme dummy1 is already handled by Mock',
AssertionError,
'Cannot add URI scheme dummy1 for B2, it is already handled by B1',
Core, audio=None, backends=[self.backend1, self.backend2])