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

Adding a more comprehensive printing in pytest #2920

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
33 changes: 33 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Loading