Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python 3.12.3 -> 3.12.4 breaks use ofcreate_autospec(X, spec_set=True, name="X") #120732

Closed
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@ShapingView

Description

@ShapingView

Bug report

Bug description:

Hello, thanks for the work you do!

My issue: Updating from 3.12.3 to 3.12.4 breaks many elements in my test suite. We use thename= argument to better understand log messages once a test with many objects fails.

This works with 3.12.3, but crashes with 3.12.4. The issue might have been introduced with this fix:23ba96e

Code example

Fileautospec_test.py:

importunittestfromunittest.mockimportcreate_autospecclassX: ...classTestX(unittest.TestCase):deftest_x(self):mock=create_autospec(X,spec_set=True,name="X")if__name__=="__main__":unittest.main()

Observed behavior

python 3.12.3

python autospec_test.py.----------------------------------------------------------------------Ran 1 test in 0.001sOK

python 3.12.4

python autospec_test.pyE======================================================================ERROR:test_x (__main__.TestX.test_x)----------------------------------------------------------------------Traceback (most recent call last):  File".../autospec_test.py", line10, intest_x    mock= create_autospec(X,spec_set=True,name="X")^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/usr/local/lib/python3.12/unittest/mock.py", line2823, increate_autospec    mock.configure_mock(**kwargs)  File"/usr/local/lib/python3.12/unittest/mock.py", line650, inconfigure_mocksetattr(obj, final, val)  File"/usr/local/lib/python3.12/unittest/mock.py", line774, in__setattr__raiseAttributeError("Mock object has no attribute '%s'"% name)AttributeError:Mock object has no attribute 'name'----------------------------------------------------------------------Ran 1 test in 0.003sFAILED (errors=1)

CPython versions tested on:

3.12

Operating systems tested on:

Linux, (CI pipelines failed on windows, too – didn't test this example, though.)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp