Skip to content

Feat/extending pytest summary line length #1220

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

Merged
merged 11 commits into from
Jul 9, 2022
31 changes: 31 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,37 @@
"SpacedPaths", ["path_without_spaces", "path_with_spaces", "path_with_single_quote"]
)

from _pytest.terminal import TerminalReporter


## Changing report line length
class MyReporter(TerminalReporter):
def short_test_summary(self):
# your own impl goes here, for example:
self.write_sep("=", "PyMAPDL Pytest short summary")

failed = self.stats.get("failed", [])
for rep in failed:
# breakpoint()
self.write_line(
f"[FAILED] {rep.head_line} - {rep.longreprtext.splitlines()[-3]}"
)

errored = self.stats.get("error", [])
for rep in errored:
# breakpoint()
self.write_line(
f"[ERROR] {rep.head_line} - {rep.longreprtext.splitlines()[-3]}"
)


@pytest.mark.trylast
def pytest_configure(config):
vanilla_reporter = config.pluginmanager.getplugin("terminalreporter")
my_reporter = MyReporter(config)
config.pluginmanager.unregister(vanilla_reporter)
config.pluginmanager.register(my_reporter, "terminalreporter")


# Check if MAPDL is installed
# NOTE: checks in this order to get the newest installed version
Expand Down