Skip to content

Commit

Permalink
Use fixtures to control testing output paths and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Nov 27, 2024
1 parent c1e21d5 commit d1ebf24
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 245 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ jobs:
env:
SETUPTOOLS_SCM_SUBPROCESS_TIMEOUT: "120"

- name: Run tests
# Disable MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.
if: runner.os != 'macOS'
# Do not run on MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.

- name: Run tests (incl. regression tests)
if: runner.os == 'Windows'
run: |
python -m pytest --regression-tests
- name: Run tests (excl. regression tests)
if: runner.os == 'Linux'
run: |
python -m pytest
Expand Down
26 changes: 25 additions & 1 deletion pytests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import os
import pathlib
import pooch
import pytest
import shutil


TEST_DATA_ARCHIVE = "https://github.com/dokempf/helios-test-data/releases/download/2024-08-29/data.tar.gz"
TEST_DATA_CHECKSUM = "df4490f41cd5f9e17fd794429ea7b2fa1f0ad58848b5df44199d24c820cb324b"


@pytest.fixture
def regression_data():
def regression_data(request):
""" A fixture that ensures the existence of regression data
Returns the Path to where that data is located after (cached) download
from GitHub.
"""

if not request.config.getoption("--regression-tests"):
return None

# Define the cache location
cache = pooch.os_cache("helios")

Expand All @@ -28,10 +35,27 @@ def regression_data():
return cache


@pytest.fixture(scope="session")
def output_dir(request):
dir = pathlib.Path(os.getcwd()) / "pytest-output"

yield dir

if request.config.getoption("--delete-output"):
shutil.rmtree(dir)


def pytest_addoption(parser):
parser.addoption(
"--regression-tests",
action="store_true",
default=False,
help="run regression tests",
)

parser.addoption(
"--delete-output",
action="store_true",
default=False,
help="run regression tests",
)
Loading

0 comments on commit d1ebf24

Please sign in to comment.