33dd843be2bb0992afd7fcd75613b3f3af2f00f4
[jelmer/gitpython.git] / test / testlib / asserts.py
1 import re
2 import unittest
3 from nose import tools
4 from nose.tools import *
5
6 __all__ = ['assert_instance_of', 'assert_not_instance_of', 
7            'assert_none', 'assert_not_none',
8            'assert_match', 'assert_not_match'] + tools.__all__
9
10 def assert_instance_of(expected, actual, msg=None):
11     """Verify that object is an instance of expected """
12     assert isinstance(actual, expected), msg
13
14 def assert_not_instance_of(expected, actual, msg=None):
15     """Verify that object is not an instance of expected """
16     assert not isinstance(actual, expected, msg)
17     
18 def assert_none(actual, msg=None):
19     """verify that item is None"""
20     assert_equal(None, actual, msg)
21
22 def assert_not_none(actual, msg=None):
23     """verify that item is None"""
24     assert_not_equal(None, actual, msg)
25
26 def assert_match(pattern, string, msg=None):
27     """verify that the pattern matches the string"""
28     assert_not_none(re.search(pattern, string), msg)
29
30 def assert_not_match(pattern, string, msg=None):
31     """verify that the pattern does not match the string"""
32     assert_none(re.search(pattern, string), msg)