Testing an addon in a pip instance

My steps to create an addon with installation of Plone 6.

mkdir testfolder
cd testfolder
python -m venv ./venv
source venv/bin/activate
touch requirements.txt
touch constraints.txt
touch instance.yaml

edit the requirements.txt

vim requirements.txt
-c constraints.txt
wheel
# mr.bob checkout only needed if python 3.10
git+https://github.com/collective/mr.bob.git@master
plonecli
cookiecutter
mxdev
zope.testrunner
Plone

edit the constraints.txt

vim constraints.txt
# add the following line to constraints.txt
-c https://dist.plone.org/release/6.0.0b2/constraints.txt

run pip install

pip install -r requirements.txt

create an addon in ./src

plonecli create addon src/my.addon
# some questions to answer

edit the requirements.txt and append the local package my.addon

vim requirements.txt
# append this tow lines to requirements.txt
-e src/my.addon
-e src/my.addon[test]

rerun pip install

pip install -r requirements.txt

edit the config for zope config creation

vim instance.yaml
# instance.yaml
default_context:
  initial_user_name: "admin"
  initial_user_password: "admin"

  load_zcml:
    package_includes: ["my.addon"]

  db_storage: direct

create zope a custom config and start the instance

cookiecutter -f --no-input --config-file instance.yaml https://github.com/plone/cookiecutter-zope-instance
runwsgi -v instance/etc/zope.ini

Now my Question, what is the right way to start the tests in the package my.addon?
I started zope-testrunner with the following command:

> zope-testrunner -pvc --test-path=src/my.addon/src/my/addon/

But it ends with an error:

Test-module import failures:

Module: tests.test_robot

ModuleNotFoundError: No module named 'tests'

Module: tests.test_setup

ModuleNotFoundError: No module named 'tests'

Running tests at level 1

Test-modules with import problems:
  tests.test_robot
  tests.test_setup
Total: 0 tests, 0 failures, 2 errors, 0 skipped in 0.000 seconds.

Update, Problem solved

@ksuess Thanks for the hint. The tests are running now.

> zope-testrunner -pvc --test-path=src/my.addon/src/
2 Likes