From 5e8f945a1ea2f34f40a5e033801d66162fc63850 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 3 Sep 2008 19:38:39 +0000 Subject: 242: Started cleanup of custom exceptions; added unit tests for errors.IPAError --- ipalib/tests/test_errors.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'ipalib/tests/test_errors.py') diff --git a/ipalib/tests/test_errors.py b/ipalib/tests/test_errors.py index 34b195e8..b0b5483c 100644 --- a/ipalib/tests/test_errors.py +++ b/ipalib/tests/test_errors.py @@ -129,3 +129,34 @@ def test_check_isinstance(): fail_bool = 0 e = raises(AssertionError, f, value, type_, name, allow_none=fail_bool) assert str(e) == type_format % ('allow_none', bool, fail_bool) + + +class test_IPAError(ClassChecker): + """ + Tests the `errors.IPAError` exception. + """ + _cls = errors.IPAError + + def test_class(self): + assert self.cls.__bases__ == (Exception,) + + def test_init(self): + """ + Tests the `errors.IPAError.__init__` method. + """ + args = ('one fish', 'two fish') + e = self.cls(*args) + assert e.args == args + assert self.cls().args == tuple() + + def test_str(self): + """ + Tests the `errors.IPAError.__str__` method. + """ + f = 'The %s color is %s.' + class custom_error(self.cls): + format = f + for args in [('sexiest', 'red'), ('most-batman-like', 'black')]: + e = custom_error(*args) + assert e.args == args + assert str(e) == f % args -- cgit