Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: report installed versions of common packages #588

Merged
merged 5 commits into from Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/conftest.py
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: MIT

import contextlib
import os
import os.path
import shutil
Expand All @@ -12,6 +13,11 @@

import build.env

if sys.version_info < (3, 8):
import importlib_metadata as metadata
else:
from importlib import metadata


def pytest_addoption(parser):
os.environ['PYTHONWARNINGS'] = 'ignore:DEPRECATION::pip._internal.cli.base_command' # for when not run within tox
Expand Down Expand Up @@ -109,3 +115,25 @@ def tmp_dir():
@pytest.fixture(autouse=True)
def force_venv(mocker):
mocker.patch.object(build.env, '_should_use_virtualenv', lambda: False)


def pytest_report_header() -> str:
interesting_packages = [
'build',
'colorama',
'filelock',
'packaging',
'pip',
'pyproject_hooks',
'setuptools',
'tomli',
'virtualenv',
'wheel',
]
valid = []
for package in interesting_packages:
# Old versions of importlib_metadata made this FileNotFoundError
with contextlib.suppress(ModuleNotFoundError, FileNotFoundError):
valid.append(f'{package}=={metadata.version(package)}')
reqs = ' '.join(valid)
return f'installed packages of interest: {reqs}'