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 8ced1d0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 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,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 8ced1d0

Please sign in to comment.