97 from .robottypes
import type_name
98 from .unic
import unic
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:
176 'Correct exception but wrong message')
178 if hasattr(exc_class,
'__name__'):
179 exc_name = exc_class.__name__
181 exc_name = str(exc_class)
186 def assert_equal(first, second, msg=None, values=True, formatter=None):
187 if not first == second:
205 if round(second - first, places) != 0:
206 extra =
'within %r places' % places
218 if round(second-first, places) == 0:
219 extra =
'within %r places' % places
230 formatter=None, extra=None):
241 formatter = formatter
or unic
242 str1 = formatter(obj1)
243 str2 = formatter(obj2)
244 if delim ==
'!=' and str1 == str2:
245 return '%s (%s) != %s (%s)' % (str1,
type_name(obj1),
247 return '%s %s %s' % (str1, delim, str2)
def assert_false(expr, msg=None)
Fail the test if the expression is True.
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 assert_not_none(obj, msg=None, values=True)
Fail the test if given object is None.
def _format_message(obj1, obj2, delim, formatter=None)
def fail(msg=None)
Fail test immediately with the given message.
def assert_raises(exc_class, callable_obj, *args, **kwargs)
Fail unless an exception of class exc_class is thrown by callable_obj.
def assert_true(expr, msg=None)
Fail the test unless the expression is True.
def assert_not_equal(first, second, msg=None, values=True, formatter=None)
Fail if given objects are equal as determined by the '==' operator.
def assert_none(obj, msg=None, values=True)
Fail the test if given object is not None.
def assert_equal(first, second, msg=None, values=True, formatter=None)
Fail if given objects are unequal as determined by the '==' operator.
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 _report_inequality(obj1, obj2, delim, msg=None, values=False, formatter=None, extra=None)
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.