@@ -182,7 +182,11 @@ def cant_trace_msg(concurrency: str, the_module: ModuleType | None) -> str | Non
182182 parts .remove ("multiprocessing" )
183183 concurrency = "," .join (parts )
184184
185- if the_module is None :
185+ if testenv .SYS_MON and concurrency :
186+ expected_out = (
187+ f"Can't use core=sysmon: sys.monitoring doesn't support concurrency={ concurrency } \n "
188+ )
189+ elif the_module is None :
186190 # We don't even have the underlying module installed, we expect
187191 # coverage to alert us to this fact.
188192 expected_out = (
@@ -251,10 +255,16 @@ def try_some_code(
251255 lines = line_count (code )
252256 assert line_counts (data )["try_it.py" ] == lines
253257
258+ @pytest .mark .skipif (
259+ not testenv .CAN_MEASURE_THREADS , reason = "Can't measure threads with this core."
260+ )
254261 def test_threads (self ) -> None :
255262 code = (THREAD + SUM_RANGE_Q + PRINT_SUM_RANGE ).format (QLIMIT = self .QLIMIT )
256263 self .try_some_code (code , "thread" , threading )
257264
265+ @pytest .mark .skipif (
266+ not testenv .CAN_MEASURE_THREADS , reason = "Can't measure threads with this core."
267+ )
258268 def test_threads_simple_code (self ) -> None :
259269 code = SIMPLE .format (QLIMIT = self .QLIMIT )
260270 self .try_some_code (code , "thread" , threading )
@@ -318,6 +328,9 @@ def do():
318328 self .try_some_code (BUG_330 , "eventlet" , eventlet , "0\n " )
319329
320330 # Sometimes a test fails due to inherent randomness. Try more times.
331+ @pytest .mark .skipif (
332+ not testenv .CAN_MEASURE_THREADS , reason = "Can't measure threads with this core."
333+ )
321334 @pytest .mark .flaky (max_runs = 3 )
322335 def test_threads_with_gevent (self ) -> None :
323336 self .make_file (
@@ -347,13 +360,17 @@ def gwork(q):
347360 )
348361 _ , out = self .run_command_status ("coverage run --concurrency=thread,gevent both.py" )
349362 if gevent is None :
350- assert out == ( "Couldn't trace with concurrency=gevent, the module isn't installed.\n " )
363+ assert "Couldn't trace with concurrency=gevent, the module isn't installed.\n " in out
351364 pytest .skip ("Can't run test without gevent installed." )
352365 if not testenv .C_TRACER :
353- assert out == (
354- f"Can't support concurrency=gevent with { testenv .REQUESTED_TRACER_CLASS } , "
355- + "only threads are supported.\n "
356- )
366+ if testenv .PY_TRACER :
367+ assert out == (
368+ "Can't support concurrency=gevent with PyTracer, only threads are supported.\n "
369+ )
370+ else :
371+ assert out == (
372+ "Can't use core=sysmon: sys.monitoring doesn't support concurrency=gevent\n "
373+ )
357374 pytest .skip (f"Can't run gevent with { testenv .REQUESTED_TRACER_CLASS } ." )
358375
359376 assert out == "done\n "
@@ -392,7 +409,10 @@ class WithoutConcurrencyModuleTest(CoverageTest):
392409 def test_missing_module (self , module : str ) -> None :
393410 self .make_file ("prog.py" , "a = 1" )
394411 sys .modules [module ] = None # type: ignore[assignment]
395- msg = f"Couldn't trace with concurrency={ module } , the module isn't installed."
412+ if testenv .SYS_MON :
413+ msg = rf"Can't use core=sysmon: sys.monitoring doesn't support concurrency={ module } "
414+ else :
415+ msg = rf"Couldn't trace with concurrency={ module } , the module isn't installed."
396416 with pytest .raises (ConfigError , match = msg ):
397417 self .command_line (f"run --concurrency={ module } prog.py" )
398418
@@ -554,6 +574,9 @@ def test_multiprocessing_and_gevent(self, start_method: str) -> None:
554574 start_method = start_method ,
555575 )
556576
577+ @pytest .mark .skipif (
578+ not testenv .CAN_MEASURE_BRANCHES , reason = "Can't measure branches with this core"
579+ )
557580 def test_multiprocessing_with_branching (self , start_method : str ) -> None :
558581 nprocs = 3
559582 upto = 30
0 commit comments