2020else :
2121 import importlib_metadata
2222
23- HAS_RESULTLOG = False
24-
25- try :
26- from _pytest .resultlog import ResultLog
27-
28- HAS_RESULTLOG = True
29- except ImportError :
30- # We have a pytest >= 6.1
31- pass
3223
3324try :
3425 from xdist .newhooks import pytest_handlecrashitem
3930 HAS_PYTEST_HANDLECRASHITEM = False
4031
4132
42- PYTEST_GTE_54 = parse_version (pytest .__version__ ) >= parse_version ("5.4" )
43- PYTEST_GTE_62 = parse_version (pytest .__version__ ) >= parse_version ("6.2.0" )
44- PYTEST_GTE_63 = parse_version (pytest .__version__ ) >= parse_version ("6.3.0.dev" )
33+ PYTEST_GTE_63 = parse_version (pytest .__version__ ) >= parse_version ("6.3.0" )
4534
4635
4736def works_with_current_xdist ():
@@ -104,35 +93,11 @@ def pytest_addoption(parser):
10493 "regex provided. Pass this flag multiple times to accumulate a list "
10594 "of regexes to match" ,
10695 )
107- arg_type = "string" if PYTEST_GTE_62 else None
96+ arg_type = "string"
10897 parser .addini ("reruns" , RERUNS_DESC , type = arg_type )
10998 parser .addini ("reruns_delay" , RERUNS_DELAY_DESC , type = arg_type )
11099
111100
112- def _get_resultlog (config ):
113- if not HAS_RESULTLOG :
114- return None
115- elif PYTEST_GTE_54 :
116- # hack
117- from _pytest .resultlog import resultlog_key
118-
119- return config ._store .get (resultlog_key , default = None )
120- else :
121- return getattr (config , "_resultlog" , None )
122-
123-
124- def _set_resultlog (config , resultlog ):
125- if not HAS_RESULTLOG :
126- pass
127- elif PYTEST_GTE_54 :
128- # hack
129- from _pytest .resultlog import resultlog_key
130-
131- config ._store [resultlog_key ] = resultlog
132- else :
133- config ._resultlog = resultlog
134-
135-
136101# making sure the options make sense
137102# should run before / at the beginning of pytest_cmdline_main
138103def check_options (config ):
@@ -142,21 +107,9 @@ def check_options(config):
142107 if config .option .usepdb : # a core option
143108 raise pytest .UsageError ("--reruns incompatible with --pdb" )
144109
145- resultlog = _get_resultlog (config )
146- if resultlog :
147- logfile = resultlog .logfile
148- config .pluginmanager .unregister (resultlog )
149- new_resultlog = RerunResultLog (config , logfile )
150- _set_resultlog (config , new_resultlog )
151- config .pluginmanager .register (new_resultlog )
152-
153110
154111def _get_marker (item ):
155- try :
156- return item .get_closest_marker ("flaky" )
157- except AttributeError :
158- # pytest < 3.6
159- return item .get_marker ("flaky" )
112+ return item .get_closest_marker ("flaky" )
160113
161114
162115def get_reruns_count (item ):
@@ -279,10 +232,7 @@ def _remove_cached_results_from_failed_fixtures(item):
279232 if getattr (fixture_def , cached_result , None ) is not None :
280233 result , _ , err = getattr (fixture_def , cached_result )
281234 if err : # Deleting cached results for only failed fixtures
282- if PYTEST_GTE_54 :
283- setattr (fixture_def , cached_result , None )
284- else :
285- delattr (fixture_def , cached_result )
235+ setattr (fixture_def , cached_result , None )
286236
287237
288238def _remove_failed_setup_state_from_session (item ):
@@ -661,33 +611,3 @@ def show_rerun(terminalreporter, lines):
661611 for rep in rerun :
662612 pos = rep .nodeid
663613 lines .append (f"RERUN { pos } " )
664-
665-
666- if HAS_RESULTLOG :
667-
668- class RerunResultLog (ResultLog ):
669- def __init__ (self , config , logfile ):
670- ResultLog .__init__ (self , config , logfile )
671-
672- def pytest_runtest_logreport (self , report ):
673- """Add support for rerun report."""
674- if report .when != "call" and report .passed :
675- return
676- res = self .config .hook .pytest_report_teststatus (report = report )
677- code = res [1 ]
678- if code == "x" :
679- longrepr = str (report .longrepr )
680- elif code == "X" :
681- longrepr = ""
682- elif report .passed :
683- longrepr = ""
684- elif report .failed :
685- longrepr = str (report .longrepr )
686- elif report .skipped :
687- longrepr = str (report .longrepr [2 ])
688- elif report .outcome == "rerun" :
689- longrepr = str (report .longrepr )
690- else :
691- longrepr = str (report .longrepr )
692-
693- self .log_outcome (report , code , longrepr )
0 commit comments