diff options
author | Martin Babinsky <mbabinsk@redhat.com> | 2015-11-20 13:47:34 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2015-12-21 12:05:23 +0100 |
commit | cd5fa389450d15d5bc696131f73d062000d3558f (patch) | |
tree | 92bfddf529d5b772456d5e7ea9bc1187d83fec9e /ipatests/test_ipalib/test_backend.py | |
parent | aa648bcedcdb06162f1e578731ecf7fba299b709 (diff) | |
download | freeipa-cd5fa389450d15d5bc696131f73d062000d3558f.tar.gz freeipa-cd5fa389450d15d5bc696131f73d062000d3558f.tar.xz freeipa-cd5fa389450d15d5bc696131f73d062000d3558f.zip |
raise more descriptive Backend connection-related exceptions
https://fedorahosted.org/freeipa/ticket/5473
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipatests/test_ipalib/test_backend.py')
-rw-r--r-- | ipatests/test_ipalib/test_backend.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ipatests/test_ipalib/test_backend.py b/ipatests/test_ipalib/test_backend.py index 086831037..f758d4ac7 100644 --- a/ipatests/test_ipalib/test_backend.py +++ b/ipatests/test_ipalib/test_backend.py @@ -93,9 +93,10 @@ class test_Connectible(ClassChecker): assert conn.disconnect == o.disconnect # Test that Exception is raised if already connected: - m = "connect: 'context.%s' already exists in thread %r" + m = "{0} is already connected ({1} in {2})" e = raises(Exception, o.connect, *args, **kw) - assert str(e) == m % ('example', threading.currentThread().getName()) + assert str(e) == m.format( + 'example', o.id, threading.currentThread().getName()) # Double check that it works after deleting context.example: del context.example @@ -122,9 +123,10 @@ class test_Connectible(ClassChecker): destroy_connection = Disconnect() o = example(api, shared_instance=True) - m = "disconnect: 'context.%s' does not exist in thread %r" + m = "{0} is not connected ({1} in {2})" e = raises(Exception, o.disconnect) - assert str(e) == m % ('example', threading.currentThread().getName()) + assert str(e) == m.format( + 'example', o.id, threading.currentThread().getName()) context.example = 'The connection.' assert o.disconnect() is None @@ -162,14 +164,14 @@ class test_Connectible(ClassChecker): Test the `ipalib.backend.Connectible.conn` property. """ api = 'the api instance' - msg = 'no context.%s in thread %r' + msg = '{0} is not connected ({1} in {2})' class example(self.cls): pass for klass in (self.cls, example): o = klass(api, shared_instance=True) e = raises(AttributeError, getattr, o, 'conn') - assert str(e) == msg % ( - klass.__name__, threading.currentThread().getName() + assert str(e) == msg.format( + klass.__name__, o.id, threading.currentThread().getName() ) conn = Connection('The connection.', Disconnect()) setattr(context, klass.__name__, conn) |