1
from nose.tools import ok_
5
raise AssertionError(msg)
8
def assert_in(thing, seq, msg=None):
9
msg = msg or "'%s' not found in %s" % (thing, seq)
10
ok_(thing in seq, msg)
13
def assert_not_in(thing, seq, msg=None):
14
msg = msg or "unexpected '%s' found in %s" % (thing, seq)
15
ok_(thing not in seq, msg)
18
def assert_has_keys(dict, required=[], optional=[]):
21
assert_in(k, keys, "required key %s missing from %s" % (k, dict))
22
allowed_keys = set(required) | set(optional)
23
extra_keys = set(keys).difference(set(required + optional))
25
fail("found unexpected keys: %s" % list(extra_keys))
28
def assert_isinstance(thing, kls):
29
ok_(isinstance(thing, kls), "%s is not an instance of %s" % (thing, kls))