Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Feb 4, 2023
1 parent 6264e41 commit b37a1a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
from __future__ import annotations
import logging
import pytest


def pytest_addoption(parser: pytest.Parser) -> None:
parser.addoption(
"--oldsetup",
action="store_true",
default=False,
help="Run tests that require older setuptools",
)


def pytest_collection_modifyitems(
config: pytest.Config, items: list[pytest.Item]
) -> None:
if not config.getoption("--oldsetup"):
skipper = pytest.mark.skip(reason="Only run when --oldsetup is given")
for item in items:
if "oldsetup" in item.keywords:
item.add_marker(skipper)


@pytest.fixture(autouse=True)
def capture_all_logs(caplog: pytest.LogCaptureFixture) -> None:
caplog.set_level(logging.DEBUG, logger="versioningit")
Expand Down
1 change: 1 addition & 0 deletions test/data/repos/git/default-version-bad.marks
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
describe_exclude
oldsetup
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ deps =
pytest-mock
wheel
commands =
pytest {posargs:-v} test
pytest {posargs:-v} --oldsetup test

[testenv:lint]
skip_install = True
Expand Down Expand Up @@ -58,6 +58,7 @@ addopts =
filterwarnings = error
markers =
describe_exclude: Tests that use `git describe --exclude` (Added in Git 2.13.0)
oldsetup: Tests to only run under pre-v64 setuptools
norecursedirs = test/data

[coverage:run]
Expand Down

0 comments on commit b37a1a1

Please sign in to comment.