)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":13177,"name":"Emma Foley","email":"efoley@redhat.com","username":"emma-l-foley"},"change_message_id":"3f23c68d431b410db429b4318dc92c3b42092c51","unresolved":true,"context_lines":[{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"5a4de111_e599ea82","line":15,"range":{"start_line":13,"start_character":1,"end_line":15,"end_character":29},"updated":"2026-06-29 11:30:24.000000000","message":"mock.Mock and mock.,MagicMock already support the autospec parameter. hacking requires these to be set, and we run hacking checks.\n\nIf the intent is to enforce this across openstack, then changing oslotest makes more sense, rather than proliferating changes across dozens of projects.","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"966fff5c69b758c94086cfc3581d2794a008a4d8","unresolved":true,"context_lines":[{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"d407bcde_42ec18e6","line":15,"range":{"start_line":13,"start_character":1,"end_line":15,"end_character":29},"in_reply_to":"0912dd01_2ac031c8","updated":"2026-07-08 11:56:25.000000000","message":"that now how this works in unittest\n\nits the patch method that supprot autospec\n\nhttps://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch\n\nmock asspcate a `spec` argument https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock\n\n```\nspec: This can be either a list of strings or an existing object (a class or instance) that acts as the specification for the mock object. If you pass in an object then a list of strings is formed by calling dir on the object (excluding unsupported magic attributes and methods). Accessing any attribute not in this list will raise an AttributeError.\n\nIf spec is an object (rather than a list of strings) then __class__ returns the class of the spec object. This allows mocks to pass isinstance() tests.\n```\nthere is also a `create_autospec` helper method\nhttps://docs.python.org/3/library/unittest.mock.html#unittest.mock.create_autospec\n\nthis is docuemnted in \nhttps://docs.python.org/3/library/unittest.mock.html#auto-speccing\n\nthe normal way to \"autospec\" when usign moc directly is\n\nmock \u003d Mock(spec\u003drequest.Request)\n\nso your example\n\n```\nmocked_foo \u003d mock.Mock(autospec\u003dFoo)\n```\nshoudl be \n```\nmocked_foo \u003d mock.Mock(spec\u003dFoo)\n```","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":8213,"name":"Claudiu Belu","email":"cbelu@cloudbasesolutions.com","username":"claudiub"},"change_message_id":"7618ffc4dbf35d34cf88321ae297cc2fcd72b7be","unresolved":true,"context_lines":[{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"0912dd01_2ac031c8","line":15,"range":{"start_line":13,"start_character":1,"end_line":15,"end_character":29},"in_reply_to":"5a4de111_e599ea82","updated":"2026-07-07 23:22:36.000000000","message":"Hi Emma,\n\n``mock.Mock and mock.,MagicMock already support the autospec parameter. hacking requires these to be set, and we run hacking checks.`` - That\u0027s interesring. to my knowledge, that parameter does not exist:\n\n```\ndocker run --rm -ti --entrypoint bash python:3.14\nroot@fafd74c411e9:/# pip install oslotest\nCollecting oslotest\n  Downloading oslotest-6.1.1-py3-none-any.whl.metadata (1.8 kB)\nCollecting fixtures\u003e\u003d3.0.0 (from oslotest)\n  Downloading fixtures-4.3.2-py3-none-any.whl.metadata (22 kB)\nCollecting testtools\u003e\u003d2.2.0 (from oslotest)\n  Downloading testtools-2.9.1-py3-none-any.whl.metadata (5.4 kB)\nDownloading oslotest-6.1.1-py3-none-any.whl (30 kB)\nDownloading fixtures-4.3.2-py3-none-any.whl (41 kB)\nDownloading testtools-2.9.1-py3-none-any.whl (110 kB)\nInstalling collected packages: testtools, fixtures, oslotest\nSuccessfully installed fixtures-4.3.2 oslotest-6.1.1 testtools-2.9.1\nWARNING: Running pip as the \u0027root\u0027 user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.\n\nroot@fafd74c411e9:/# python3\nPython 3.14.6 (main, Jun 24 2026, 04:50:39) [GCC 14.2.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e class Foo:\n...     def lish(bar, tender):\n...         pass\n...\n\u003e\u003e\u003e from unittest import mock\n\u003e\u003e\u003e mocked_foo \u003d mock.Mock(autospec\u003dFoo)\n\u003e\u003e\u003e # the next call should fail, because the signature is not respected. But it doesn\u0027t.\n\u003e\u003e\u003e mocked_foo.lish()\n\u003cMock name\u003d\u0027mock.lish()\u0027 id\u003d\u0027129798341741600\u0027\u003e\n\nroot@fafd74c411e9:/# python3\nPython 3.14.6 (main, Jun 24 2026, 04:50:39) [GCC 14.2.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e class Foo:\n...     def lish(bar, tender):\n...         pass\n...\n\u003e\u003e\u003e from oslotest import mock_fixture\n\u003e\u003e\u003e mock_fixture.MockAutospecFixture().setUp()\n\u003e\u003e\u003e from unittest import mock\n... mocked_foo \u003d mock.Mock(autospec\u003dFoo)\n...\n\u003e\u003e\u003e # the next call should fail, because the signature is not respected.\n\u003e\u003e\u003e mocked_foo.lish()\nTraceback (most recent call last):\n  File \"\u003cpython-input-5\u003e\", line 1, in \u003cmodule\u003e\n    mocked_foo.lish()\n    ~~~~~~~~~~~~~~~^^\n  File \"/usr/local/lib/python3.14/unittest/mock.py\", line 1174, in __call__\n    self._mock_check_sig(*args, **kwargs)\n    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.14/site-packages/oslotest/mock_fixture.py\", line 41, in _autospeced\n    _lazy_autospec(*args, **kwargs)\n    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^\n  File \"\u003cstring\u003e\", line 2, in lish\n  File \"/usr/local/lib/python3.14/unittest/mock.py\", line 196, in checksig\n    sig.bind(*args, **kwargs)\n    ~~~~~~~~^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.14/inspect.py\", line 3236, in bind\n    return self._bind(args, kwargs)\n           ~~~~~~~~~~^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.14/inspect.py\", line 3149, in _bind\n    raise TypeError(msg) from None\nTypeError: missing a required argument: \u0027tender\u0027\n```\n\nAm I missing something? As far as I can tell, you have a hacking rule enforcing a parameter that does not exist.\n\nThe fixture is in oslotest, but it is opt in, mostly due to the fact that most OpenStack projects would have failing tests otherwise (most common issues: things getting mocked twice, some things that cannot be autospec\u0027d, `self` argument not being consumed when checking method signatures). As you can see even in this project, these things would have to be addressed first.","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":8213,"name":"Claudiu Belu","email":"cbelu@cloudbasesolutions.com","username":"claudiub"},"change_message_id":"33bc3b1d91f2672b938eeae599a7516e07681679","unresolved":true,"context_lines":[{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"b737ad55_67ca102d","line":15,"range":{"start_line":13,"start_character":1,"end_line":15,"end_character":29},"in_reply_to":"d407bcde_42ec18e6","updated":"2026-07-08 14:23:21.000000000","message":"Indeed, by default `mock.patch` (+ `.object`, + `.dict`) has the `autospec` argument, which is `None` by default. `oslotest.mock_fixture.patch_mock_module()` sets it to `True` unless set otherwise, or an incompatible argument is given (`create`, `new_callable`).\n\nUpstream `mock.Mock` / `magic.MagicMock` doesn\u0027t have the `autospec` argument, that is true, but `oslotest.mock_fixture.MockAutospecFixture().setUp()` effectively adds it. There is a significant difference between `spec` and `autospec`: `spec` essentially only checks for an attribute\u0027s existence (raises `AttributeError` if it doesn\u0027t exist), while `autospec` also ensures that when you call a mock\u0027s autospec\u0027d attribute, it really is a callable attribute, and it also ensures that it is called with the proper signature, that you don\u0027t give it bogus arguments. Autospec is stronger than spec, and it is a more rigurous enforcement.\n\nIndeed, `mock.create_autospec` is the vanilla way to create autospec\u0027d objects. However, it is very slow. That is because it recursively creates autospec mocks for *all* the properties on creation, no matter if you *need* all of them, or only one during a test. Meanwhile, if you use `mock.Mock(autospec\u003dthing)`, it\u0027s significantly faster. That is because in oslotest we do lazy autospec-ing, creating it only on `getattr`, instead of creating autospecs for every attribute recursively. You can run the following scripts yourself to see the difference: https://paste.openstack.org/show/834403/ and https://paste.openstack.org/show/834405/. Here are my results:\n\n```\npython3 ./benchmarks/bench_flat.py\nN\u003d1000 iterations\ncreate_autospec(BigClass):      15.593 ms/call\nlazy + access  1/10 methods:    2.155 ms/call  (7.2x faster)\nlazy + access  3/10 methods:    4.267 ms/call  (3.7x faster)\nlazy + access  5/10 methods:    5.090 ms/call  (3.1x faster)\nlazy + access 10/10 methods:    9.679 ms/call (1.6x faster)\n\npython3 ./benchmarks/bench_inheritance.py\nN\u003d1000 iterations\nClass        depth         own inherited | create_autospec lazy (1 method)  speedup\n-----------------------------------------------------------------------------------\nFlat             1          10         0 |         14.034ms          1.714ms     8.2x\nDeep2            2           5         5 |         13.323ms          2.393ms     5.6x\nDeep4            4           1         9 |         16.904ms          1.942ms     8.7x\nWide+Deep        4           5        15 |         27.996ms          2.130ms    13.1x\n```\n\nNote that `mocked_foo \u003d mock.Mock(spec\u003dFoo)` only uses `spec`, not `autospec`. You could call `mocked_foo.uncallable_property(random, argument)` and it would not raise `TypeError`. With autospec, it would raise it.","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"ad166eca68a5b4ebe140ae13a6d2177f82165308","unresolved":true,"context_lines":[{"line_number":4,"context_line":"Commit:     Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2026-06-22 09:44:28 +0000"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"tests: Enforce autospec\u003dTrue on mock patches"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Using mock_fixture.patch_mock_module() will enforce autospec\u003dTrue on all"},{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"905b7582_83a344e5","line":16,"range":{"start_line":7,"start_character":0,"end_line":16,"end_character":1},"updated":"2026-06-29 11:26:12.000000000","message":"Claudiu we shoudl not prot this to other project and we shoudl actully consier removing this helper that only nova uses from oslo.test\n\nthis does nto actully work propely if you have nested context manager such as when the transartion and retry ones we use for databases.\n\ni spent a while evaulating this for cybrog a few weeks ago \n\nusing auto spec is a good thing but the fixture that oslo test has is problemanti and not something we shoudl cargo cult to other repos.\n\nthe main issue that i hit is technically less relevent now as it cause a python 3.9/3.10 behavior change\n\nso now that we have 3.11 as a min we shoudl not hit it but it is better to acully use autospec then change the semantics fo a standard lib libviary without a visiable change in the code","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":8213,"name":"Claudiu Belu","email":"cbelu@cloudbasesolutions.com","username":"claudiub"},"change_message_id":"33bc3b1d91f2672b938eeae599a7516e07681679","unresolved":true,"context_lines":[{"line_number":4,"context_line":"Commit:     Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2026-06-22 09:44:28 +0000"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"tests: Enforce autospec\u003dTrue on mock patches"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Using mock_fixture.patch_mock_module() will enforce autospec\u003dTrue on all"},{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"c30a0cb5_c8fd06e7","line":16,"range":{"start_line":7,"start_character":0,"end_line":16,"end_character":1},"in_reply_to":"5297ecea_0185e05a","updated":"2026-07-08 14:23:21.000000000","message":"It was used in nova because at that time, I only had enough time to do it for nova and our own projects that we had then: os-win, networking-hyperv, compute-hyperv, which have since then been removed. I can reference a WIP cinder PR for this from years ago if needed.\n.\nIn regards to the invasiveness: right. If that is the concern, we can limit the change to just having the `oslotest.mock_fixture.patch_mock_module()` call (which enforces `autospec\u003dTrue`); meaning that `oslotest.mock_fixture.MockAutospecFixture().setUp()` wouldn\u0027t be used (which would give us `mock.Mock(autospec\u003dthing)`). The tests should still pass afterwards, because it\u0027s simply just a downgrade in enforcement. The only significant difference would be the `self / cls` argument would have to be readded to `assert_called_with` calls for tests that had explicit `autospec\u003dTrue` arguments (there are few projects that do this).\n.\n`a better way to do this would be to have new oslotest utiltity function that wrapped mock.patch or something simiarl that makes it clear that we are not expectign the upstream patch bevhior.` - I\u0027m not sure I follow what you mean here; should we log a warning or something there?","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"966fff5c69b758c94086cfc3581d2794a008a4d8","unresolved":true,"context_lines":[{"line_number":4,"context_line":"Commit:     Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2026-06-22 09:44:28 +0000"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"tests: Enforce autospec\u003dTrue on mock patches"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Using mock_fixture.patch_mock_module() will enforce autospec\u003dTrue on all"},{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"5297ecea_0185e05a","line":16,"range":{"start_line":7,"start_character":0,"end_line":16,"end_character":1},"in_reply_to":"8ba6d22a_fe771e8a","updated":"2026-07-08 11:56:25.000000000","message":"the technial issue i rasied since its 3.9 specific is not really a issue for master since its 3.9 sepecific and has been fixed. the min python we supprot today is 3.11\n\nbut the large issue is we are chagnign teh behvior of the python standard libary mock in a non obvious way that will mean if you follow the upstream docs for how mock shoudl work you will not get the documented behvior.\n\nthat is problematic form my point of view espcially if we we dont have extensive doc for this\n\nthe olostest fixture is not used in any project expect nova and even then this is not something that is widely known in nova.\n\nso im more pushing back on the fact that this is an very invasive change following the same problematic approch that eventlet took of mokeypatching the behvior of the stadnard lib\n\na better way to do this would be to have new oslotest utiltity function that wrapped mock.patch or something simiarl that makes it clear that we are not expectign the upstream patch bevhior.","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":8213,"name":"Claudiu Belu","email":"cbelu@cloudbasesolutions.com","username":"claudiub"},"change_message_id":"7618ffc4dbf35d34cf88321ae297cc2fcd72b7be","unresolved":true,"context_lines":[{"line_number":4,"context_line":"Commit:     Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2026-06-22 09:44:28 +0000"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"tests: Enforce autospec\u003dTrue on mock patches"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Using mock_fixture.patch_mock_module() will enforce autospec\u003dTrue on all"},{"line_number":10,"context_line":"the mock.patch and similar calls. This will enforce signature checks on"},{"line_number":11,"context_line":"the mocked methods and functions, catching potential bugs missed by"},{"line_number":12,"context_line":"otherwise false positive unit tests."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Additionally, mock_fixture adds the ability to add autospecs to"},{"line_number":15,"context_line":"mock.Mock and mock.MagicMock."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: I1f7ba6d370446f6c0887d200e36ca0746ab1ed2d"},{"line_number":18,"context_line":"Signed-off-by: Claudiu Belu \u003ccbelu@cloudbasesolutions.com\u003e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"8ba6d22a_fe771e8a","line":16,"range":{"start_line":7,"start_character":0,"end_line":16,"end_character":1},"in_reply_to":"905b7582_83a344e5","updated":"2026-07-07 23:22:36.000000000","message":"Hi Sean,\n\nAs mentioned in https://review.opendev.org/c/openstack/placement/+/994194, the issue you\u0027re mentioning existed in the upstream inspect library (used by mock when autospec is being used), issue which was solved up to Python 3.10 (and not Python 3.9); the fixture did not cause the issue (I didn\u0027t see it being used in cyborg in the first place). The oslotest fixture basically enforces autospec\u003dTrue on patches (if not explicitly set otherwise), and fixes a few rough edges (bug fixes which were not merged in the upstream mock library). If needed, we could have it account for those Python version differences you mention, if there are any relevant differences left now.\n\n``so now that we have 3.11 as a min we shoudl not hit it but it is better to acully use autospec then change the semantics fo a standard lib libviary without a visiable change in the code`` - Indeed, which is why that bugfix for \"self not being consumed when autospec\u003dTrue\" was sent upstream in the first place (and included in the oslotest mock fixture), to reduce the amount of changes required in adopting autospecs. However, there could still be erroneous tests that would need fixing nonetheless. For example, the most typical issues currently found in this list of PRs is patching existing mocks (let\u0027s say self.thing \u003d mock.Mock(), you don\u0027t need to mock.patch.object(self.thing, \"foo\") it), and double patching the same thing. In those cases, the upstream mock library raises InvalidSpecError in those cases, as they\u0027re not considered good practices (can\u0027t autospec in those cases anyways, and silently passing would be worse than failing, as it may hide potential issues). So, in the majority of the cases, test code changes are still needed.","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"}],"ceilometer/tests/base.py":[{"author":{"_account_id":13177,"name":"Emma Foley","email":"efoley@redhat.com","username":"emma-l-foley"},"change_message_id":"3f23c68d431b410db429b4318dc92c3b42092c51","unresolved":true,"context_lines":[{"line_number":43,"context_line":"class BaseTestCase(base.BaseTestCase):"},{"line_number":44,"context_line":"    def setUp(self):"},{"line_number":45,"context_line":"        super().setUp()"},{"line_number":46,"context_line":"        self.useFixture(mock_fixture.MockAutospecFixture())"},{"line_number":47,"context_line":"        if os.environ.get(\u0027OS_LOG_CAPTURE\u0027) in (\u0027True\u0027, \u0027true\u0027, \u00271\u0027, \u0027yes\u0027):"},{"line_number":48,"context_line":"            self.stdlog \u003d self.useFixture(ceilo_fixtures.StandardLogging())"},{"line_number":49,"context_line":"        self.addCleanup(CONF.reset)"}],"source_content_type":"text/x-python","patch_set":2,"id":"8ce9568b_e4d5f23a","line":46,"range":{"start_line":46,"start_character":8,"end_line":46,"end_character":59},"updated":"2026-06-29 11:30:24.000000000","message":"I don\u0027t understand why this is here, but there\u0027s also something added into tests/__init__.\n\nAre both needed, what do they do?\nIn one case we have this fixture used in all the testcases, but in the other, importing the module has a side effect of patching mock. Do we now have double patches? this causes its own issues.","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"},{"author":{"_account_id":8213,"name":"Claudiu Belu","email":"cbelu@cloudbasesolutions.com","username":"claudiub"},"change_message_id":"7618ffc4dbf35d34cf88321ae297cc2fcd72b7be","unresolved":true,"context_lines":[{"line_number":43,"context_line":"class BaseTestCase(base.BaseTestCase):"},{"line_number":44,"context_line":"    def setUp(self):"},{"line_number":45,"context_line":"        super().setUp()"},{"line_number":46,"context_line":"        self.useFixture(mock_fixture.MockAutospecFixture())"},{"line_number":47,"context_line":"        if os.environ.get(\u0027OS_LOG_CAPTURE\u0027) in (\u0027True\u0027, \u0027true\u0027, \u00271\u0027, \u0027yes\u0027):"},{"line_number":48,"context_line":"            self.stdlog \u003d self.useFixture(ceilo_fixtures.StandardLogging())"},{"line_number":49,"context_line":"        self.addCleanup(CONF.reset)"}],"source_content_type":"text/x-python","patch_set":2,"id":"86ec944c_8e0adeaf","line":46,"range":{"start_line":46,"start_character":8,"end_line":46,"end_character":59},"in_reply_to":"8ce9568b_e4d5f23a","updated":"2026-07-07 23:22:36.000000000","message":"Right. There are 2 different things being monkey patched. First of all, the change in __init__.py (`mock_fixture.patch_mock_module()`) - basically enforces `autospec\u003dTrue` on all mock.patch, mock.patch.object, mock.patch.dict calls. This *needs* to be done as early as possible (hence it is in __init__.py), otherwise the patcher doesn\u0027t work as intended (tests with `@mock.patch` / `@mock.patch.object` are \"initialized\" with `autospec\u003dNone`).\n\nMeanwhile, this fixture adds the `autospec\u003d` argument to `mock.Mock` and `mock.MagicMock`. It *could* be included in the `mock_fixture.patch_mock_module()` call, but the intent was to make them separate; you could use `mock_fixture.patch_mock_module()` without this.","commit_id":"4d28dec524d3704bb954dcbbef6c90c3e6c0c48f"}]}
