/
asserts.py
29 lines (23 loc) · 968 Bytes
/
asserts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import re
import unittest
from nose import tools
from nose.tools import *
__all__ = ['assert_instance_of', 'assert_not_instance_of',
'assert_none', 'assert_not_none',
'assert_list_same'] + tools.__all__
def assert_instance_of(expected, actual, msg=None):
"""Verify that object is an instance of expected """
assert isinstance(actual, expected), msg
def assert_not_instance_of(expected, actual, msg=None):
"""Verify that object is not an instance of expected """
assert not isinstance(actual, expected, msg)
def assert_none(actual, msg=None):
"""verify that item is None"""
assert_equal(None, actual, msg)
def assert_not_none(actual, msg=None):
"""verify that item is None"""
assert_not_equal(None, actual, msg)
def assert_list_same(expected, actual, msg=None):
"""verify that the list contains the expected"""
assert_equal([repr(e) for e in expected],
[repr(a) for a in actual])