Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container for Pytest #901

Merged
merged 8 commits into from
Oct 15, 2022

Conversation

nucleogenic
Copy link
Member

@nucleogenic nucleogenic commented Oct 9, 2022

Container providing an alternative to a local Python venv for test execution.

Usage

Basic usage:

docker compose run pytest

Running with specific parameters:

docker compose run pytest -v -k test_download_file

Accessing a shell:

docker compose run --entrypoint=bash pytest

The container can be rebuilt if needed (e.g. when requirements-dev.txt is updated) with:

docker compose build pytest [--no-cache --progress=plain]

@rdmark
Copy link
Member

rdmark commented Oct 9, 2022

@nucleogenic Minor thing, but it'd be helpful if you could make branches in this project instead of your fork. It makes it slightly more convenient to check out your work branch and try out the code. :)

parser.addoption("--base_url", action="store", default="http://localhost:8080")
parser.addoption("--httpserver_host", action="store", default="host.docker.internal")
parser.addoption("--httpserver_listen_address", action="store", default="127.0.0.1")
parser.addoption("--base_url", action="store", default="http://rascsi_web")
Copy link
Member

Choose a reason for hiding this comment

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

This change means that you have to override --base_url now when running in a default non-dockerized environment. Is there a particular reason for changing it for the purpose of the docker environment?

BTW, this is also a good reminder to write a README with some pointers / reminders when running the tests. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point! I can probably define an environment var inside the container and set some defaults based on container vs non container environments. Can you describe the environment you want to run the tests on? e.g. on dev machine against local web.py process, dev machine against remote Pi, executed directly on the Pi?

Copy link
Member

Choose a reason for hiding this comment

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

My main use case is "executed directly on the Pi" but I can imagine that the other two scenarios are potentially useful for other people.

Copy link
Member Author

Choose a reason for hiding this comment

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

Base URL now defaults to http://localhost:8080 as before, unless the env var DOCKER is truthy.

Copy link
Member

@rdmark rdmark left a comment

Choose a reason for hiding this comment

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

Seems good. Just one remark.

@nucleogenic
Copy link
Member Author

nucleogenic commented Oct 15, 2022

@rdmark Please could you re-test this in your Pi environment?

You can now use the --home_dir=/home/user parameter when executing the tests.

Copy link
Member

@rdmark rdmark left a comment

Choose a reason for hiding this comment

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

Thank for the excellent improvements!

@rdmark rdmark merged commit 6514e24 into PiSCSI:develop Oct 15, 2022
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.

2 participants