3 from dmigrations.exceptions import *
5 class WarningsMocker(object):
8 def __call__(self, warning):
9 self.warnings.append(warning)
11 class TestCase(unittest.TestCase):
13 Common code, and Pythonic (underscored) names support, instead of ugly javaCamelCase.
15 def assert_attrs(self, obj, **kwargs):
16 for key in sorted(kwargs.keys()):
17 expected = kwargs[key]
18 actual = getattr(obj, key)
19 self.assert_equal(expected, actual, u"Object's %s expected to be `%s', is `%s' instead" % (key, expected, actual))
21 def assert_raises(self, expected_exception_class, code):
24 self.assert_(False, u"Exception %s expected, but no exception raised" % expected_exception_class)
26 if isinstance(e, expected_exception_class):
29 raise # Assert false or raise an error is better ?
30 self.assert_(False, u"Exception %s expected, `%s' exception raised instead" % (expected_exception_class, e))
32 def assert_equal(self, *args, **kwargs):
33 self.assertEqual(*args, **kwargs)
36 self.mock_migrations_dir = os.path.join(os.path.dirname(__file__), "mock_migrations_dir")