File tree 2 files changed +23
-1
lines changed
Lib/unittest/test/testmock 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1077,7 +1077,7 @@ def test_propertymock(self):
1077
1077
p .stop ()
1078
1078
1079
1079
1080
- def test_propertymock_returnvalue (self ):
1080
+ def test_propertymock_bare (self ):
1081
1081
m = MagicMock ()
1082
1082
p = PropertyMock ()
1083
1083
type(m ).foo = p
@@ -1088,6 +1088,27 @@ def test_propertymock_returnvalue(self):
1088
1088
self .assertNotIsInstance (returned , PropertyMock )
1089
1089
1090
1090
1091
+ def test_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
+ def test_propertymock_side_effect (self ):
1103
+ m = MagicMock ()
1104
+ p = PropertyMock (side_effect = ValueError )
1105
+ type(m ).foo = p
1106
+
1107
+ with self .assertRaises (ValueError ):
1108
+ m .foo
1109
+ p .assert_called_once_with ()
1110
+
1111
+
1091
1112
class TestCallablePredicate (unittest .TestCase ):
1092
1113
1093
1114
def test_type (self ):
Original file line number Diff line number Diff line change
1
+ Regression tests for the behaviour of ``unittest.mock.PropertyMock `` were added.
You can’t perform that action at this time.
0 commit comments