File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+ Regression tests for the behaviour of ``unittest.mock.PropertyMock `` were added.
Original file line number Diff line number Diff line change @@ -1086,7 +1086,7 @@ def test_propertymock(self):
1086
1086
p .stop ()
1087
1087
1088
1088
1089
- def test_propertymock_returnvalue (self ):
1089
+ def test_propertymock_bare (self ):
1090
1090
m = MagicMock ()
1091
1091
p = PropertyMock ()
1092
1092
type(m ).foo = p
@@ -1097,6 +1097,27 @@ def test_propertymock_returnvalue(self):
1097
1097
self .assertNotIsInstance (returned , PropertyMock )
1098
1098
1099
1099
1100
+ def test_propertymock_returnvalue (self ):
1101
+ m = MagicMock ()
1102
+ p = PropertyMock (return_value = 42 )
1103
+ type(m ).foo = p
1104
+
1105
+ returned = m .foo
1106
+ p .assert_called_once_with ()
1107
+ self .assertEqual (returned , 42 )
1108
+ self .assertNotIsInstance (returned , PropertyMock )
1109
+
1110
+
1111
+ def test_propertymock_side_effect (self ):
1112
+ m = MagicMock ()
1113
+ p = PropertyMock (side_effect = ValueError )
1114
+ type(m ).foo = p
1115
+
1116
+ with self .assertRaises (ValueError ):
1117
+ m .foo
1118
+ p .assert_called_once_with ()
1119
+
1120
+
1100
1121
class TestCallablePredicate (unittest .TestCase ):
1101
1122
1102
1123
def test_type (self ):
You can’t perform that action at this time.
0 commit comments