From 484500d9c257f7d9dff99bef7b8d52e38faeb7ba Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Mon, 31 Mar 2025 12:25:01 +0300 Subject: [PATCH 1/2] pytest_runtest_makereport is updated (cleanup) Local 'rep' is not used. --- tests/conftest.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0f65838e..e27eaeb3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -394,10 +394,6 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo): assert outcome is not None assert type(outcome) == pluggy.Result # noqa: E721 - rep: pytest.TestReport = outcome.get_result() - assert rep is not None - assert type(rep) == pytest.TestReport # noqa: E721 - if call.when == "collect": return From 81982b97445729cdad5f0453a3a6c75fbfb6336e Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Mon, 31 Mar 2025 13:11:15 +0300 Subject: [PATCH 2/2] helper__build_test_id is added (conftest refactoring) --- tests/conftest.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0f65838e..5a883280 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -199,6 +199,22 @@ def timedelta_to_human_text(delta: datetime.timedelta) -> str: # ///////////////////////////////////////////////////////////////////////////// +def helper__build_test_id(item: pytest.Function) -> str: + assert item is not None + assert isinstance(item, pytest.Function) + + testID = "" + + if item.cls is not None: + testID = item.cls.__module__ + "." + item.cls.__name__ + "::" + + testID = testID + item.name + + return testID + +# ///////////////////////////////////////////////////////////////////////////// + + def helper__makereport__setup( item: pytest.Function, call: pytest.CallInfo, outcome: pluggy.Result ): @@ -224,12 +240,7 @@ def helper__makereport__setup( TEST_PROCESS_STATS.incrementNotExecutedTestCount() return - testID = "" - - if item.cls is not None: - testID = item.cls.__module__ + "." + item.cls.__name__ + "::" - - testID = testID + item.name + testID = helper__build_test_id(item) if rep.outcome == "passed": testNumber = TEST_PROCESS_STATS.incrementExecutedTestCount() @@ -279,12 +290,7 @@ def helper__makereport__call( assert type(rep) == pytest.TestReport # noqa: E721 # -------- - testID = "" - - if item.cls is not None: - testID = item.cls.__module__ + "." + item.cls.__name__ + "::" - - testID = testID + item.name + testID = helper__build_test_id(item) # -------- assert call.start <= call.stop