@@ -430,7 +430,7 @@ def test_non_base_multierror():
430430 assert isinstance (exc , ExceptionGroup )
431431
432432
433- def run_script (name , use_ipython = False ) :
433+ def run_script (name : str ) -> subprocess . CompletedProcess [ bytes ] :
434434 import trio
435435
436436 trio_path = Path (trio .__file__ ).parent .parent
@@ -447,24 +447,7 @@ def run_script(name, use_ipython=False):
447447 env ["PYTHONPATH" ] = os .pathsep .join (pp )
448448 print ("subprocess PYTHONPATH:" , env .get ("PYTHONPATH" ))
449449
450- if use_ipython :
451- lines = [
452- "import runpy" ,
453- f"runpy.run_path(r'{ script_path } ', run_name='trio.fake')" ,
454- "exit()" ,
455- ]
456-
457- cmd = [
458- sys .executable ,
459- "-u" ,
460- "-m" ,
461- "IPython" ,
462- # no startup files
463- "--quick" ,
464- "--TerminalIPythonApp.code_to_run=" + "\n " .join (lines ),
465- ]
466- else :
467- cmd = [sys .executable , "-u" , str (script_path )]
450+ cmd = [sys .executable , "-u" , str (script_path )]
468451 print ("running:" , cmd )
469452 completed = subprocess .run (
470453 cmd , env = env , stdout = subprocess .PIPE , stderr = subprocess .STDOUT
@@ -474,69 +457,6 @@ def run_script(name, use_ipython=False):
474457 return completed
475458
476459
477- def check_simple_excepthook (completed ):
478- assert_match_in_seq (
479- [
480- "in <module>" ,
481- "MultiError" ,
482- "--- 1 ---" ,
483- "in exc1_fn" ,
484- "ValueError" ,
485- "--- 2 ---" ,
486- "in exc2_fn" ,
487- "KeyError" ,
488- ],
489- completed .stdout .decode ("utf-8" ),
490- )
491-
492-
493- try :
494- import IPython # noqa: F401
495- except ImportError : # pragma: no cover
496- have_ipython = False
497- else :
498- have_ipython = True
499-
500- need_ipython = pytest .mark .skipif (not have_ipython , reason = "need IPython" )
501-
502-
503- @slow
504- @need_ipython
505- def test_ipython_exc_handler ():
506- completed = run_script ("simple_excepthook.py" , use_ipython = True )
507- check_simple_excepthook (completed )
508-
509-
510- @slow
511- @need_ipython
512- def test_ipython_imported_but_unused ():
513- completed = run_script ("simple_excepthook_IPython.py" )
514- check_simple_excepthook (completed )
515-
516-
517- @slow
518- @need_ipython
519- def test_ipython_custom_exc_handler ():
520- # Check we get a nice warning (but only one!) if the user is using IPython
521- # and already has some other set_custom_exc handler installed.
522- completed = run_script ("ipython_custom_exc.py" , use_ipython = True )
523- assert_match_in_seq (
524- [
525- # The warning
526- "RuntimeWarning" ,
527- "IPython detected" ,
528- "skip installing Trio" ,
529- # The MultiError
530- "MultiError" ,
531- "ValueError" ,
532- "KeyError" ,
533- ],
534- completed .stdout .decode ("utf-8" ),
535- )
536- # Make sure our other warning doesn't show up
537- assert "custom sys.excepthook" not in completed .stdout .decode ("utf-8" )
538-
539-
540460@slow
541461@pytest .mark .skipif (
542462 not Path ("/usr/lib/python3/dist-packages/apport_python_hook.py" ).exists (),
0 commit comments