From b4814d2f86a3b86ca4c7c02bee0c255275308b9a Mon Sep 17 00:00:00 2001 From: niboshi Date: Thu, 31 Oct 2019 02:54:18 +0000 Subject: [PATCH] Print installed packages in pytest --- tests/conftest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index f854edcf589f..caa46ccd05e5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,6 @@ import os +import subprocess +import sys from chainer import testing from chainer.testing import parameterized @@ -9,6 +11,26 @@ assert _pairwise_parameterize in ('never', 'always') +def _is_pip_installed(): + try: + import pip # NOQA + return True + except ImportError: + return False + + +def _is_in_ci(): + ci_name = os.environ.get('CHAINER_CI', '') + return ci_name != '' + + +def pytest_configure(config): + # Print installed packages + if _is_in_ci() and _is_pip_installed(): + print("***** Installed packages *****", flush=True) + subprocess.check_call([sys.executable, '-m', 'pip', 'freeze', '--all']) + + def pytest_collection(session): # Perform pairwise testing. # TODO(kataoka): This is a tentative fix. Discuss its public interface.