8000 [summary] An error count of each test is printed · postgrespro/testgres@24b20c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24b20c8

Browse files
[summary] An error count of each test is printed
1 parent 88bb6ae commit 24b20c8

File tree

1 file changed

+72
-20
lines changed

1 file changed

+72
-20
lines changed

tests/conftest.py

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class TEST_PROCESS_STATS:
109109
cUnexpectedTests: int = 0
110110
cAchtungTests: int = 0
111111

112-
FailedTests = list[str]()
113-
XFailedTests = list[str]()
112+
FailedTests = list[str, int]()
113+
XFailedTests = list[str, int]()
114114
NotXFailedTests = list[str]()
115115
AchtungTests = list[str]()
116116

@@ -132,19 +132,23 @@ def incrementPassedTestCount() -> None:
132132
__class__.cPassedTests += 1
133133

134134
# --------------------------------------------------------------------
135-
def incrementFailedTestCount(testID: str) -> None:
135+
def incrementFailedTestCount(testID: str, errCount: int) -> None:
136136
assert type(testID) == str # noqa: E721
137+
assert type(errCount) == int # noqa: E721
138+
assert errCount >= 0
137139
assert type(__class__.FailedTests) == list # noqa: E721
138140

139-
__class__.FailedTests.append(testID) # raise?
141+
__class__.FailedTests.append((testID, errCount)) # raise?
140142
__class__.cFailedTests += 1
141143

142144
# --------------------------------------------------------------------
143-
def incrementXFailedTestCount(testID: str) -> None:
145+
def incrementXFailedTestCount(testID: str, errCount: int) -> None:
144146
assert type(testID) == str # noqa: E721
147+
assert type(errCount) == int # noqa: E721
148+
assert errCount >= 0
145149
assert type(__class__.XFailedTests) == list # noqa: E721
146150

147-
__class__.XFailedTests.append(testID) # raise?
151+
__class__.XFailedTests.append((testID, errCount)) # raise?
148152
__class__.cXFailedTests += 1
149153

150154
# --------------------------------------------------------------------
@@ -329,26 +333,25 @@ def helper__makereport__call(
329333
if type(call.excinfo.value) == _pytest.outcomes.Skipped: # noqa: E721
330334
assert not hasattr(rep, "wasxfail")
331335

332-
TEST_PROCESS_STATS.incrementSkippedTestCount()
333-
334336
exitStatus = "SKIPPED"
335337
reasonText = str(call.excinfo.value)
336338
reasonMsgTempl = "SKIP REASON: {0}"
337339

338-
elif type(call.excinfo.value) == _pytest.outcomes.XFailed: # noqa: E721
339-
TEST_PROCESS_STATS.incrementXFailedTestCount(testID)
340+
TEST_PROCESS_STATS.incrementSkippedTestCount()
340341

342+
elif type(call.excinfo.value) == _pytest.outcomes.XFailed: # noqa: E721
341343
exitStatus = "XFAILED"
342344
reasonText = str(call.excinfo.value)
343345
reasonMsgTempl = "XFAIL REASON: {0}"
346+
347+
TEST_PROCESS_STATS.incrementXFailedTestCount(testID, item_error_msg_count)
348+
344349
else:
345350
exitStatus = "XFAILED"
346351
assert hasattr(rep, "wasxfail")
347352
assert rep.wasxfail is not None
348353
assert type(rep.wasxfail) == str # noqa: E721
349354

350-
TEST_PROCESS_STATS.incrementXFailedTestCount(testID)
351-
352355
reasonText = rep.wasxfail
353356
reasonMsgTempl = "XFAIL REASON: {0}"
354357

@@ -358,6 +361,8 @@ def helper__makereport__call(
358361
logging.error(call.excinfo.value)
359362
item_error_msg_count += 1
360363

364+
TEST_PROCESS_STATS.incrementXFailedTestCount(testID, item_error_msg_count)
365+
361366
assert type(reasonText) == str # noqa: E721
362367

363368
if reasonText != "":
@@ -369,15 +374,15 @@ def helper__makereport__call(
369374
assert call.excinfo is not None
370375
assert call.excinfo.value is not None
371376

372-
TEST_PROCESS_STATS.incrementFailedTestCount(testID)
373-
374377
if type(call.excinfo.value) == SIGNAL_EXCEPTION: # noqa: E721
375378
assert item_error_msg_count > 0
376379
pass
377380
else:
378381
logging.error(call.excinfo.value)
379382
item_error_msg_count += 1
380383

384+
TEST_PROCESS_STATS.incrementFailedTestCount(testID, item_error_msg_count)
385+
381386
exitStatus = "FAILED"
382387
elif rep.outcome == "passed":
383388
assert call.excinfo is None
@@ -676,11 +681,42 @@ def helper__print_test_list(tests: list[str]) -> None:
676681

677682
nTest = 0
678683

679-
while nTest < len(tests):
680-
testID = tests[nTest]
681-
assert type(testID) == str # noqa: E721
684+
for t in tests:
685+
assert type(t) == str # noqa: E721
686+
assert t != ""
682687
nTest += 1
683-
logging.info(templateLine.format(nTest, testID))
688+
logging.info(templateLine.format(nTest, t))
689+
690+
691+
# ------------------------------------------------------------------------
692+
def helper__print_test_list2(tests: list[str, int]) -> None:
693+
assert type(tests) == list # noqa: E721
694+
695+
assert helper__calc_W(9) == 1
696+
assert helper__calc_W(10) == 2
697+
assert helper__calc_W(11) == 2
698+
assert helper__calc_W(99) == 2
699+
assert helper__calc_W(100) == 3
700+
assert helper__calc_W(101) == 3
701+
assert helper__calc_W(999) == 3
702+
assert helper__calc_W(1000) == 4
703+
assert helper__calc_W(1001) == 4
704+
705+
W = helper__calc_W(len(tests))
706+
707+
templateLine = "{0:0" + str(W) + "d}. {1} ({2})"
708+
709+
nTest = 0
710+
711+
for t in tests:
712+
assert type(t) == tuple # noqa: E721
713+
assert len(t) == 2
714+
assert type(t[0]) == str # noqa: E721
715+
assert type(t[1]) == int # noqa: E721
716+
assert t[0] != ""
717+
assert t[1] >= 0
718+
nTest += 1
719+
logging.info(templateLine.format(nTest, t[0], t[1]))
684720

685721

686722
# /////////////////////////////////////////////////////////////////////////////
@@ -714,20 +750,36 @@ def LOCAL__print_test_list(header: str, test_count: int, test_list: list[str]):
714750
helper__print_test_list(test_list)
715751
logging.info("")
716752

753+
def LOCAL__print_test_list2(
754+
header: str, test_count: int, test_list: list[str, int]
755+
):
756+
assert type(header) == str # noqa: E721
757+
assert type(test_count) == int # noqa: E721
758+
assert type(test_list) == list # noqa: E721
759+
assert header != ""
760+
assert test_count >= 0
761+
assert len(test_list) == test_count
762+
763+
LOCAL__print_line1_with_header(header)
764+
logging.info("")
765+
if len(test_list) > 0:
766+
helper__print_test_list2(test_list)
767+
logging.info("")
768+
717769
# fmt: off
718770
LOCAL__print_test_list(
719771
"ACHTUNG TESTS",
720772
TEST_PROCESS_STATS.cAchtungTests,
721773
TEST_PROCESS_STATS.AchtungTests,
722774
)
723775

724-
LOCAL__print_test_list(
776+
LOCAL__print_test_list2(
725777
"FAILED TESTS",
726778
TEST_PROCESS_STATS.cFailedTests,
727779
TEST_PROCESS_STATS.FailedTests
728780
)
729781

730-
LOCAL__print_test_list(
782+
LOCAL__print_test_list2(
731783
"XFAILED TESTS",
732784
TEST_PROCESS_STATS.cXFailedTests,
733785
TEST_PROCESS_STATS.XFailedTests,

0 commit comments

Comments
 (0)
0