Merge pull request #1360 from meejah/4091.fragile

Fix fragile unit-test (4091)

Fixes ticket:4091
This commit is contained in:
Itamar Turner-Trauring 2024-02-27 15:32:19 -05:00 committed by GitHub
commit a23a97d45b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

0
newsfragments/4091.minor Normal file
View File

View File

@ -27,7 +27,8 @@ class NoArgumentException(Exception):
class HumanReadable(unittest.TestCase):
def test_repr(self):
hr = humanreadable.hr
self.failUnlessEqual(hr(foo), "<foo() at test_humanreadable.py:20>")
# we match on regex so this test isn't fragile about line-numbers
self.assertRegex(hr(foo), r"<foo\(\) at test_humanreadable.py:\d+>")
self.failUnlessEqual(hr(self.test_repr),
"<bound method HumanReadable.test_repr of <allmydata.test.test_humanreadable.HumanReadable testMethod=test_repr>>")
self.failUnlessEqual(hr(long(1)), "1")