Skip to content

Conversation

@erral
Copy link
Member

@erral erral commented Dec 1, 2025

In plone/bobtemplates.plone#599 I have reworked the tests that bobtemplates.plone subtemplate creates changing the layer names to mimic the ones that cookieplone creates.

Doing that, we can run those tests with pytest, but to do so we need to call pytest passing the tests folder as a parameter.

I have tried calling pytest with both folders as parameters, but tests fail, if I run in separate statements they run correctly.

This is a first step of the process, a second step would be to generate those tests directly in pytest-style instead of unitest, and move them to the root tests folder.

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try adjusting the testpaths in pyproject.toml? What was the error when you ran all the tests together?

@erral
Copy link
Member Author

erral commented Dec 2, 2025

This is the error when running pytests with both folders as parameters:

erral@lindari:/tmp/collective.collectivecocotero(main)$ .venv/bin/pytest tests src/collective/collectivecocotero/tests/
🐎 This Python (/tmp/collective.collectivecocotero/.venv/bin/python3) uses horse-with-no-namespace to make the following pkg_resources namespace packages compatible with PEP 420 namespace packages:
  Products, Shared, Shared.DC, borg, collective, paste, plone, plone.app, plone.formwidget, plone.portlet, plonetheme, repoze, zc, zmi, zope, zope.app

============================================================================ test session starts ============================================================================
platform linux -- Python 3.10.16, pytest-8.4.0, pluggy-1.6.0
rootdir: /tmp/collective.collectivecocotero
configfile: pyproject.toml
plugins: zope.pytestlayer-8.3, plone-1.0.0a2, cov-6.2.1
collected 5 items / 1 error                                                                                                                                                 

================================================================================== ERRORS ===================================================================================
_______________________________________________ ERROR collecting src/collective/collectivecocotero/tests/test_ct_todo_task.py _______________________________________________
ImportError while importing test module '/tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/erral/.local/share/uv/python/cpython-3.10.16-linux-x86_64-gnu/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/collective/collectivecocotero/tests/test_ct_todo_task.py:3: in <module>
    from collective.collectivecocotero.testing import COLLECTIVE_COLLECTIVECOCOTERO_INTEGRATION_TESTING  # noqa
E   ImportError: cannot import name 'COLLECTIVE_COLLECTIVECOCOTERO_INTEGRATION_TESTING' from 'collective.collectivecocotero.testing' (/tmp/collective.collectivecocotero/src/collective/collectivecocotero/testing.py)
========================================================================== short test summary info ==========================================================================
ERROR src/collective/collectivecocotero/tests/test_ct_todo_task.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================= 1 error in 0.14s ==============================================================================
erral@lindari:/tmp/collective.collectivecocotero(main)$ code .
erral@lindari:/tmp/collective.collectivecocotero(main)$ .venv/bin/pytest tests src/collective/collectivecocotero/tests/
🐎 This Python (/tmp/collective.collectivecocotero/.venv/bin/python3) uses horse-with-no-namespace to make the following pkg_resources namespace packages compatible with PEP 420 namespace packages:
  Products, Shared, Shared.DC, borg, collective, paste, plone, plone.app, plone.formwidget, plone.portlet, plonetheme, repoze, zc, zmi, zope, zope.app

============================================================================ test session starts ============================================================================
platform linux -- Python 3.10.16, pytest-8.4.0, pluggy-1.6.0
rootdir: /tmp/collective.collectivecocotero
configfile: pyproject.toml
plugins: zope.pytestlayer-8.3, plone-1.0.0a2, cov-6.2.1
collected 11 items                                                                                                                                                          

tests/setup/test_setup_install.py ...                                                                                                                                 [ 27%]
tests/setup/test_setup_uninstall.py ..                                                                                                                                [ 45%]
src/collective/collectivecocotero/tests/test_ct_todo_task.py EEEEEE                                                                                                   [100%]

================================================================================== ERRORS ===================================================================================
____________________________________________________ ERROR at setup of TodoTaskIntegrationTest.test_ct_todo_task_adding _____________________________________________________
file /tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py, line 45
      def test_ct_todo_task_adding(self):
E       fixture 'integration' not found
>       available fixtures: _unittest_setUpClass_fixture_TodoTaskIntegrationTest, app, browser_layers, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, controlpanel_actions, cov, doctest_namespace, generate_mo, get_behaviors, get_fti, get_vocabulary, http_request, installer, monkeypatch, no_cover, portal, profile_last_version, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, setup_tool, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py:45
____________________________________________________ ERROR at setup of TodoTaskIntegrationTest.test_ct_todo_task_factory ____________________________________________________
file /tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py, line 33
      def test_ct_todo_task_factory(self):
E       fixture 'integration' not found
>       available fixtures: _unittest_setUpClass_fixture_TodoTaskIntegrationTest, app, browser_layers, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, controlpanel_actions, cov, doctest_namespace, generate_mo, get_behaviors, get_fti, get_vocabulary, http_request, installer, monkeypatch, no_cover, portal, profile_last_version, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, setup_tool, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py:33
___________________________________________ ERROR at setup of TodoTaskIntegrationTest.test_ct_todo_task_filter_content_type_false ___________________________________________
file /tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py, line 72
      def test_ct_todo_task_filter_content_type_false(self):
E       fixture 'integration' not found
>       available fixtures: _unittest_setUpClass_fixture_TodoTaskIntegrationTest, app, browser_layers, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, controlpanel_actions, cov, doctest_namespace, generate_mo, get_behaviors, get_fti, get_vocabulary, http_request, installer, monkeypatch, no_cover, portal, profile_last_version, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, setup_tool, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py:72
______________________________________________________ ERROR at setup of TodoTaskIntegrationTest.test_ct_todo_task_fti ______________________________________________________
file /tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py, line 29
      def test_ct_todo_task_fti(self):
E       fixture 'integration' not found
>       available fixtures: _unittest_setUpClass_fixture_TodoTaskIntegrationTest, app, browser_layers, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, controlpanel_actions, cov, doctest_namespace, generate_mo, get_behaviors, get_fti, get_vocabulary, http_request, installer, monkeypatch, no_cover, portal, profile_last_version, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, setup_tool, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py:29
_______________________________________________ ERROR at setup of TodoTaskIntegrationTest.test_ct_todo_task_globally_addable ________________________________________________
file /tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py, line 67
      def test_ct_todo_task_globally_addable(self):
E       fixture 'integration' not found
>       available fixtures: _unittest_setUpClass_fixture_TodoTaskIntegrationTest, app, browser_layers, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, controlpanel_actions, cov, doctest_namespace, generate_mo, get_behaviors, get_fti, get_vocabulary, http_request, installer, monkeypatch, no_cover, portal, profile_last_version, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, setup_tool, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py:67
____________________________________________________ ERROR at setup of TodoTaskIntegrationTest.test_ct_todo_task_schema _____________________________________________________
file /tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py, line 24
      def test_ct_todo_task_schema(self):
E       fixture 'integration' not found
>       available fixtures: _unittest_setUpClass_fixture_TodoTaskIntegrationTest, app, browser_layers, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, controlpanel_actions, cov, doctest_namespace, generate_mo, get_behaviors, get_fti, get_vocabulary, http_request, installer, monkeypatch, no_cover, portal, profile_last_version, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, setup_tool, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/collective.collectivecocotero/src/collective/collectivecocotero/tests/test_ct_todo_task.py:24
============================================================================= warnings summary ==============================================================================
tests/setup/test_setup_install.py::TestSetupInstall::test_addon_installed
  /tmp/collective.collectivecocotero/.venv/lib/python3.10/site-packages/plone/scale/storage.py:4: DeprecationWarning: PersistentDict is deprecated. `persistent.dict.PersistentDict` is deprecated. Use `persistent.mapping.PersistentMapping` instead. This backward compatibility shim will be removed in persistent version 7.
    from persistent.dict import PersistentDict

tests/setup/test_setup_install.py::TestSetupInstall::test_addon_installed
tests/setup/test_setup_uninstall.py::TestSetupUninstall::test_addon_uninstalled
  /tmp/collective.collectivecocotero/.venv/lib/python3.10/site-packages/Products/CMFPlone/factory.py:176: DeprecationWarning: addPloneSite ignores the setup_content keyword argument since Plone 6.1, treating it as always False. In Plone 7 it will be removed.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================== short test summary info ==========================================================================
ERROR src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_adding
ERROR src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_factory
ERROR src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_filter_content_type_false
ERROR src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_fti
ERROR src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_globally_addable
ERROR src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_schema
================================================================== 5 passed, 3 warnings, 6 errors in 4.49s ==================================================================

And this is the output if I run it directly only with the tests folder inside the package:

erral@lindari:/tmp/collective.collectivecocotero(main)$ .venv/bin/pytest src/collective/collectivecocotero/tests/
🐎 This Python (/tmp/collective.collectivecocotero/.venv/bin/python3) uses horse-with-no-namespace to make the following pkg_resources namespace packages compatible with PEP 420 namespace packages:
  Products, Shared, Shared.DC, borg, collective, paste, plone, plone.app, plone.formwidget, plone.portlet, plonetheme, repoze, zc, zmi, zope, zope.app

============================================================================ test session starts ============================================================================
platform linux -- Python 3.10.16, pytest-8.4.0, pluggy-1.6.0
rootdir: /tmp/collective.collectivecocotero
configfile: pyproject.toml
plugins: zope.pytestlayer-8.3, plone-1.0.0a2, cov-6.2.1
collected 6 items                                                                                                                                                           

src/collective/collectivecocotero/tests/test_ct_todo_task.py ......                                                                                                   [100%]

============================================================================= warnings summary ==============================================================================
src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_adding
  /tmp/collective.collectivecocotero/.venv/lib/python3.10/site-packages/plone/scale/storage.py:4: DeprecationWarning: PersistentDict is deprecated. `persistent.dict.PersistentDict` is deprecated. Use `persistent.mapping.PersistentMapping` instead. This backward compatibility shim will be removed in persistent version 7.
    from persistent.dict import PersistentDict

src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_adding
  /tmp/collective.collectivecocotero/.venv/lib/python3.10/site-packages/Products/CMFPlone/factory.py:176: DeprecationWarning: addPloneSite ignores the setup_content keyword argument since Plone 6.1, treating it as always False. In Plone 7 it will be removed.
    warnings.warn(

src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_filter_content_type_false
src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_filter_content_type_false
src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_filter_content_type_false
src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_filter_content_type_false
src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_filter_content_type_false
src/collective/collectivecocotero/tests/test_ct_todo_task.py::TodoTaskIntegrationTest::test_ct_todo_task_filter_content_type_false
  /tmp/collective.collectivecocotero/.venv/lib/python3.10/site-packages/Products/PageTemplates/Expressions.py:155: DeprecationWarning: Use method is_structural_folder from @@plone_context_state instead. Will be removed in Plone 7
    ob = ob()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================= 6 passed, 8 warnings in 3.01s =======================================================================

If I adjust the testpath in pyproject.toml like this, I get the same error as if I run the tests passing both folders as parameters.

This is how the pyproject.toml would look like:

 [tool.pytest.ini_options]
-testpaths = ["tests"]
+testpaths = ["tests", "src/collective/collectivecocotero/tests/"]

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.

3 participants