File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2049,21 +2049,24 @@ def blech(self):
20492049 self .assertEqual (obj , exc .obj )
20502050
20512051 def test_getattr_error_message (self ):
2052+ def fqn (type ):
2053+ return f'{ type .__module__ } .{ type .__qualname__ } '
2054+
20522055 class RaiseWithName :
20532056 def __getattr__ (self , name ):
20542057 raise AttributeError (name )
20552058 with self .assertRaises (AttributeError ) as cm :
20562059 getattr (RaiseWithName (), "missing1" )
2057- self .assertRegex (str (cm .exception ),
2058- r"'.+\. RaiseWithName' object has no attribute 'missing1'" )
2060+ self .assertEqual (str (cm .exception ),
2061+ f"' { fqn ( RaiseWithName ) } ' object has no attribute 'missing1'" )
20592062
20602063 class BareRaise :
20612064 def __getattr__ (self , name ):
20622065 raise AttributeError
20632066 with self .assertRaises (AttributeError ) as cm :
20642067 getattr (BareRaise (), "missing2" )
2065- self .assertRegex (str (cm .exception ),
2066- r"'.+\. BareRaise' object has no attribute 'missing2'" )
2068+ self .assertEqual (str (cm .exception ),
2069+ f"' { fqn ( BareRaise ) } ' object has no attribute 'missing2'" )
20672070
20682071 class RaiseCustom :
20692072 def __getattr__ (self , name ):
You can’t perform that action at this time.
0 commit comments