mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Fix test_py_compile with -O mode (GH-115345)
This commit is contained in:
		
							parent
							
								
									7b25a82e83
								
							
						
					
					
						commit
						07ef9d86a5
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -227,7 +227,8 @@ class PyCompileCLITestCase(unittest.TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        self.directory = tempfile.mkdtemp()
 | 
					        self.directory = tempfile.mkdtemp()
 | 
				
			||||||
        self.source_path = os.path.join(self.directory, '_test.py')
 | 
					        self.source_path = os.path.join(self.directory, '_test.py')
 | 
				
			||||||
        self.cache_path = importlib.util.cache_from_source(self.source_path)
 | 
					        self.cache_path = importlib.util.cache_from_source(self.source_path,
 | 
				
			||||||
 | 
					                                optimization='' if __debug__ else 1)
 | 
				
			||||||
        with open(self.source_path, 'w') as file:
 | 
					        with open(self.source_path, 'w') as file:
 | 
				
			||||||
            file.write('x = 123\n')
 | 
					            file.write('x = 123\n')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -250,6 +251,7 @@ def pycompilecmd_failure(self, *args):
 | 
				
			||||||
        return script_helper.assert_python_failure('-m', 'py_compile', *args)
 | 
					        return script_helper.assert_python_failure('-m', 'py_compile', *args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_stdin(self):
 | 
					    def test_stdin(self):
 | 
				
			||||||
 | 
					        self.assertFalse(os.path.exists(self.cache_path))
 | 
				
			||||||
        result = self.pycompilecmd('-', input=self.source_path)
 | 
					        result = self.pycompilecmd('-', input=self.source_path)
 | 
				
			||||||
        self.assertEqual(result.returncode, 0)
 | 
					        self.assertEqual(result.returncode, 0)
 | 
				
			||||||
        self.assertEqual(result.stdout, b'')
 | 
					        self.assertEqual(result.stdout, b'')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue