File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed
Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -2440,10 +2440,6 @@ def __str__(self):
24402440 self .assertTypedEqual (StrSubclass (StrWithStr (OtherStrSubclass ('abc' ))),
24412441 StrSubclass ('abc' ))
24422442
2443- str_value = StrSubclass ('abc' )
2444- self .assertIs (str (WithStr (str_value )), str_value )
2445- self .assertIs (str (StrWithStr (str_value )), str_value )
2446-
24472443 self .assertTypedEqual (str (WithRepr ('<abc>' )), '<abc>' )
24482444 self .assertTypedEqual (str (WithRepr (StrSubclass ('<abc>' ))), StrSubclass ('<abc>' ))
24492445 self .assertTypedEqual (StrSubclass (WithRepr ('<abc>' )), StrSubclass ('<abc>' ))
@@ -2452,9 +2448,6 @@ def __str__(self):
24522448 self .assertTypedEqual (StrSubclass (WithRepr (OtherStrSubclass ('<abc>' ))),
24532449 StrSubclass ('<abc>' ))
24542450
2455- repr_value = StrSubclass ('<abc>' )
2456- self .assertIs (str (WithRepr (repr_value )), repr_value )
2457-
24582451 def test_unicode_repr (self ):
24592452 class s1 :
24602453 def __repr__ (self ):
Original file line number Diff line number Diff line change @@ -19,6 +19,33 @@ def __init__(self, value):
1919assert y + " other" == "1 other"
2020assert y .x == "substr"
2121
22+
23+ class ReprStrSubclass (str ):
24+ pass
25+
26+
27+ class WithStr :
28+ def __init__ (self , value ):
29+ self .value = value
30+
31+ def __str__ (self ):
32+ return self .value
33+
34+
35+ class WithRepr :
36+ def __init__ (self , value ):
37+ self .value = value
38+
39+ def __repr__ (self ):
40+ return self .value
41+
42+
43+ str_value = ReprStrSubclass ("abc" )
44+ assert str (WithStr (str_value )) is str_value
45+
46+ repr_value = ReprStrSubclass ("<abc>" )
47+ assert str (WithRepr (repr_value )) is repr_value
48+
2249## Base strings currently get an attribute dict, but shouldn't.
2350# with assert_raises(AttributeError):
2451# "hello".x = 5
You can’t perform that action at this time.
0 commit comments