Pytest no longer applies --no-migrations from setup.cfg when --html argument is used
mnieber opened this issue · 12 comments
I have a setup.cfg file with this configuration for pytest:
[tool:pytest]
addopts = -vvvv --fail-on-template-vars --ignore=integration_tests --disable-socket --no-migrations
If I run pytest without --html
then it applies the --no-migrations option as expected, but when I include --html
then it no longer does so.
Can you share a minimal repro case?
Any thoughts @RonnyPfannschmidt ? 🤔
without context its completely unclear, not even a hint to guess
Thanks for looking into it, yes, I will create a small repo to reproduce this.
I found out more details:
- when I use --html then the setup.cfg file is not read at all (I tested this by adding a mistake in setup.cfg on purpose)
- I'm using Django in Docker and I'm pointing the --html argument to a html file that is shared with the host (see details below). However, when I point --html to a local file then setup.cfg is picked up, and the problem goes away (--no-migrations is applied correctly). Note though that pytest-html can write to the shared file without any problems.
Here some details about how I'm sharing my file. The docker-compose file has this volume:
volumes:
/opt/projects/foo/backend/pytest_report.html:/app/pytest_report.html
This file is owned by root but has 777 permissions:
-rwxrwxrwx 1 root root 5 Dez 10 11:12 /opt/projects/foo/backend/pytest_report.html
If you have suggestions on what else I can do to find out more, please let me know (providing a repo that produces the problem is a bit tedious, I would have to add a docker-compose environment, but if I can debug something in pytest-html then I will)
Yes, it's present (when I leave out the --html argument, then setup.cfg is picked up, and pytest will return with an error because I added a deliberate mistake to setup.cfg, so I know when it's picked up and when not).
BTW I'm now also running with --self-contained-html to limit the error surface. The problem persists so it's probably unrelated to the assets directory.
Another small hint is that when i use pytest-html-reporter then it works correctly (it can write to the shared file, and setup.cfg is picked up). Unfortunately, pytest-html-reporter doesn't give me the stacktrace in its report.
I agree it must be docker related (or permissions related), because when I point it to a local file (not shared with the host), then the problem goes away.
I'm sorry, I don't want to make the effort to provide a repo that includes Docker to reproduce this. I will work around it by copying the local file to the shared file. Thanks for looking into it, I have a good enough workaround.
For the record, a better workaround is to not share the pytest_report.html file between the host and docker-container, but share a pytest_report directory and use --html /app/pytest_report/pytest_report.html in the docker container. This also solves the problem.
Great! I'll close this issue then.
If someone else runs into this in the future, they can reopen. 👍
I don't mean to reopen this, but it seems I was mistaken about my better fix (mapping a directory instead of a single file), This doesn't solve the issue, Just mentioning this for anyone reading this issue later.
I will instead use my other workaround (create the report file locally and then copy if to the mapped file).
(I will just keep reporting here :-D )
I just found out the problem only happens if I point --html at a report file that already exists. So probably it's completely unrelated to docker.