Skip to content

Commit

Permalink
馃И馃殤馃悰 Adjust object ID repr @ unbound saferepr test
Browse files Browse the repository at this point in the history
Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
  • Loading branch information
Farbod Ahmadian and webknjaz committed Jun 20, 2024
1 parent d6f3559 commit 7828d15
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions testing/io/test_saferepr.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,20 @@ def __repr__(self):

class TestSafereprUnbounded:
class Help:
def __init__(self, i):
self.i = i

def bound_method(self):
return self.i
pass

Check warning on line 198 in testing/io/test_saferepr.py

View check run for this annotation

Codecov / codecov/patch

testing/io/test_saferepr.py#L198

Added line #L198 was not covered by tests

def test_saferepr_bound_method(self):
"""saferepr() of a bound method should show only the method name"""
assert saferepr(self.Help(10).bound_method) == "bound_method"
assert saferepr(self.Help().bound_method) == "bound_method"

def test_saferepr_unbounded(self):
"""saferepr() of an unbound method should still show the full information"""
obj = self.Help(10)
obj = self.Help()
obj_id = f"{id(obj) :x}".lstrip("0").lower()
assert (
saferepr(obj)
== f"<test_saferepr.{self.__class__.__name__}.Help object at 0x{id(obj):x}>"
== f"<test_saferepr.{self.__class__.__name__}.Help object at 0x{obj_id !s}>"
)
assert (
saferepr(self.Help)
Expand Down

0 comments on commit 7828d15

Please sign in to comment.