Closed
Description
Bug report
3.12.0a7 changed the behavior of unittest.mock.PropertyMock
Setup:
from unittest.mock import MagicMock, PropertyMock
m = MagicMock()
p1 = PropertyMock(return_value=3)
p2 = PropertyMock(side_effect=ValueError)
type(m).foo = p1
type(m).bar = p2
In Python 3.12.0a6 and earlier, m.foo
evaluates as 3, and m.bar
raises a ValueError.
In Python 3.12.0a7, m.foo
evaluates as 3, and m.bar
returns <MagicMock name='mock.bar' id=...>
Your environment
- CPython versions tested on: 3.12.0a7, 3.12.0a6, 3.11.2, 3.10.10, 3.9.16, 3.8.16
- Operating system and architecture:
- macOS Ventura 13.2.1, on an M1 MacBook Pro.
- GitHub Actions macOS 12 x86_64
- GitHub Actions Ubuntu 22.04
- GitHub Actions Windows Server 2022