File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -572,7 +572,8 @@ def __getattr__(self, name):
572572 raise AttributeError (name )
573573 if not self ._mock_unsafe :
574574 if name .startswith (('assert' , 'assret' )):
575- raise AttributeError (name )
575+ raise AttributeError ("Attributes cannot start with 'assert' "
576+ "or 'assret'" )
576577
577578 result = self ._mock_children .get (name )
578579 if result is _deleted :
Original file line number Diff line number Diff line change @@ -1453,9 +1453,10 @@ def static_method(): pass
14531453 #Issue21238
14541454 def test_mock_unsafe (self ):
14551455 m = Mock ()
1456- with self .assertRaises (AttributeError ):
1456+ msg = "Attributes cannot start with 'assert' or 'assret'"
1457+ with self .assertRaisesRegex (AttributeError , msg ):
14571458 m .assert_foo_call ()
1458- with self .assertRaises (AttributeError ):
1459+ with self .assertRaisesRegex (AttributeError , msg ):
14591460 m .assret_foo_call ()
14601461 m = Mock (unsafe = True )
14611462 m .assert_foo_call ()
You can’t perform that action at this time.
0 commit comments