summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unittest
diff options
context:
space:
mode:
authorChristian Klein <167265+cklein@users.noreply.github.com>2023-01-04 22:31:29 (GMT)
committerGitHub <noreply@github.com>2023-01-04 22:31:29 (GMT)
commit7f1eefc6f4843f0fca60308f557a71af11d18a53 (patch)
tree4e9e176fc5596c5dd2d6d094de2887fe41c77833 /Lib/test/test_unittest
parent52017dbe1681a7cd4fe0e8d6fbbf81fd711a0506 (diff)
downloadcpython-7f1eefc6f4843f0fca60308f557a71af11d18a53.zip
cpython-7f1eefc6f4843f0fca60308f557a71af11d18a53.tar.gz
cpython-7f1eefc6f4843f0fca60308f557a71af11d18a53.tar.bz2
gh-100739: Respect mock spec when checking for unsafe prefixes (#100740)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/test/test_unittest')
-rw-r--r--Lib/test/test_unittest/testmock/testmock.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_unittest/testmock/testmock.py b/Lib/test/test_unittest/testmock/testmock.py
index 8a92490..b224f87 100644
--- a/Lib/test/test_unittest/testmock/testmock.py
+++ b/Lib/test/test_unittest/testmock/testmock.py
@@ -1652,6 +1652,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()