mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	gh-87868: Skip test_one_environment_variable in test_subprocess when the platform or build cannot do that (#113867)
				
					
				
			* improve the assert for test_one_environment_variable * skip some test in test_subprocess when python is configured with shared * also skip the test if AddressSanitizer is enabled --------- Co-authored-by: Steve Dower <steve.dower@microsoft.com>
This commit is contained in:
		
							parent
							
								
									1d75fa43a2
								
							
						
					
					
						commit
						fafb3275f2
					
				
					 1 changed files with 12 additions and 3 deletions
				
			
		| 
						 | 
					@ -835,6 +835,11 @@ class ProcessTestCase(BaseTestCase):
 | 
				
			||||||
                               if not is_env_var_to_ignore(k)]
 | 
					                               if not is_env_var_to_ignore(k)]
 | 
				
			||||||
            self.assertEqual(child_env_names, [])
 | 
					            self.assertEqual(child_env_names, [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @unittest.skipIf(sysconfig.get_config_var('Py_ENABLE_SHARED') == 1,
 | 
				
			||||||
 | 
					                     'The Python shared library cannot be loaded '
 | 
				
			||||||
 | 
					                     'without some system environments.')
 | 
				
			||||||
 | 
					    @unittest.skipIf(check_sanitizer(address=True),
 | 
				
			||||||
 | 
					                     'AddressSanitizer adds to the environment.')
 | 
				
			||||||
    def test_one_environment_variable(self):
 | 
					    def test_one_environment_variable(self):
 | 
				
			||||||
        newenv = {'fruit': 'orange'}
 | 
					        newenv = {'fruit': 'orange'}
 | 
				
			||||||
        cmd = [sys.executable, '-c',
 | 
					        cmd = [sys.executable, '-c',
 | 
				
			||||||
| 
						 | 
					@ -842,9 +847,13 @@ class ProcessTestCase(BaseTestCase):
 | 
				
			||||||
                               'sys.stdout.write("fruit="+os.getenv("fruit"))']
 | 
					                               'sys.stdout.write("fruit="+os.getenv("fruit"))']
 | 
				
			||||||
        if sys.platform == "win32":
 | 
					        if sys.platform == "win32":
 | 
				
			||||||
            cmd = ["CMD", "/c", "SET", "fruit"]
 | 
					            cmd = ["CMD", "/c", "SET", "fruit"]
 | 
				
			||||||
        with subprocess.Popen(cmd, stdout=subprocess.PIPE, env=newenv) as p:
 | 
					        with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=newenv) as p:
 | 
				
			||||||
            stdout, _ = p.communicate()
 | 
					            stdout, stderr = p.communicate()
 | 
				
			||||||
            self.assertTrue(stdout.startswith(b"fruit=orange"))
 | 
					            if p.returncode and support.verbose:
 | 
				
			||||||
 | 
					                print("STDOUT:", stdout.decode("ascii", "replace"))
 | 
				
			||||||
 | 
					                print("STDERR:", stderr.decode("ascii", "replace"))
 | 
				
			||||||
 | 
					            self.assertEqual(p.returncode, 0)
 | 
				
			||||||
 | 
					            self.assertEqual(stdout.strip(), b"fruit=orange")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_invalid_cmd(self):
 | 
					    def test_invalid_cmd(self):
 | 
				
			||||||
        # null character in the command name
 | 
					        # null character in the command name
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue