Help Test new Module

Python version: 3.8.10
Version module: 6.0.0

I’ve created my first module in venv via cookiecutter (video youtube “Deploying Tryton with Docker by Cédric Krier”).

command: python setup.py develop OK
command: DB_NAME=":memory:" python setup.py test ERROR:

Test validity of all views of the module … FAIL

FAIL: test_view (tests.test_simpool.SimpoolTestCase)
Test validity of all views of the module

Traceback (most recent call last):
File “/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/tests/test_tryton.py”, line 204, in wrapper
result = func(*args, **kwargs)
File “/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/tests/test_tryton.py”, line 278, in test_view
self.assertTrue(view.arch,
AssertionError: None is not true : missing architecture for view “party_form” of model “party.party”

party.xml:

<?xml version="1.0"?>
<tryton>
    <data>
        <record model="ir.ui.view" id="party_view_form">
            <field name="model">party.party</field>
            <field name="inherit" ref="party.party_view_form"/>
            <field name="name">party_form</field>
        </record>
    </data>
</tryton>

view/party_form.xml:

<?xml version="1.0"?>
<data>
    <xpath expr="/form/notebook" position="inside">
        <label name="simpoolfield"/>
        <field name="simpoolfield"/>
    </xpath>
</data>

Where am i wrong?

Some stuffs to check:

  • Have you declare the dependency to party module in tryton.cfg?
  • Is your module name is coherent in the setup.py: package name, entrypoint etc.?

Hi ced,

tryton.cfg it’s ok:

[tryton]
version=6.0.0
depends:
    ir
    party
xml:
    party_custom/party.xml

I entered these values in the cookiecutter wizard:

cookiecutter hg+https://hg.tryton.org/cookiecutter

module_name [my_module]: simpool
prefix []: simpool
package_name [simpool_simpool]:
version []: 6.0.0

module_name and prefix are the same. Could this be the mistake?

in setup.py:

...
name = 'simpool_simpool'
...
    package_dir={'trytond.modules.simpool': '.'},
    packages=(
        ['trytond.modules.simpool']
        + ['trytond.modules.simpool.%s' % p
            for p in find_packages()]
        ),
    package_data={
        'trytond.modules.simpool': (info.get('xml', [])
            + ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
                'icons/*.svg', 'tests/*.rst']),
        },
...
    entry_points="""
    [trytond.modules]
    simpool = trytond.modules.simpool
    """,  # noqa: E501

The setuptools seems to break import mechanism since Python 3.9 (see Python 3.9 breaks module import (#10513) · Issues · Tryton / Tryton · GitLab). Maybe you should try to use pip install -e . instead.

I tried your suggestion but the problem is not solved …
The test result is:

$ DB_NAME=":memory:" python setup.py test
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
running egg_info
writing simpool_simpool.egg-info/PKG-INFO
writing dependency_links to simpool_simpool.egg-info/dependency_links.txt
writing entry points to simpool_simpool.egg-info/entry_points.txt
writing requirements to simpool_simpool.egg-info/requires.txt
writing top-level names to simpool_simpool.egg-info/top_level.txt
reading manifest file 'simpool_simpool.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'CHANGELOG'
writing manifest file 'simpool_simpool.egg-info/SOURCES.txt'
running build_ext
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:333: UserWarning: Unable to remove not null with SQLite backend
warnings.warn('Unable to remove not null with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:269: UserWarning: Unable to drop foreign key with SQLite backend
warnings.warn('Unable to drop foreign key with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:338: UserWarning: Unable to add constraint with SQLite backend
warnings.warn('Unable to add constraint with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:196: UserWarning: Unable to set default on column with SQLite backend
warnings.warn('Unable to set default on column with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:331: UserWarning: Unable to set not null with SQLite backend
warnings.warn('Unable to set not null with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:266: UserWarning: Unable to add foreign key with SQLite backend
warnings.warn('Unable to add foreign key with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:341: UserWarning: Unable to drop constraint with SQLite backend
warnings.warn('Unable to drop constraint with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:301: UserWarning: Unable to create index with parameters
warnings.warn('Unable to create index with parameters')
test_buttons_registered (tests.test_simpool.SimpoolTestCase)
Test all buttons are registered in ir.model.button ... ok
test_buttons_states (tests.test_simpool.SimpoolTestCase)
Test the states of buttons ... ok
test_depends (tests.test_simpool.SimpoolTestCase)
Test depends ... ok
test_field_methods (tests.test_simpool.SimpoolTestCase)
Test field methods ... ok
test_field_relation_target (tests.test_simpool.SimpoolTestCase)
Test field relation and target ... ok
test_function_fields (tests.test_simpool.SimpoolTestCase)
Test function fields methods ... ok
test_icon (tests.test_simpool.SimpoolTestCase)
Test icons of the module ... ok
test_ir_action_window (tests.test_simpool.SimpoolTestCase)
Test action windows are correctly defined ... ok
test_menu_action (tests.test_simpool.SimpoolTestCase)
Test that menu actions are accessible to menu's group ... ok
test_missing_depends (tests.test_simpool.SimpoolTestCase)
Test for missing depends ... ok
test_model__access__ (tests.test_simpool.SimpoolTestCase)
Test existing model __access__ ... ok
test_model_access (tests.test_simpool.SimpoolTestCase)
Test missing default model access ... ok
test_modelsingleton_inherit_order (tests.test_simpool.SimpoolTestCase)
Test ModelSingleton, ModelSQL, ModelStorage order in the MRO ... ok
test_rec_name (tests.test_simpool.SimpoolTestCase) ... ok
test_rpc_callable (tests.test_simpool.SimpoolTestCase)
Test that RPC methods are callable ... ok
test_selection_fields (tests.test_simpool.SimpoolTestCase)
Test selection values ... ok
test_view (tests.test_simpool.SimpoolTestCase)
**Test validity of all views of the module ... FAIL**
test_wizards (tests.test_simpool.SimpoolTestCase)
Test wizards are correctly defined ... ok
test_workflow_transitions (tests.test_simpool.SimpoolTestCase)
Test all workflow transitions exist ... ok
test_xml_files (tests.test_simpool.SimpoolTestCase)
Test validity of the xml files of the module ... ok

FAIL: test_view (tests.test_simpool.SimpoolTestCase)

Test validity of all views of the module

Traceback (most recent call last):
File "/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/tests/test_tryton.py", line 204, in wrapper
result = func(*args, **kwargs)
File "/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/tests/test_tryton.py", line 278, in test_view
self.assertTrue(view.arch,
AssertionError: None is not true : missing architecture for view "party_form" of model "party.party"

Ran 20 tests in 4.663s

FAILED (failures=1)

Test failed: <unittest.runner.TextTestResult run=20 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=20 errors=0 failures=1>

I read your reply to another post:

I’ll try this too.

Where, relative to the top level directory of your module, is your view directory?

“view” directory is in party_custom directory:

  • My Module [folder]
    • party_custom [folder]
      • party.py
      • party.xml
      • view [folder]
        • party_form.xml

I tried to start the test with

python -m trytond.tests.run-tests -m <module>

Result:

/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:333: UserWarning: Unable to remove not null with SQLite backend
  warnings.warn('Unable to remove not null with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:269: UserWarning: Unable to drop foreign key with SQLite backend
  warnings.warn('Unable to drop foreign key with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:338: UserWarning: Unable to add constraint with SQLite backend
  warnings.warn('Unable to add constraint with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:196: UserWarning: Unable to set default on column with SQLite backend
  warnings.warn('Unable to set default on column with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:331: UserWarning: Unable to set not null with SQLite backend
  warnings.warn('Unable to set not null with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:266: UserWarning: Unable to add foreign key with SQLite backend
  warnings.warn('Unable to add foreign key with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:341: UserWarning: Unable to drop constraint with SQLite backend
  warnings.warn('Unable to drop constraint with SQLite backend')
/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/backend/sqlite/table.py:301: UserWarning: Unable to create index with parameters
  warnings.warn('Unable to create index with parameters')

FAIL: test_view (trytond.modules.simpool.tests.test_simpool.SimpoolTestCase)
Test validity of all views of the module
e.py:301: UserWarning: Unable to create index with parameters
  warnings.warn('Unable to create index with parameters')

FAIL: test_view (trytond.modules.simpool.tests.test_simpool.SimpoolTestCase)
Test validity of all views of the module

Traceback (most recent call last):
  File "/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/tests/test_t
Traceback (most recent call last):
  File "/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/tests/test_tryton.py", line 204, in wrapper
    result = func(*args, **kwargs)
  File "/home/trytond/venvs/.venv/lib/python3.8/site-packages/trytond-6.0.10-py3.8.egg/trytond/tests/test_tryton.py", line 278, in test_view
    self.assertTrue(view.arch,
AssertionError: None is not true : missing architecture for view "party_form" of model "party.party"

Ran 20 tests in 4.562s

FAILED (failures=1)

This can not work. The view must be in the view folder inside the top-level module directory.

Sorry, I didn’t notice the mistake. I was convinced that the “party_custom” directory contained the “view” directory.

With the fix it works …

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.