From 1014c6e373313c642c4d72ad884a1ebbc69e8de1 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 29 Oct 2012 10:50:18 +0100 Subject: [PATCH] Include both involved backends in the error message --- mopidy/core/actor.py | 7 +++++-- tests/core/actor_test.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mopidy/core/actor.py b/mopidy/core/actor.py index 7fdaeb71..482868ad 100644 --- a/mopidy/core/actor.py +++ b/mopidy/core/actor.py @@ -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 diff --git a/tests/core/actor_test.py b/tests/core/actor_test.py index 9feddbd0..8212c1da 100644 --- a/tests/core/actor_test.py +++ b/tests/core/actor_test.py @@ -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])