Skip to content

Commit 79bc692

Browse files
conftest is updated - ExitStatusNames (#283)
It is a synchronization with our internal tests.
1 parent 28dac03 commit 79bc692

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

tests/conftest.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ def helper__makereport__setup(
437437
return
438438

439439

440+
# ------------------------------------------------------------------------
441+
class ExitStatusNames:
442+
FAILED = "FAILED"
443+
PASSED = "PASSED"
444+
XFAILED = "XFAILED"
445+
NOT_XFAILED = "NOT XFAILED"
446+
SKIPPED = "SKIPPED"
447+
UNEXPECTED = "UNEXPECTED"
448+
449+
440450
# ------------------------------------------------------------------------
441451
def helper__makereport__call(
442452
item: pytest.Function, call: pytest.CallInfo, outcome: T_PLUGGY_RESULT
@@ -486,28 +496,29 @@ def helper__makereport__call(
486496

487497
# --------
488498
exitStatus = None
499+
exitStatusInfo = None
489500
if rep.outcome == "skipped":
490501
assert call.excinfo is not None # research
491502
assert call.excinfo.value is not None # research
492503

493504
if type(call.excinfo.value) == _pytest.outcomes.Skipped: # noqa: E721
494505
assert not hasattr(rep, "wasxfail")
495506

496-
exitStatus = "SKIPPED"
507+
exitStatus = ExitStatusNames.SKIPPED
497508
reasonText = str(call.excinfo.value)
498509
reasonMsgTempl = "SKIP REASON: {0}"
499510

500511
TEST_PROCESS_STATS.incrementSkippedTestCount()
501512

502-
elif type(call.excinfo.value) == _pytest.outcomes.XFailed: # noqa: E721
503-
exitStatus = "XFAILED"
513+
elif type(call.excinfo.value) == _pytest.outcomes.XFailed: # noqa: E721 E501
514+
exitStatus = ExitStatusNames.XFAILED
504515
reasonText = str(call.excinfo.value)
505516
reasonMsgTempl = "XFAIL REASON: {0}"
506517

507518
TEST_PROCESS_STATS.incrementXFailedTestCount(testID, item_error_msg_count)
508519

509520
else:
510-
exitStatus = "XFAILED"
521+
exitStatus = ExitStatusNames.XFAILED
511522
assert hasattr(rep, "wasxfail")
512523
assert rep.wasxfail is not None
513524
assert type(rep.wasxfail) == str # noqa: E721
@@ -544,7 +555,7 @@ def helper__makereport__call(
544555
assert item_error_msg_count > 0
545556
TEST_PROCESS_STATS.incrementFailedTestCount(testID, item_error_msg_count)
546557

547-
exitStatus = "FAILED"
558+
exitStatus = ExitStatusNames.FAILED
548559
elif rep.outcome == "passed":
549560
assert call.excinfo is None
550561

@@ -559,22 +570,31 @@ def helper__makereport__call(
559570
warnMsg += " [" + rep.wasxfail + "]"
560571

561572
logging.info(warnMsg)
562-
exitStatus = "NOT XFAILED"
573+
exitStatus = ExitStatusNames.NOT_XFAILED
563574
else:
564575
assert not hasattr(rep, "wasxfail")
565576

566577
TEST_PROCESS_STATS.incrementPassedTestCount()
567-
exitStatus = "PASSED"
578+
exitStatus = ExitStatusNames.PASSED
568579
else:
569580
TEST_PROCESS_STATS.incrementUnexpectedTests()
570-
exitStatus = "UNEXPECTED [{0}]".format(rep.outcome)
581+
exitStatus = ExitStatusNames.UNEXPECTED
582+
exitStatusInfo = rep.outcome
571583
# [2025-03-28] It may create a useless problem in new environment.
572584
# assert False
573585

574586
# --------
575587
if item_warning_msg_count > 0:
576588
TEST_PROCESS_STATS.incrementWarningTestCount(testID, item_warning_msg_count)
577589

590+
# --------
591+
assert exitStatus is not None
592+
assert type(exitStatus) == str # noqa: E721
593+
594+
if exitStatus == ExitStatusNames.FAILED:
595+
assert item_error_msg_count > 0
596+
pass
597+
578598
# --------
579599
assert type(TEST_PROCESS_STATS.cTotalDuration) == datetime.timedelta # noqa: E721
580600
assert type(testDurration) == datetime.timedelta # noqa: E721
@@ -583,11 +603,17 @@ def helper__makereport__call(
583603

584604
assert testDurration <= TEST_PROCESS_STATS.cTotalDuration
585605

606+
# --------
607+
exitStatusLineData = exitStatus
608+
609+
if exitStatusInfo is not None:
610+
exitStatusLineData += " [{}]".format(exitStatusInfo)
611+
586612
# --------
587613
logging.info("*")
588614
logging.info("* DURATION : {0}".format(timedelta_to_human_text(testDurration)))
589615
logging.info("*")
590-
logging.info("* EXIT STATUS : {0}".format(exitStatus))
616+
logging.info("* EXIT STATUS : {0}".format(exitStatusLineData))
591617
logging.info("* ERROR COUNT : {0}".format(item_error_msg_count))
592618
logging.info("* WARNING COUNT: {0}".format(item_warning_msg_count))
593619
logging.info("*")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy