Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29a1e89

Browse files
gh-103329: Add regression test for PropertyMock with side effect (GH-103358)
(cherry picked from commit26c6598)Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
1 parent70bc8c9 commit29a1e89

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

‎Lib/unittest/test/testmock/testhelpers.py‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def test_propertymock(self):
10771077
p.stop()
10781078

10791079

1080-
deftest_propertymock_returnvalue(self):
1080+
deftest_propertymock_bare(self):
10811081
m=MagicMock()
10821082
p=PropertyMock()
10831083
type(m).foo=p
@@ -1088,6 +1088,27 @@ def test_propertymock_returnvalue(self):
10881088
self.assertNotIsInstance(returned,PropertyMock)
10891089

10901090

1091+
deftest_propertymock_returnvalue(self):
1092+
m=MagicMock()
1093+
p=PropertyMock(return_value=42)
1094+
type(m).foo=p
1095+
1096+
returned=m.foo
1097+
p.assert_called_once_with()
1098+
self.assertEqual(returned,42)
1099+
self.assertNotIsInstance(returned,PropertyMock)
1100+
1101+
1102+
deftest_propertymock_side_effect(self):
1103+
m=MagicMock()
1104+
p=PropertyMock(side_effect=ValueError)
1105+
type(m).foo=p
1106+
1107+
withself.assertRaises(ValueError):
1108+
m.foo
1109+
p.assert_called_once_with()
1110+
1111+
10911112
classTestCallablePredicate(unittest.TestCase):
10921113

10931114
deftest_type(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Regression tests for the behaviour of ``unittest.mock.PropertyMock`` were added.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp