Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions testtools/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ def __eq__(self, other):
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}>"
Expand Down
4 changes: 4 additions & 0 deletions testtools/tests/test_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def test_shortDescription_specified(self):
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")
Expand Down