summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-01-04 23:11:46 (GMT)
committerGitHub <noreply@github.com>2023-01-04 23:11:46 (GMT)
commitf49cc3c805dbc1bc54edeba3c248b875b3e6f3d3 (patch)
tree2dc4481958796cb4873b7e1b4b6f37d29f37fca1 /Lib/unittest/test
parentfee4059d213401011457531933e64790b181f33c (diff)
downloadcpython-f49cc3c805dbc1bc54edeba3c248b875b3e6f3d3.zip
cpython-f49cc3c805dbc1bc54edeba3c248b875b3e6f3d3.tar.gz
cpython-f49cc3c805dbc1bc54edeba3c248b875b3e6f3d3.tar.bz2
gh-100739: Respect mock spec when checking for unsafe prefixes (GH-100740)
(cherry picked from commit 7f1eefc6f4843f0fca60308f557a71af11d18a53) Co-authored-by: Christian Klein <167265+cklein@users.noreply.github.com> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/testmock/testmock.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index fdba543..535f908 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -1644,6 +1644,22 @@ class MockTest(unittest.TestCase):
m.aseert_foo_call()
m.assrt_foo_call()
+ # gh-100739
+ def test_mock_safe_with_spec(self):
+ class Foo(object):
+ def assert_bar(self):
+ pass
+
+ def assertSome(self):
+ pass
+
+ m = Mock(spec=Foo)
+ m.assert_bar()
+ m.assertSome()
+
+ m.assert_bar.assert_called_once()
+ m.assertSome.assert_called_once()
+
#Issue21262
def test_assert_not_called(self):
m = Mock()