mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
bpo-38669: patch.object now raises a helpful error (GH17034)
This means a clearer message is now shown when patch.object is called with two string arguments, rather than a class and a string argument.
This commit is contained in:
parent
28c91631c2
commit
cd90a52983
3 changed files with 9 additions and 0 deletions
|
@ -105,6 +105,10 @@ class PatchTest(unittest.TestCase):
|
|||
self.assertEqual(Something.attribute, sentinel.Original,
|
||||
"patch not restored")
|
||||
|
||||
def test_patchobject_with_string_as_target(self):
|
||||
msg = "'Something' must be the actual object to be patched, not a str"
|
||||
with self.assertRaisesRegex(TypeError, msg):
|
||||
patch.object('Something', 'do_something')
|
||||
|
||||
def test_patchobject_with_none(self):
|
||||
class Something(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue