test-folder-imported (ODE8130)
Preview (since 0.16.2.2) · Related issues · View source
Derived from the odoo linter.
Fix is sometimes available.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for imports of the tests folder in a module's __init__.py.
Why is this bad?
Odoo discovers and loads tests on its own when running with --test-enable; importing
the tests package from __init__.py loads test code (and its extra dependencies) in
production too.
Example
Use instead:
Fix safety
The fix removes the import — just the tests name when the statement imports other
names too, the whole statement otherwise. It is marked as unsafe because a name the
import bound may still be referenced elsewhere in the file, and because dropping the
import also drops any side effects of loading the tests package.