Skip to content

3.12.0a7 changes behavior of PropertyMock #103329

Closed
@freakboy3742

Description

@freakboy3742

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions