@@ -4748,38 +4748,25 @@ class MyList(list):
47484748 with self .assertRaises (TypeError ):
47494749 _suggestions ._generate_suggestions (MyList (), "" )
47504750
4751- @support .requires_subprocess ()
47524751 def test_no_site_package_flavour (self ):
4753- import subprocess
4754-
4755- cmd = [sys .executable , '-S' , '-c' , 'import boo' ]
4756- result = subprocess .run (
4757- cmd ,
4758- stdout = subprocess .PIPE ,
4759- stderr = subprocess .PIPE ,
4760- text = True
4761- )
4762-
4763- self .assertNotEqual (result .returncode , 0 )
4764- self .assertTrue (
4765- ("Site initialization is disabled, did you forget to "
4766- + "add the site-packages directory to sys.path?" ) in result .stderr
4767- )
4752+ code = """import boo"""
4753+ _ , _ , stderr = assert_python_failure ('-S' , '-c' , code )
47684754
4769- cmd = [sys .executable , '-S' , '-c' ,
4770- 'import sys; sys.builtin_module_names = sys.builtin_module_names + ("boo",); import boo' ]
4771-
4772- result = subprocess .run (
4773- cmd ,
4774- stdout = subprocess .PIPE ,
4775- stderr = subprocess .PIPE ,
4776- text = True
4755+ self .assertIn (
4756+ (b"Site initialization is disabled, did you forget to "
4757+ b"add the site-packages directory to sys.path?" ), stderr
47774758 )
47784759
4779- self .assertNotEqual (result .returncode , 0 )
4780- self .assertTrue (
4781- ("Site initialization is disabled, did you forget to "
4782- + "add the site-packages directory to sys.path?" ) not in result .stderr
4760+ code = """
4761+ import sys
4762+ sys.builtin_module_names = sys.builtin_module_names + ("boo",)
4763+ import boo
4764+ """
4765+ _ , _ , stderr = assert_python_failure ('-S' , '-c' , code )
4766+
4767+ self .assertNotIn (
4768+ (b"Site initialization is disabled, did you forget to "
4769+ b"add the site-packages directory to sys.path?" ), stderr
47834770 )
47844771
47854772
0 commit comments