8
8
9
9
from . import extras # noqa: F401
10
10
from .html_report import HTMLReport
11
- from .nextgen import NextGenReport
12
- from .nextgen import NextGenSelfContainedReport
11
+ from .nextgen import NextGenReport , NextGenSelfContainedReport
13
12
14
13
15
14
def pytest_addhooks (pluginmanager ):
@@ -44,6 +43,12 @@ def pytest_addoption(parser):
44
43
default = [],
45
44
help = "append given css file content to report style file." ,
46
45
)
46
+ group .addoption (
47
+ "--next-gen" ,
48
+ action = "store_true" ,
49
+ default = False ,
50
+ help = "use next-gen report." ,
51
+ )
47
52
parser .addini (
48
53
"render_collapsed" ,
49
54
type = "bool" ,
@@ -80,16 +85,17 @@ def pytest_configure(config):
80
85
raise OSError (os_error )
81
86
82
87
if not hasattr (config , "workerinput" ):
83
- # prevent opening htmlpath on worker nodes (xdist)
84
- # config._html = HTMLReport(htmlpath, config)
85
- # config.pluginmanager.register(config._html)
88
+ # prevent opening html_path on worker nodes (xdist)
86
89
87
- if config .getoption ("self_contained_html " ):
88
- config ._next_gen = NextGenSelfContainedReport (html_path , config )
90
+ if not config .getoption ("next_gen " ):
91
+ config ._html = HTMLReport (html_path , config )
89
92
else :
90
- config ._next_gen = NextGenReport (html_path , config )
93
+ if config .getoption ("self_contained_html" ):
94
+ config ._html = NextGenSelfContainedReport (html_path , config )
95
+ else :
96
+ config ._html = NextGenReport (html_path , config )
91
97
92
- config .pluginmanager .register (config ._next_gen )
98
+ config .pluginmanager .register (config ._html )
93
99
94
100
95
101
def pytest_unconfigure (config ):
@@ -98,11 +104,6 @@ def pytest_unconfigure(config):
98
104
del config ._html
99
105
config .pluginmanager .unregister (html )
100
106
101
- next_gen = getattr (config , "_next_gen" , None )
102
- if next_gen :
103
- del config ._next_gen
104
- config .pluginmanager .unregister (next_gen )
105
-
106
107
107
108
@pytest .hookimpl (tryfirst = True , hookwrapper = True )
108
109
def pytest_runtest_makereport (item , call ):
0 commit comments