From d3b096da9a537d8236d535c4daf70d76c1d1d6be Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 13 Jun 2024 12:53:40 -0700 Subject: [PATCH 1/2] Move pytest configuration file to root of repository The previous location worked fine when running pytest directly or via the task. It was also possible to run the tests from the PyCharm UI after a bit of configuration. However, I had no luck with using the VS Code test explorer. VS Code is likely to be the most common development environment of contributors so it will be important to make it easy to use with VS Code. Moving pytest.ini file to the root of the repository allowed the VS Code test explorer to correctly recognize it. --- compilesketches/tests/pytest.ini => pytest.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename compilesketches/tests/pytest.ini => pytest.ini (100%) diff --git a/compilesketches/tests/pytest.ini b/pytest.ini similarity index 100% rename from compilesketches/tests/pytest.ini rename to pytest.ini From dbee8d00206e52ce2a39805eef5ca2fafe0d3757 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 13 Jun 2024 12:55:52 -0700 Subject: [PATCH 2/2] Configure PYTHONPATH via pytest configuration file Previously, the python:test task set PYTHONPATH via environment variable. That approach is fine when running the tests via the task, but meant that PYTHONPATH was not correctly configured when running the tests via the interface of an IDE. Each contributor would be forced to configure their IDE in order to allow it to run the tests successfully. Configuring PYTHONPATH via the pytest.ini file makes this universal. --- .github/workflows/test-python-poetry-task.yml | 2 ++ Taskfile.yml | 1 - pytest.ini | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-python-poetry-task.yml b/.github/workflows/test-python-poetry-task.yml index 9fddf152..d0a717fc 100644 --- a/.github/workflows/test-python-poetry-task.yml +++ b/.github/workflows/test-python-poetry-task.yml @@ -16,6 +16,7 @@ on: - "pyproject.toml" - "compilesketches/tests/**" - "**.py" + - "**/pytest.ini" pull_request: paths: - ".github/workflows/test-python-poetry-task.ya?ml" @@ -28,6 +29,7 @@ on: - "pyproject.toml" - "compilesketches/tests/**" - "**.py" + - "**/pytest.ini" schedule: # Run periodically to catch breakage caused by external changes. - cron: "0 12 * * WED" diff --git a/Taskfile.yml b/Taskfile.yml index 3ee780b9..d6ac18b5 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -434,7 +434,6 @@ tasks: POETRY_GROUPS: dev,main cmds: - | - export PYTHONPATH="${PWD}/{{.PYTHON_PROJECT_PATH}}" poetry run \ coverage run \ --source="{{.PYTHON_PROJECT_PATH}}" \ diff --git a/pytest.ini b/pytest.ini index b8beed3f..202c1cf8 100644 --- a/pytest.ini +++ b/pytest.ini @@ -8,3 +8,4 @@ filterwarnings = # --capture=no - disable per-test capture # --tb=long sets the length of the traceback in case of failures addopts = --capture=no --tb=long --verbose +pythonpath = compilesketches