diff options
author | Jelmer Vernooij <jelmer@jelmer.uk> | 2022-07-01 19:36:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-01 19:36:24 +0100 |
commit | 4c352be4d3ba2dbf870b1e19885c4a4135264295 (patch) | |
tree | 6ddaccbb766e2c516aae67d9fdc0a9fba1243c8c | |
parent | da597fa5de20687ac45142e90c72382f4b694c05 (diff) | |
parent | e223b5dfada74e8a7438f699c81ab2baeb08df60 (diff) | |
download | testtools-4c352be4d3ba2dbf870b1e19885c4a4135264295.tar.gz |
Merge pull request #248 from gone/master
Making sure that TestCase can be hashed
-rw-r--r-- | testtools/testcase.py | 2 | ||||
-rw-r--r-- | testtools/tests/test_testcase.py | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/testtools/testcase.py b/testtools/testcase.py index 012def3..f3bd510 100644 --- a/testtools/testcase.py +++ b/testtools/testcase.py @@ -275,6 +275,8 @@ class TestCase(unittest.TestCase): return False return self.__dict__ == other.__dict__ + __hash__ = unittest.TestCase.__hash__ + def __repr__(self): # We add id to the repr because it makes testing testtools easier. return f"<{self.id()} id=0x{id(self):0x}>" diff --git a/testtools/tests/test_testcase.py b/testtools/tests/test_testcase.py index 00cb60d..c2766ff 100644 --- a/testtools/tests/test_testcase.py +++ b/testtools/tests/test_testcase.py @@ -86,6 +86,10 @@ class TestPlaceHolder(TestCase): test = PlaceHolder("test id", "description") self.assertEqual("description", test.shortDescription()) + def test_testcase_is_hashable(self): + test = hash(self) + self.assertEqual(unittest.TestCase.__hash__(self), test) + def test_repr_just_id(self): # repr(placeholder) shows you how the object was constructed. test = PlaceHolder("test id") |