summary refs log tree commit diff
path: root/tests/unittest.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-18 18:25:23 +0100
committerErik Johnston <erik@matrix.org>2014-09-18 18:25:23 +0100
commitbeed1ba089fa4aa0aca6ac9ef9c560508197baa4 (patch)
tree51b4105de45a5dea15013b90b2692d772599e302 /tests/unittest.py
parentRemove lie from change log. (diff)
parentfix SYWEB-41 (hopefully) (diff)
downloadsynapse-beed1ba089fa4aa0aca6ac9ef9c560508197baa4.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse
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.