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 @@ -2441,10 +2441,6 @@ def __str__(self):
24412441 self .assertTypedEqual (StrSubclass (StrWithStr (OtherStrSubclass ('abc' ))),
24422442 StrSubclass ('abc' ))
24432443
2444- str_value = StrSubclass ('abc' )
2445- self .assertIs (str (WithStr (str_value )), str_value )
2446- self .assertIs (str (StrWithStr (str_value )), str_value )
2447-
24482444 self .assertTypedEqual (str (WithRepr ('<abc>' )), '<abc>' )
24492445 self .assertTypedEqual (str (WithRepr (StrSubclass ('<abc>' ))), StrSubclass ('<abc>' ))
24502446 self .assertTypedEqual (StrSubclass (WithRepr ('<abc>' )), StrSubclass ('<abc>' ))
@@ -2453,9 +2449,6 @@ def __str__(self):
24532449 self .assertTypedEqual (StrSubclass (WithRepr (OtherStrSubclass ('<abc>' ))),
24542450 StrSubclass ('<abc>' ))
24552451
2456- repr_value = StrSubclass ('<abc>' )
2457- self .assertIs (str (WithRepr (repr_value )), repr_value )
2458-
24592452 def test_unicode_repr (self ):
24602453 class s1 :
24612454 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