diff --git a/tests/common.py b/tests/common.py index ebb65b315d..29f0eb492c 100644 --- a/tests/common.py +++ b/tests/common.py @@ -104,7 +104,7 @@ def has_grpc(): def has_dpf(): - return os.environ.get("DPF_PORT", "") + return bool(os.environ.get("DPF_PORT", "")) def is_smp(): diff --git a/tests/conftest.py b/tests/conftest.py index fb7145adc2..723522a117 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,6 +23,7 @@ from collections import namedtuple import os from pathlib import Path +from shutil import get_terminal_size from sys import platform from _pytest.terminal import TerminalReporter # for terminal customization @@ -238,6 +239,38 @@ def requires_dependency(dependency: str): raise MapdlRuntimeError(ERRMSG) +@pytest.hookimpl(trylast=True) +def pytest_report_header(config, start_path, startdir): + text = [] + text += ["Testing variables".center(get_terminal_size()[0], "-")] + text += [ + f"Session dependent: ON_CI ({ON_CI}), TESTING_MINIMAL ({TESTING_MINIMAL}), SUPPORT_PLOTTING ({SUPPORT_PLOTTING})" + ] + text += [ + f"OS dependent: ON_LINUX ({ON_LINUX}), ON_UBUNTU ({ON_UBUNTU}), ON_WINDOWS ({ON_WINDOWS}), ON_MACOS )({ON_MACOS})" + ] + text += [ + f"MAPDL dependent: ON_LOCAL ({ON_LOCAL}), ON_STUDENT ({ON_STUDENT}), HAS_GRPC ({HAS_GRPC}), HAS_DPF ({HAS_DPF}), IS_SMP ({IS_SMP})" + ] + + text += ["Environment variables".center(get_terminal_size()[0], "-")] + line = "" + for env_var in [ + "PYMAPDL_START_INSTANCE", + "PYMAPDL_PORT", + "PYMAPDL_DB_PORT", + "PYMAPDL_IP", + "DPF_PORT", + "DPF_START_SERVER", + ]: + env_var_value = os.environ.get(env_var, None) + if env_var_value is not None: + line += f"{env_var} ('{env_var_value}'), " + text += [line] + text += ["Pytest configuration".center(get_terminal_size()[0], "-")] + return "\n".join(text) + + ## Changing report line length class MyReporter(TerminalReporter): def short_test_summary(self):