From 085ea3f62f37539a279f7d4ade51208fcbe868b9 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 3 Sep 2008 18:32:49 +0000 Subject: 239: Added errors.ConversionError; started big clean up of how ValidationError is raised so it works well with multivalues --- ipalib/tests/tstutil.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ipalib/tests/tstutil.py') diff --git a/ipalib/tests/tstutil.py b/ipalib/tests/tstutil.py index 79e8ae38..1bf3eaab 100644 --- a/ipalib/tests/tstutil.py +++ b/ipalib/tests/tstutil.py @@ -22,6 +22,7 @@ Utility functions for the unit tests. """ import inspect +from ipalib import errors class ExceptionNotRaised(Exception): """ @@ -131,3 +132,16 @@ class ClassChecker(object): self.__class__.__name__, 'get_subcls()' ) + + +def check_TypeError(value, type_, name, callback, *args, **kw): + """ + Tests a standard TypeError raised with `errors.raise_TypeError`. + """ + e = raises(TypeError, callback, *args, **kw) + assert e.value == value + assert type(e.value) is type(value) + assert e.type is type_ + assert e.name == name + assert type(e.name) is str + assert str(e) == errors.TYPE_FORMAT % (name, type_, value) -- cgit