pytest-odoo icon indicating copy to clipboard operation
pytest-odoo copied to clipboard

AttributeError with python 3.8.6 - Wrong import way?

Open samsagaz opened this issue 4 years ago • 4 comments

When run pytest with odoo12 and python 3.8.6 i get the following error:

@pytest.fixture(scope='session', autouse=True)
def load_registry():
    # Initialize the registry before running tests.
    # If we don't do that, the modules will be loaded *inside* of the first
    # test we run, which would trigger the launch of the postinstall tests
    # (because we force 'test_enable' to True and the at end of the loading of
    # the registry, the postinstall tests are run when test_enable is enabled).
    # And also give wrong timing indications.
    # Finally we enable `testing` flag on current thread
    # since Odoo sets it when loading test suites.
    threading.currentThread().testing = True
  odoo.registry(odoo.tests.common.get_db_name())

E AttributeError: module 'odoo' has no attribute 'tests'

env/lib/python3.8/site-packages/pytest_odoo.py:88: AttributeError

samsagaz avatar Dec 03 '20 21:12 samsagaz

Simple fix is to use import odoo.tests instead import odoo

samsagaz avatar Dec 03 '20 21:12 samsagaz

noone have the same error? :/

Is not possible to find module common without explicit import odoo.test as odoo and test are two packages

samsagaz avatar Dec 11 '20 17:12 samsagaz

@samsagaz doesn't ring a bell, but we usually stick to the supported python version of Odoo. For Odoo 12.0 we use Python 3.5 https://github.com/camptocamp/docker-odoo-project/blob/master/12.0/Dockerfile#L19

Nevertheless we use Python 3.7 for Odoo 14.0 https://github.com/camptocamp/docker-odoo-project/blob/master/14.0/Dockerfile#L19

I'll try to find some time this week to have a look at your PR.

yvaucher avatar Mar 23 '21 16:03 yvaucher

@samsagaz doesn't ring a bell, but we usually stick to the supported python version of Odoo. For Odoo 12.0 we use Python 3.5 https://github.com/camptocamp/docker-odoo-project/blob/master/12.0/Dockerfile#L19

Nevertheless we use Python 3.7 for Odoo 14.0 https://github.com/camptocamp/docker-odoo-project/blob/master/14.0/Dockerfile#L19

I'll try to find some time this week to have a look at your PR.

Ok, no problem!

samsagaz avatar Mar 25 '21 12:03 samsagaz