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
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ docs = [
]
test = [
"filelock >= 3",
'importlib-metadata; python_version<"3.8"',
henryiii marked this conversation as resolved.
Show resolved Hide resolved
"pytest >= 6.2.4",
"pytest-cov >= 2.12",
"pytest-mock >= 2",
Expand Down
29 changes: 29 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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,26 @@ 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:
with contextlib.suppress(ImportError):
henryiii marked this conversation as resolved.
Show resolved Hide resolved
valid.append(f'{package}=={metadata.version(package)}')
reqs = ' '.join(valid)
pkg_line = f'installed packages of interest: {reqs}'

return pkg_line