Module Expr Str ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam defaults NameLoad body Expr Str Expr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If NameLoad body Expr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If UnaryOpNot NameLoad body Expr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign NameStore Str If CompareIs NameLoad NameLoad body If CompareIs NameLoad NameLoad body Assign NameStore NameLoad orelse If CompareIs NameLoad NameLoad body Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad Expr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign NameStore BinOpMod Str NameLoad If CompareIsNot NameLoad NameLoad body If CompareIs NameLoad NameLoad body Assign NameStore NameLoad orelse If CompareIs NameLoad NameLoad body Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad Expr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults vararg kwarg body Expr Str TryExcept body Expr Call NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad name NameStore body Return NameLoad orelse If Call NameLoad NameLoad Str body Assign NameStore AttributeLoad NameLoad attr orelse Assign NameStore Call NameLoad NameLoad Expr Call NameLoad BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults vararg kwarg body Expr Str TryExcept body Expr Call NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad name NameStore body Expr Call NameLoad NameLoad Call NameLoad NameLoad Str orelse If Call NameLoad NameLoad Str body Assign NameStore AttributeLoad NameLoad attr orelse Assign NameStore Call NameLoad NameLoad Expr Call NameLoad BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If UnaryOpNot CompareEq NameLoad NameLoad body Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If CompareEq NameLoad NameLoad body Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Num NameLoad NameLoad body Expr Str If CompareNotEq Call NameLoad BinOpSub NameLoad NameLoad NameLoad Num body Assign NameStore BinOpMod Str NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Num NameLoad NameLoad body Expr Str If CompareEq Call NameLoad BinOpSub NameLoad NameLoad NameLoad Num body Assign NameStore BinOpMod Str NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body If CompareIs NameLoad NameLoad body Raise Call NameLoad Raise Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad body If UnaryOpNot NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad orelse If NameLoad body Assign NameStore BinOpMod Str TupleLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad If BoolOpAnd NameLoad NameLoad body AugAssignAdd NameStore BinOpAdd Str NameLoad Raise Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad If BoolOpAnd CompareEq NameLoad Str CompareEq NameLoad NameLoad body Return BinOpMod Str TupleLoad NameLoad Call NameLoad NameLoad NameLoad Call NameLoad NameLoad Return BinOpMod Str TupleLoad NameLoad NameLoad NameLoad decorator_list
N/A N/A Convenience functions for testing both in unit and higher levels.

Benefits:
  - Integrates 100% with unittest (see example below)
  - Can be easily used without unittest (using unittest.TestCase when you
    only need convenient asserts is not so nice)
  - Saved typing and shorter lines because no need to have 'self.' before
    asserts. These are static functions after all so that is OK.
  - All 'equals' methods (by default) report given values even if optional
    message given. This behavior can be controlled with the optional values
    argument.

Drawbacks:
  - unittest is not able to filter as much non-interesting traceback away
    as with its own methods because AssertionErrors occur outside.

Most of the functions are copied more or less directly from unittest.TestCase
which comes with the following license. Further information about unittest in
general can be found from http://pyunit.sourceforge.net/. This module can be
used freely in same terms as unittest.

unittest license::

    Copyright (c) 1999-2003 Steve Purcell
    This module is free software, and you may redistribute it and/or modify
    it under the same terms as Python itself, so long as this copyright message
    and disclaimer are retained in their original form.

    IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
    SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
    THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
    DAMAGE.

    THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
    PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
    AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
    SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Examples::

    import unittest
    from robot.utils.asserts import assert_equal

    class MyTests(unittest.TestCase):

        def test_old_style(self):
            self.assertEqual(1, 2, 'my msg')

        def test_new_style(self):
            assert_equal(1, 2, 'my msg')

Example output::

    FF
    ======================================================================
    FAIL: test_old_style (example.MyTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "example.py", line 7, in test_old_style
        self.assertEqual(1, 2, 'my msg')
    AssertionError: my msg

    ======================================================================
    FAIL: test_new_style (example.MyTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "example.py", line 10, in test_new_style
        assert_equal(1, 2, 'my msg')
      File "/path/to/robot/utils/asserts.py", line 181, in assert_equal
        _report_inequality_failure(first, second, msg, values, '!=')
      File "/path/to/robot/utils/asserts.py", line 229, in _report_inequality_failure
        raise AssertionError(msg)
    AssertionError: my msg: 1 != 2

    ----------------------------------------------------------------------
    Ran 2 tests in 0.000s

    FAILED (failures=2)
 robottypes type_name unic unic fail N/A N/A msg N/A None N/A N/A Fail test immediately with the given message. N/A N/A _report_failure msg N/A assert_false N/A N/A expr msg N/A None N/A N/A Fail the test if the expression is True. N/A expr N/A N/A N/A _report_failure msg N/A assert_true N/A N/A expr msg N/A None N/A N/A Fail the test unless the expression is True. N/A N/A expr N/A N/A N/A _report_failure msg N/A assert_not_none N/A N/A obj msg values N/A None True N/A N/A Fail the test if given object is None. N/A _msg is None N/A N/A obj None N/A N/A N/A msg None N/A N/A msg _msg N/A N/A N/A values True N/A N/A msg N/A %s: %s N/A msg _msg N/A N/A _report_failure msg N/A assert_none N/A N/A obj msg values N/A None True N/A N/A Fail the test if given object is not None. N/A _msg N/A %r is not None obj N/A N/A obj None N/A N/A N/A msg None N/A N/A msg _msg N/A N/A N/A values True N/A N/A msg N/A %s: %s N/A msg _msg N/A N/A _report_failure msg N/A assert_raises N/A N/A exc_class callable_obj N/A args kwargs N/A N/A Fail unless an exception of class exc_class is thrown by callable_obj.

    callable_obj is invoked with arguments args and keyword arguments
    kwargs. If a different type of exception is thrown, it will not be
    caught, and the test case will be deemed to have suffered an
    error, exactly as for an unexpected exception.

    If a correct exception is raised, the exception instance is returned
    by this method.
     N/A N/A N/A N/A callable_obj args kwargs N/A N/A N/A exc_class N/A err N/A N/A err N/A N/A N/A hasattr exc_class __name__ N/A N/A exc_name N/A exc_class __name__ N/A N/A exc_name N/A str exc_class N/A N/A _report_failure N/A %s not raised exc_name N/A assert_raises_with_msg N/A N/A exc_class expected_msg callable_obj N/A args kwargs N/A N/A Similar to fail_unless_raises but also checks the exception message. N/A N/A N/A N/A callable_obj args kwargs N/A N/A N/A exc_class N/A err N/A N/A N/A assert_equal expected_msg N/A unic err Correct exception but wrong message N/A N/A N/A hasattr exc_class __name__ N/A N/A exc_name N/A exc_class __name__ N/A N/A exc_name N/A str exc_class N/A N/A _report_failure N/A %s not raised exc_name N/A assert_equal N/A N/A first second msg values N/A None True N/A N/A Fail if given objects are unequal as determined by the '==' operator. N/A N/A N/A first second N/A N/A N/A _report_inequality_failure first second msg values != N/A assert_not_equal N/A N/A first second msg values N/A None True N/A N/A Fail if given objects are equal as determined by the '==' operator. N/A N/A first second N/A N/A N/A _report_inequality_failure first second msg values == N/A assert_almost_equal N/A N/A first second places msg values N/A 7 None True N/A N/A Fail if the two objects are unequal after rounded to given places.

    inequality is determined by object's difference rounded to the
    given number of decimal places (default 7) and comparing to zero.
    Note that decimal places (from zero) are usually not the same as
    significant digits (measured from the most signficant digit).
     N/A N/A N/A round N/A second first places 0 N/A N/A extra N/A within %r places places N/A N/A _report_inequality_failure first second msg values != extra N/A assert_not_almost_equal N/A N/A first second places msg values N/A 7 None True N/A N/A Fail if the two objects are unequal after rounded to given places.

    Equality is determined by object's difference rounded to to the
    given number of decimal places (default 7) and comparing to zero.
    Note that decimal places (from zero) are usually not the same as
    significant digits (measured from the most significant digit).
     N/A N/A N/A round N/A second first places 0 N/A N/A extra N/A within %r places places N/A N/A _report_inequality_failure first second msg values == extra N/A _report_failure N/A N/A msg N/A N/A N/A N/A msg None N/A N/A N/A AssertionError N/A N/A AssertionError msg N/A _report_inequality_failure N/A N/A obj1 obj2 msg values delim extra N/A None N/A N/A N/A msg N/A N/A msg N/A _get_default_message obj1 obj2 delim N/A N/A values N/A N/A msg N/A %s: %s N/A msg N/A _get_default_message obj1 obj2 delim N/A N/A values extra N/A N/A msg N/A extra N/A N/A AssertionError msg N/A _get_default_message N/A N/A obj1 obj2 delim N/A N/A N/A str1 N/A unic obj1 N/A str2 N/A unic obj2 N/A N/A N/A delim != N/A str1 str2 N/A N/A N/A %s (%s) != %s (%s) N/A str1 N/A type_name obj1 str2 N/A type_name obj2 N/A N/A %s %s %s N/A str1 delim str2 N/A