diff options
author | BonfaceKilz | 2020-07-24 02:14:50 +0300 |
---|---|---|
committer | BonfaceKilz | 2020-07-24 03:47:45 +0300 |
commit | 09bc3137328fbefe41044b5124f3c6a7abaa8982 (patch) | |
tree | 4e130dda52aca3828c9b82afb97267fe6f3c426b /wqflask | |
parent | f95a42b0a9445a58e68fc83e9b1411bedef67904 (diff) | |
download | genenetwork2-09bc3137328fbefe41044b5124f3c6a7abaa8982.tar.gz |
Add more tests for general_object
* wqflask/tests/base/test_general_object.py: test getattr() and `==`
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/tests/base/test_general_object.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/wqflask/tests/base/test_general_object.py b/wqflask/tests/base/test_general_object.py index df5791e0..c7701021 100644 --- a/wqflask/tests/base/test_general_object.py +++ b/wqflask/tests/base/test_general_object.py @@ -21,7 +21,21 @@ class TestGeneralObjectTests(unittest.TestCase): self.assertEqual( repr(test_obj), "value = 1\nname = test\ncontents = ['a']\n") self.assertEqual(len(test_obj), 2) - self.assertEqual(getattr(test_obj, "value"), 1) self.assertEqual(test_obj["value"], 1) test_obj["test"] = 1 self.assertEqual(test_obj["test"], 1) + + def test_get_attribute(self): + "Test that getattr works" + test_obj = GeneralObject("a", name="test", value=1) + self.assertEqual(getattr(test_obj, "value", None), 1) + self.assertEqual(getattr(test_obj, "non-existent", None), None) + + def test_object_comparisons(self): + "Test that 2 objects of the same length are equal" + test_obj1 = GeneralObject("a", name="test", value=1) + test_obj2 = GeneralObject("b", name="test2", value=2) + test_obj3 = GeneralObject("a", name="test", x=1, y=2) + self.assertTrue(test_obj1 == test_obj2 ) + self.assertFalse(test_obj1 == test_obj3 ) + |