[Solved] Testsetup ends with error: TypeError: Module xyz does not define any tests

I created an empty addon called setup.test, only for play and learn with mrbob bobtemplates.plone:addon
i customized some imports in testing.py, e.g. i replace z2 with zope, because its a Plone 5.2.2 Installation on Py3
I upgraded my buildout to the last package version of plone.testing = 8.0.2 and plone.app.testing = 6.1.7
I run a first test:

> bin/test --all
Test-module import failures:
Module: setup.tests.testing
TypeError: Module setup.tests.testing does not define any tests

Now i'm a little bit clueless, whats going wrong, perhaps ist the bobtemplate to old?

Thats my setup:

# testing.py

from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import PloneSandboxLayer
from plone.testing import zope

class SetupTestsLayer(PloneSandboxLayer):

    defaultBases = (PLONE_FIXTURE,)

    def setUpZope(self, app, configurationContext):
        import plone.restapi
        self.loadZCML(package=plone.restapi)
        self.loadZCML(package=setup.tests)

    def setUpPloneSite(self, portal):
        applyProfile(portal, 'setup.tests:default')

SETUP_TESTS_FIXTURE = SetupTestsLayer()

SETUP_TESTS_INTEGRATION_TESTING = IntegrationTesting(
    bases=(SETUP_TESTS_FIXTURE,),
    name='SetupTestsLayer:IntegrationTesting',
)

SETUP_TESTS_FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(SETUP_TESTS_FIXTURE,),
    name='SetupTestsLayer:FunctionalTesting',
)

SETUP_TESTS_ACCEPTANCE_TESTING = FunctionalTesting(
    bases=(
        SETUP_TESTS_FIXTURE,
        REMOTE_LIBRARY_BUNDLE_FIXTURE,
        zope.WSGI_SERVER_FIXTURE
    ),
    name='SetupTestsLayer:AcceptanceTesting',
)
# tests/test_setup.py

from plone.testing.zope import Browser
from setup.tests.testing import SETUP_TESTS_FUNCTIONAL_TESTING  # noqa: E501

import unittest

class SetupFunctionalTest(unittest.TestCase):
    """ basic use cases """

    layer = SETUP_TESTS_FUNCTIONAL_TESTING

    def setUp(self):
        # Set up browser
        app = self.layer['app']
        self.portal = self.layer['portal']
        self.portal_url = self.portal.absolute_url()
        self.browser = Browser(app)
        self.browser.handleErrors = False        

    def test_plone(self):
        self.browser.open(self.portal_url)
        self.assertTrue('plone' in self.browser.contents)

zope.testrunner expects to find your tests inside your package directory, in a subpackage or module named tests.

From https://pypi.org/project/zope.testrunner/

Could it be that because your package is called setup.tests, the .tests part makes the testrunner think that everything inside are tests?

Yes this was the solution. Thanks. I test it with a "myaddon.check" namespace and all was fine.

Plone Foundation Code of Conduct