summary refs log tree commit diff
path: root/tests/unittest.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-18 14:31:47 +0100
committerErik Johnston <erik@matrix.org>2014-09-18 14:31:47 +0100
commit335e5d131c90b82d1e7aa3955079f549fc211540 (patch)
treee21eae5ca01c2ab157e44eca2f8c2efe99735f23 /tests/unittest.py
parentMerge branch 'release-v0.3.0' of github.com:matrix-org/synapse (diff)
parentMerge branch 'develop' into test-sqlite-memory (diff)
downloadsynapse-335e5d131c90b82d1e7aa3955079f549fc211540.tar.xz
Merge branch 'test-sqlite-memory' of github.com:matrix-org/synapse into develop
Conflicts:
	tests/handlers/test_profile.py
Diffstat (limited to 'tests/unittest.py')
-rw-r--r--tests/unittest.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unittest.py b/tests/unittest.py
index fb97fb1148..a9c0e05541 100644
--- a/tests/unittest.py
+++ b/tests/unittest.py
@@ -71,6 +71,17 @@ class TestCase(unittest.TestCase):
             logging.getLogger().setLevel(level)
             return orig()
 
+    def assertObjectHasAttributes(self, attrs, obj):
+        """Asserts that the given object has each of the attributes given, and
+        that the value of each matches according to assertEquals."""
+        for (key, value) in attrs.items():
+            if not hasattr(obj, key):
+                raise AssertionError("Expected obj to have a '.%s'" % key)
+            try:
+                self.assertEquals(attrs[key], getattr(obj, key))
+            except AssertionError as e:
+                raise (type(e))(e.message + " for '.%s'" % key)
+
 
 def DEBUG(target):
     """A decorator to set the .loglevel attribute to logging.DEBUG.