Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
CONSTRUCTOR_SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x86/signtool.exe"
run: |
rm -rf coverage.json
pytest -vv --cov=constructor --cov-branch tests/test_examples.py
pytest -vv --tb=long -rs --cov=constructor --cov-branch tests/test_examples.py
coverage run --branch --append -m constructor -V
coverage json
- uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ select = [
[tool.pytest.ini_options]
markers = [
"examples",
"installer_types: restrict test to specific installer types (args: tuple of suffix strings)",
]
42 changes: 42 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
import os
import subprocess
import sys
from pathlib import Path

import pytest

REPO_DIR = Path(__file__).parent.parent

def _platform_installer_types() -> list[str]:
"""Return the installer type suffixes available on the current platform."""
if sys.platform.startswith("win"):
return ["exe"]
elif sys.platform == "darwin":
return ["sh", "pkg"]
else:
return ["sh"]

ALL_INSTALLER_TYPES = _platform_installer_types()


def pytest_generate_tests(metafunc):
"""
Automatically parametrize any test that declares an ``installer_type``
fixture argument.

If the test is decorated with ``@pytest.mark.installer_types("pkg", ...)``
the parametrization is restricted to those types (intersected with what is
available on the current platform). Without the marker all platform types
are used.

Note: this hook lives here for colocation with the tests; it should be
moved to ``conftest.py`` if this file grows or the hook is needed elsewhere.
"""
if "installer_type" not in metafunc.fixturenames:
return

marker = metafunc.definition.get_closest_marker("installer_types")
if marker:
requested = list(marker.args) # marker.args is already the tuple of strings
types = [t for t in requested if t in ALL_INSTALLER_TYPES]
if not types:
pytest.skip(
f"No applicable installer types for this platform "
f"(requested: {requested}, available: {ALL_INSTALLER_TYPES})"
)
else:
types = ALL_INSTALLER_TYPES

metafunc.parametrize("installer_type", types)

@pytest.fixture
def self_signed_application_certificate_macos(tmp_path):
Expand Down
Loading
Loading