From 927b205d63b4cfb6db8ea418b14096eafcb0ce5e Mon Sep 17 00:00:00 2001 From: albrja Date: Fri, 22 Sep 2023 13:49:19 -0700 Subject: [PATCH] Run tests on deploy --- .github/workflows/deploy.yml | 4 ++++ tests/conftest.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ba3da927..e7091d15 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,6 +18,10 @@ jobs: python --version python -m pip install --upgrade pip pip install setuptools wheel twine + - name: Test + run: | + pip install .[test] + pytest --runslow ./tests - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} diff --git a/tests/conftest.py b/tests/conftest.py index 4c1e5b7b..b5954706 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,24 @@ from loguru import logger +def pytest_addoption(parser): + parser.addoption("--runslow", action="store_true", default=False, help="run slow tests") + + +def pytest_configure(config): + config.addinivalue_line("markers", "slow: mark test as slow to run") + + +def pytest_collection_modifyitems(config, items): + if config.getoption("--runslow"): + # --runslow given in cli: do not skip slow tests + return + skip_slow = pytest.mark.skip(reason="need --runslow option to run") + for item in items: + if "slow" in item.keywords: + item.add_marker(skip_slow) + + @pytest.fixture def caplog(_caplog): class PropogateHandler(logging.Handler):