← Back to team overview

sts-sponsors team mailing list archive

Re: [Merge] ~alexsander-souza/maas-ci/+git/system-tests:add_maas_gitrev_to_report into ~maas-committers/maas-ci/+git/system-tests:master

 


Diff comments:

> diff --git a/systemtests/conftest.py b/systemtests/conftest.py
> index 58fc4aa..74238e5 100644
> --- a/systemtests/conftest.py
> +++ b/systemtests/conftest.py
> @@ -198,6 +199,18 @@ def pytest_runtest_makereport(item: Any, call: Any) -> Iterator[Any]:
>          rep.sections.append(("Test logging", testlog.getvalue()))
>  
>  
> +@pytest.hookimpl(hookwrapper=True)  # type: ignore
> +def pytest_terminal_summary(
> +    terminalreporter: TerminalReporter, exitstatus: int, config: pytest.Config
> +):
> +    yield
> +    session = terminalreporter._session
> +    if session is not None and hasattr(session, "maas_version"):

in general hasattr() is an anti-pattern since internally it just does getattr() wrapped around try..except

how about

if session is not None and maas_version := getattr(session, "maas_version"):
    ... use maas_version here ...

> +        print("BEGIN_SYSTEMTESTS_META")
> +        print(f"maasgit: {session.maas_version}")
> +        print("END_SYSTEMTESTS_META")
> +
> +
>  @pytest.fixture(scope="module")
>  def machine_config(
>      authenticated_admin: AuthenticatedAPIClient, request: Any


-- 
https://code.launchpad.net/~alexsander-souza/maas-ci/+git/system-tests/+merge/440799
Your team MAAS Committers is subscribed to branch ~maas-committers/maas-ci/+git/system-tests:master.



References