change standard repr to ClassName
This commit is contained in:
parent
f248baf418
commit
be7a67c93e
@ -2,12 +2,12 @@
|
||||
|
||||
>>> class Missing(Sentinel): pass
|
||||
>>> Missing
|
||||
<Missing>
|
||||
Missing
|
||||
>>> class CustomRepr(Sentinel):
|
||||
... repr = '*** sentinel ***'
|
||||
... repr = '<CustomRepr>'
|
||||
...
|
||||
>>> CustomRepr
|
||||
*** sentinel ***
|
||||
<CustomRepr>
|
||||
|
||||
"""
|
||||
|
||||
@ -16,9 +16,8 @@ class SentinelMeta(type):
|
||||
try:
|
||||
return cls.repr
|
||||
except AttributeError:
|
||||
return f'<{cls.__name__}>'
|
||||
return cls.__name__
|
||||
|
||||
class Sentinel(metaclass=SentinelMeta):
|
||||
def __new__(cls):
|
||||
return cls
|
||||
|
||||
|
@ -8,7 +8,7 @@ class SentinelCustomRepr(Sentinel):
|
||||
|
||||
|
||||
def test_repr():
|
||||
assert repr(PlainSentinel) == '<PlainSentinel>'
|
||||
assert repr(PlainSentinel) == 'PlainSentinel'
|
||||
|
||||
|
||||
def test_pickle():
|
||||
|
Loading…
Reference in New Issue
Block a user