Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accommodations for running tests in containers that don't match the h…
…ost OS (#1834) * Set object store URL in tests using an env var The S3 endpoint URL used in the unit tests was hard-coded to localhost. When executing the tests in a container, a minio sibling container can't be accessed via localhost. This allows setting the endpoint URL via an environment variable, and adds 'BANDERSNATCH_*' to the environment variable passthrough list for Tox. ...noticing that Tox was the reason the environment variable was being ignored took a very long time. * Fix line endings for storage plugin sample file test Previously the test_get_hash test used shutil.copy to duplicate a sample file from the project directory into a temp directory for the test. If the project folder is cloned on Windows then bind-mounted into a Linux container, with the test run in the container, the file would have Windows line endings while the test would expect unix line endings based on sys.platform within the container. Instead of copying the file, this change writes the file from a string value using Python's universal newlines support, so the written file will have the same line ending as the platform executing the test. This change trips mypy errors in the pre-commit checks. The errors show when running mypy in the console or via pre-commit, but the MyPy plugin for VS Code *doesn't* and will make the *opposite complaint* if you try to change the file to fix the errors shown in pre-commit. I don't know what to do about that. * Set some pytest file discovery settings explicitly in pytest.ini Pytest would fail to discover any test files when run in a container with the project folder mounted. Adding these helped, and doesn't change anything when tests are run 'normally' as far as I can tell. I know what each does, but I don't know why the problem was happening in the container specifically, or why these fix it. This is a "web search the error message" -> "find reasonable option on StackOverflow" fix.
- Loading branch information