Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24b20c8

Browse files
[summary] An error count of each test is printed
1 parent88bb6ae commit24b20c8

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-
defincrementFailedTestCount(testID:str)->None:
135+
defincrementFailedTestCount(testID:str,errCount:int)->None:
136136
asserttype(testID)==str# noqa: E721
137+
asserttype(errCount)==int# noqa: E721
138+
asserterrCount>=0
137139
asserttype(__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-
defincrementXFailedTestCount(testID:str)->None:
145+
defincrementXFailedTestCount(testID:str,errCount:int)->None:
144146
asserttype(testID)==str# noqa: E721
147+
asserttype(errCount)==int# noqa: E721
148+
asserterrCount>=0
145149
asserttype(__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
iftype(call.excinfo.value)==_pytest.outcomes.Skipped:# noqa: E721
330334
assertnothasattr(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-
eliftype(call.excinfo.value)==_pytest.outcomes.XFailed:# noqa: E721
339-
TEST_PROCESS_STATS.incrementXFailedTestCount(testID)
340+
TEST_PROCESS_STATS.incrementSkippedTestCount()
340341

342+
eliftype(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
asserthasattr(rep,"wasxfail")
347352
assertrep.wasxfailisnotNone
348353
asserttype(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
asserttype(reasonText)==str# noqa: E721
362367

363368
ifreasonText!="":
@@ -369,15 +374,15 @@ def helper__makereport__call(
369374
assertcall.excinfoisnotNone
370375
assertcall.excinfo.valueisnotNone
371376

372-
TEST_PROCESS_STATS.incrementFailedTestCount(testID)
373-
374377
iftype(call.excinfo.value)==SIGNAL_EXCEPTION:# noqa: E721
375378
assertitem_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
elifrep.outcome=="passed":
383388
assertcall.excinfoisNone
@@ -676,11 +681,42 @@ def helper__print_test_list(tests: list[str]) -> None:
676681

677682
nTest=0
678683

679-
whilenTest<len(tests):
680-
testID=tests[nTest]
681-
asserttype(testID)==str# noqa: E721
684+
fortintests:
685+
asserttype(t)==str# noqa: E721
686+
assertt!=""
682687
nTest+=1
683-
logging.info(templateLine.format(nTest,testID))
688+
logging.info(templateLine.format(nTest,t))
689+
690+
691+
# ------------------------------------------------------------------------
692+
defhelper__print_test_list2(tests:list[str,int])->None:
693+
asserttype(tests)==list# noqa: E721
694+
695+
asserthelper__calc_W(9)==1
696+
asserthelper__calc_W(10)==2
697+
asserthelper__calc_W(11)==2
698+
asserthelper__calc_W(99)==2
699+
asserthelper__calc_W(100)==3
700+
asserthelper__calc_W(101)==3
701+
asserthelper__calc_W(999)==3
702+
asserthelper__calc_W(1000)==4
703+
asserthelper__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+
fortintests:
712+
asserttype(t)==tuple# noqa: E721
713+
assertlen(t)==2
714+
asserttype(t[0])==str# noqa: E721
715+
asserttype(t[1])==int# noqa: E721
716+
assertt[0]!=""
717+
assertt[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+
defLOCAL__print_test_list2(
754+
header:str,test_count:int,test_list:list[str,int]
755+
):
756+
asserttype(header)==str# noqa: E721
757+
asserttype(test_count)==int# noqa: E721
758+
asserttype(test_list)==list# noqa: E721
759+
assertheader!=""
760+
asserttest_count>=0
761+
assertlen(test_list)==test_count
762+
763+
LOCAL__print_line1_with_header(header)
764+
logging.info("")
765+
iflen(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)

[8]ページ先頭

©2009-2025 Movatter.jp