97 from .robottypes
import type_name
98 from .unic
import safe_str
128 msg =
'%s: %s' % (msg, _msg)
137 _msg =
'%r is not None' % obj
142 msg =
'%s: %s' % (msg, _msg)
158 callable_obj(*args, **kwargs)
159 except exc_class
as err:
162 if hasattr(exc_class,
'__name__'):
163 exc_name = exc_class.__name__
165 exc_name = str(exc_class)
173 callable_obj(*args, **kwargs)
174 except exc_class
as err:
175 assert_equal(expected_msg, str(err),
'Correct exception but wrong message')
177 if hasattr(exc_class,
'__name__'):
178 exc_name = exc_class.__name__
180 exc_name = str(exc_class)
185 def assert_equal(first, second, msg=None, values=True, formatter=safe_str):
186 if not first == second:
204 if round(second - first, places) != 0:
205 extra =
'within %r places' % places
217 if round(second-first, places) == 0:
218 extra =
'within %r places' % places
240 str1 = formatter(obj1)
241 str2 = formatter(obj2)
242 if delim ==
'!=' and str1 == str2:
243 return '%s (%s) != %s (%s)' % (str1,
type_name(obj1),
245 return '%s %s %s' % (str1, delim, str2)
def assert_not_equal(first, second, msg=None, values=True, formatter=safe_str)
Fail if given objects are equal as determined by the '==' operator.
def assert_true(expr, msg=None)
Fail the test unless the expression is True.
def assert_almost_equal(first, second, places=7, msg=None, values=True)
Fail if the two objects are unequal after rounded to given places.
def assert_none(obj, msg=None, values=True)
Fail the test if given object is not None.
def _report_inequality(obj1, obj2, delim, msg=None, values=False, formatter=safe_str, extra=None)
def assert_raises(exc_class, callable_obj, *args, **kwargs)
Fail unless an exception of class exc_class is thrown by callable_obj.
def assert_not_almost_equal(first, second, places=7, msg=None, values=True)
Fail if the two objects are unequal after rounded to given places.
def assert_raises_with_msg(exc_class, expected_msg, callable_obj, *args, **kwargs)
Similar to fail_unless_raises but also checks the exception message.
def _format_message(obj1, obj2, delim, formatter=safe_str)
def assert_not_none(obj, msg=None, values=True)
Fail the test if given object is None.
def fail(msg=None)
Fail test immediately with the given message.
def assert_equal(first, second, msg=None, values=True, formatter=safe_str)
Fail if given objects are unequal as determined by the '==' operator.
def assert_false(expr, msg=None)
Fail the test if the expression is True.
def type_name(item, capitalize=False)
Return "non-technical" type name for objects and types.