Skip to content

[ADD] core: checker for methods being set on models during tests#247151

Closed
xmo-odoo wants to merge 1 commit into
odoo:18.0from
odoo-dev:18.0-model-mutations-xmo
Closed

[ADD] core: checker for methods being set on models during tests#247151
xmo-odoo wants to merge 1 commit into
odoo:18.0from
odoo-dev:18.0-model-mutations-xmo

Conversation

@xmo-odoo

@xmo-odoo xmo-odoo commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator

Setting methods on models during tests and not removing them afterwards can cause misbehaviour of other tests. Setting mock or test-specific methods is not an issue but it should be done via patchers.

https://runbot.odoo.com/odoo/error/237983

@robodoo

robodoo commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@xmo-odoo xmo-odoo force-pushed the 18.0-model-mutations-xmo branch 28 times, most recently from 2bb1462 to 377e7d3 Compare February 10, 2026 13:09
@xmo-odoo xmo-odoo force-pushed the 18.0-model-mutations-xmo branch from 377e7d3 to cb39f35 Compare February 11, 2026 10:55
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
See odoo/odoo#247151

* Register with the patch checker to prevent exhaustive logging

```
odoo odoo.tests.common: /__w/server-tools/server-tools/auditlog/models/rule.py:232:_patch_method setting res.groups.unlink to <function AuditlogRule._make_unlink.<locals>.unlink_full at 0x7fa51ea90f70>
```

* Align model patching with how it's done in base_automation to fully remove
  patched methods. Fixes OCA#3439
* Dismantle own patch checker.
* Ensure no patching takes place in setUpClass.
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
See odoo/odoo#247151

Fixes
```
AssertionError: Found unexpected attributes on res.partner: _default_batch_size
```
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
See odoo/odoo#247151

Fixes
```
AssertionError: Found unexpected attributes on res.partner.category: jsonify_custom
```
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
Replace manual monkeypatching with unittest.mock.patch which is not signalled
by Odoo's patch checker.

See odoo/odoo#247151
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
See odoo/odoo#247151

Fixes
```
AssertionError: Found unexpected attributes on res.partner: _default_batch_size
```
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
See odoo/odoo#247151

Fixes
```
AssertionError: Found unexpected attributes on res.partner.category: jsonify_custom
```
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
See odoo/odoo#247151

Fixes
```
AssertionError: Found unexpected attributes on res.partner: _default_batch_size
```
StefanRijnhart added a commit to StefanRijnhart/server-tools that referenced this pull request Feb 19, 2026
Comment thread odoo/tests/common.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants