@@ -65,7 +65,8 @@ def __init__(self, config):
6565 def __call__ (self , msg ):
6666 if self .config .getoption ("capture" , "fd" ) == "no" :
6767 self .report (msg )
68- if not isinstance (msg , str ):
68+ if not isinstance (msg , str ): # pragma: no cover
69+ # e.g. the dict payloads from our observability machinery
6970 msg = repr (msg )
7071 self .results .append (msg )
7172
@@ -88,7 +89,8 @@ def __call__(self, msg):
8889 # need balanced increment/decrement in configure/sessionstart to support nested
8990 # pytest (e.g. runpytest_inprocess), so this early increment in effect replaces
9091 # the first one in pytest_configure.
91- if not os .environ .get ("HYPOTHESIS_EXTEND_INITIALIZATION" ):
92+ # (the else-branch can only run in a child process)
93+ if not os .environ .get ("HYPOTHESIS_EXTEND_INITIALIZATION" ): # pragma: no branch
9294 _hypothesis_globals .in_initialization += 1
9395 if "hypothesis" in sys .modules :
9496 # Some other plugin has imported hypothesis, so we'll check if there
@@ -169,7 +171,7 @@ def pytest_configure(config):
169171 # with the extra values given (in this case 'verbosity')
170172 settings .register_profile (name , verbosity = verbosity_value )
171173 settings .load_profile (name )
172- if (
174+ if ( # pragma: no cover # the explain option is currently untested
173175 config .getoption (EXPLAIN_OPTION )
174176 and Phase .explain not in settings .default .phases
175177 ):
@@ -326,10 +328,12 @@ def _stash_get(config, key, default):
326328 if hasattr (config , "stash" ):
327329 # pytest 7
328330 return config .stash .get (key , default )
329- elif hasattr (config , "_store" ):
331+ # The old-pytest fallbacks below are covered by the check-pytest*
332+ # jobs, which don't measure coverage.
333+ elif hasattr (config , "_store" ): # pragma: no cover
330334 # pytest 5.4
331335 return config ._store .get (key , default )
332- else :
336+ else : # pragma: no cover
333337 return getattr (config , key , default )
334338
335339 @pytest .hookimpl (hookwrapper = True )
@@ -358,7 +362,7 @@ def pytest_runtest_makereport(item, call):
358362 xml .add_global_property (name , stats_base64 )
359363
360364 # If there's a terminal report, include our summary stats for each test
361- if terminalreporter is not None :
365+ if terminalreporter is not None : # pragma: no branch
362366 report .__dict__ [STATS_KEY ] = stats
363367
364368 # If there's an HTML report, include our summary stats for each test
@@ -399,7 +403,9 @@ def pytest_terminal_summary(terminalreporter):
399403
400404 from hypothesis .internal .observability import _WROTE_TO
401405
402- if _WROTE_TO :
406+ if _WROTE_TO : # pragma: no cover
407+ # Observability output is only produced by tests which run pytest
408+ # in a subprocess, where we don't measure coverage.
403409 terminalreporter .section ("Hypothesis" )
404410 for fname in sorted (_WROTE_TO ):
405411 terminalreporter .write_line (f"observations written to { fname } " )
@@ -412,10 +418,10 @@ def pytest_terminal_summary(terminalreporter):
412418 try :
413419 gc_patches ()
414420 fname = save_patch (patch )
415- except Exception :
421+ except Exception : # pragma: no cover
416422 # fail gracefully if we hit any filesystem or permissions problems
417423 return
418- if not _WROTE_TO :
424+ if not _WROTE_TO : # pragma: no branch
419425 terminalreporter .section ("Hypothesis" )
420426 terminalreporter .write_line (
421427 f"`git apply { fname } ` to add failing test cases to your code."
0 commit comments