Skip to content

helper__build_test_id is added (conftest refactoring) #229

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

34 changes: 18 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -394,10 +400,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

Expand Down