Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Lib/unittest/test/testmock/testhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def test_propertymock(self):
p.stop()


def test_propertymock_returnvalue(self):
def test_propertymock_bare(self):
m = MagicMock()
p = PropertyMock()
type(m).foo = p
Expand All @@ -1088,6 +1088,27 @@ def test_propertymock_returnvalue(self):
self.assertNotIsInstance(returned, PropertyMock)


def test_propertymock_returnvalue(self):
m = MagicMock()
p = PropertyMock(return_value=42)
type(m).foo = p

returned = m.foo
p.assert_called_once_with()
self.assertEqual(returned, 42)
self.assertNotIsInstance(returned, PropertyMock)


def test_propertymock_side_effect(self):
m = MagicMock()
p = PropertyMock(side_effect=ValueError)
type(m).foo = p

with self.assertRaises(ValueError):
m.foo
p.assert_called_once_with()


class TestCallablePredicate(unittest.TestCase):

def test_type(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Regression tests for the behaviour of ``unittest.mock.PropertyMock`` were added.