Skip to content

Commit

Permalink
tests: report installed versions of common packages
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Mar 14, 2023
1 parent 7cf293a commit 97f0bb6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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"',
"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(ModuleNotFoundError):
valid.append(f'{package}=={metadata.version(package)}')
reqs = ' '.join(valid)
pkg_line = f'installed packages of interest: {reqs}'

return '\n'.join([pkg_line])

0 comments on commit 97f0bb6

Please sign in to comment.