Add a `debug_mode: bool` fixture via `--tpdb` flag
Allows tests (including any `@tractor_test`s) to subscribe to a CLI flag `--tpdb` (for "tractor python debugger") which the session can provide to tests which can then proxy the value to `open_root_actor()` (via `open_nursery()`) when booting the runtime - thus enabling our debug mode globally to any subscribers B) This is real handy if you have some failures but can't determine the root issue without jumping into a `pdbp` REPL inside a (sub-)actor's spawned-task.sc_super_proto_dgrams
							parent
							
								
									2a5ff82061
								
							
						
					
					
						commit
						54576851e9
					
				|  | @ -41,22 +41,43 @@ no_windows = pytest.mark.skipif( | |||
| 
 | ||||
| def pytest_addoption(parser): | ||||
|     parser.addoption( | ||||
|         "--ll", action="store", dest='loglevel', | ||||
|         "--ll", | ||||
|         action="store", | ||||
|         dest='loglevel', | ||||
|         default='ERROR', help="logging level to set when testing" | ||||
|     ) | ||||
| 
 | ||||
|     parser.addoption( | ||||
|         "--spawn-backend", action="store", dest='spawn_backend', | ||||
|         "--spawn-backend", | ||||
|         action="store", | ||||
|         dest='spawn_backend', | ||||
|         default='trio', | ||||
|         help="Processing spawning backend to use for test run", | ||||
|     ) | ||||
| 
 | ||||
|     parser.addoption( | ||||
|         "--tpdb", "--debug-mode", | ||||
|         action="store_true", | ||||
|         dest='tractor_debug_mode', | ||||
|         # default=False, | ||||
|         help=( | ||||
|             'Enable a flag that can be used by tests to to set the ' | ||||
|             '`debug_mode: bool` for engaging the internal ' | ||||
|             'multi-proc debugger sys.' | ||||
|         ), | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| def pytest_configure(config): | ||||
|     backend = config.option.spawn_backend | ||||
|     tractor._spawn.try_set_start_method(backend) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.fixture(scope='session') | ||||
| def debug_mode(request): | ||||
|     return request.config.option.tractor_debug_mode | ||||
| 
 | ||||
| 
 | ||||
| @pytest.fixture(scope='session', autouse=True) | ||||
| def loglevel(request): | ||||
|     orig = tractor.log._default_loglevel | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue