1
1
# /////////////////////////////////////////////////////////////////////////////
2
2
# PyTest Configuration
3
3
4
- import _pytest .outcomes
5
-
6
4
import pluggy
7
5
import pytest
8
- import _pytest
9
6
import os
10
7
import logging
11
8
import pathlib
12
9
import math
13
10
import datetime
14
11
12
+ import _pytest .outcomes
13
+ import _pytest .unittest
14
+ import _pytest .logging
15
+
15
16
# /////////////////////////////////////////////////////////////////////////////
16
17
17
18
C_ROOT_DIR__RELATIVE = ".."
@@ -91,10 +92,6 @@ def GetCurrentTestWorkerSignature() -> str:
91
92
return __class__ .sm_CurrentTestWorkerSignature
92
93
93
94
94
- # /////////////////////////////////////////////////////////////////////////////# /////////////////////////////////////////////////////////////////////////////
95
- # Fixtures
96
-
97
-
98
95
# /////////////////////////////////////////////////////////////////////////////
99
96
# TEST_PROCESS_STATS
100
97
@@ -198,10 +195,13 @@ def helper__makereport__setup(
198
195
assert item is not None
199
196
assert call is not None
200
197
assert outcome is not None
201
- assert type (item ) == pytest .Function # noqa: E721
198
+ # it may be pytest.Function or _pytest.unittest.TestCaseFunction
199
+ assert isinstance (item , pytest .Function )
202
200
assert type (call ) == pytest .CallInfo # noqa: E721
203
201
assert type (outcome ) == pluggy .Result # noqa: E721
204
202
203
+ C_LINE1 = "******************************************************"
204
+
205
205
# logging.info("pytest_runtest_makereport - setup")
206
206
207
207
TEST_PROCESS_STATS .incrementTotalTestCount ()
@@ -214,26 +214,32 @@ def helper__makereport__setup(
214
214
TEST_PROCESS_STATS .incrementNotExecutedTestCount ()
215
215
return
216
216
217
- assert rep .outcome == "passed"
218
-
219
- testNumber = TEST_PROCESS_STATS .incrementExecutedTestCount ()
220
-
221
217
testID = ""
222
218
223
219
if item .cls is not None :
224
220
testID = item .cls .__module__ + "." + item .cls .__name__ + "::"
225
221
226
222
testID = testID + item .name
227
223
228
- if testNumber > 1 :
229
- logging . info ( "" )
224
+ if rep . outcome == "passed" :
225
+ testNumber = TEST_PROCESS_STATS . incrementExecutedTestCount ( )
230
226
231
- logging .info ("******************************************************" )
232
- logging .info ("* START TEST {0}" .format (testID ))
227
+ logging .info (C_LINE1 )
228
+ logging .info ("* START TEST {0}" .format (testID ))
229
+ logging .info ("*" )
230
+ logging .info ("* Path : {0}" .format (item .path ))
231
+ logging .info ("* Number: {0}" .format (testNumber ))
232
+ logging .info ("*" )
233
+ return
234
+
235
+ assert rep .outcome != "passed"
236
+
237
+ logging .info (C_LINE1 )
238
+ logging .info ("* ACHTUNG TEST {0}" .format (testID ))
233
239
logging .info ("*" )
234
- logging .info ("* Path : {0}" .format (item .path ))
235
- logging .info ("* Number: {0}" .format (testNumber ))
240
+ logging .info ("* Outcome is [{0}]" .format (rep .outcome ))
236
241
logging .info ("*" )
242
+ return
237
243
238
244
239
245
# ------------------------------------------------------------------------
@@ -243,12 +249,11 @@ def helper__makereport__call(
243
249
assert item is not None
244
250
assert call is not None
245
251
assert outcome is not None
246
- assert type (item ) == pytest .Function # noqa: E721
252
+ # it may be pytest.Function or _pytest.unittest.TestCaseFunction
253
+ assert isinstance (item , pytest .Function )
247
254
assert type (call ) == pytest .CallInfo # noqa: E721
248
255
assert type (outcome ) == pluggy .Result # noqa: E721
249
256
250
- # logging.info("pytest_runtest_makereport - call")
251
-
252
257
rep = outcome .get_result ()
253
258
assert rep is not None
254
259
assert type (rep ) == pytest .TestReport # noqa: E721
@@ -350,6 +355,7 @@ def helper__makereport__call(
350
355
logging .info ("* EXIT STATUS : {0}" .format (exitStatus ))
351
356
logging .info ("*" )
352
357
logging .info ("* STOP TEST {0}" .format (testID ))
358
+ logging .info ("*" )
353
359
354
360
355
361
# /////////////////////////////////////////////////////////////////////////////
@@ -359,17 +365,14 @@ def helper__makereport__call(
359
365
def pytest_runtest_makereport (item : pytest .Function , call : pytest .CallInfo ):
360
366
assert item is not None
361
367
assert call is not None
362
- assert type (item ) == pytest .Function # noqa: E721
368
+ # it may be pytest.Function or _pytest.unittest.TestCaseFunction
369
+ assert isinstance (item , pytest .Function )
363
370
assert type (call ) == pytest .CallInfo # noqa: E721
364
371
365
- # logging.info("[pytest_runtest_makereport][#001][{0}][{1}]".format(item.name, call.when))
366
-
367
372
outcome : pluggy .Result = yield
368
373
assert outcome is not None
369
374
assert type (outcome ) == pluggy .Result # noqa: E721
370
375
371
- # logging.info("[pytest_runtest_makereport][#002][{0}][{1}]".format(item.name, call.when))
372
-
373
376
rep : pytest .TestReport = outcome .get_result ()
374
377
assert rep is not None
375
378
assert type (rep ) == pytest .TestReport # noqa: E721
@@ -503,7 +506,13 @@ def pytest_configure(config: pytest.Config) -> None:
503
506
504
507
log_path .mkdir (exist_ok = True )
505
508
506
- logging_plugin = config .pluginmanager .get_plugin ("logging-plugin" )
509
+ logging_plugin : _pytest .logging .LoggingPlugin = config .pluginmanager .get_plugin (
510
+ "logging-plugin"
511
+ )
512
+
513
+ assert logging_plugin is not None
514
+ assert isinstance (logging_plugin , _pytest .logging .LoggingPlugin )
515
+
507
516
logging_plugin .set_log_path (str (log_path / log_name ))
508
517
509
518
0 commit comments