summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-01-23 18:42:41 (GMT)
committerGitHub <noreply@github.com>2022-01-23 18:42:41 (GMT)
commitf7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418 (patch)
treebe80eeca8d122c5b8a256c1c9675b05c9623e214 /Lib/unittest/test
parentca78130d7eb5265759697639e42487ec6d0a4caf (diff)
downloadcpython-f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418.zip
cpython-f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418.tar.gz
cpython-f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418.tar.bz2
bpo-41403: Improve error message for invalid mock target (GH-30833)
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/testmock/testpatch.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/unittest/test/testmock/testpatch.py
index 233a5af..8ab63a1 100644
--- a/Lib/unittest/test/testmock/testpatch.py
+++ b/Lib/unittest/test/testmock/testpatch.py
@@ -1933,8 +1933,13 @@ class PatchTest(unittest.TestCase):
def test_invalid_target(self):
- with self.assertRaises(TypeError):
- patch('')
+ class Foo:
+ pass
+
+ for target in ['', 12, Foo()]:
+ with self.subTest(target=target):
+ with self.assertRaises(TypeError):
+ patch(target)
def test_cant_set_kwargs_when_passing_a_mock(self):