mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Merge #14492: fix some bugs in Tools/scripts/pdeps.py.
Initial patch by Popa Claudiu.
This commit is contained in:
		
						commit
						3861a322b9
					
				
					 2 changed files with 32 additions and 5 deletions
				
			
		|  | @ -6,8 +6,10 @@ | |||
| 
 | ||||
| import os | ||||
| import sys | ||||
| import imp | ||||
| import unittest | ||||
| import sysconfig | ||||
| import tempfile | ||||
| from test import support | ||||
| from test.script_helper import assert_python_ok | ||||
| 
 | ||||
|  | @ -72,6 +74,31 @@ def test_analyze_dxp_import(self): | |||
|                 import analyze_dxp | ||||
| 
 | ||||
| 
 | ||||
| class PdepsTests(unittest.TestCase): | ||||
| 
 | ||||
|     @classmethod | ||||
|     def setUpClass(self): | ||||
|         path = os.path.join(scriptsdir, 'pdeps.py') | ||||
|         self.pdeps = imp.load_source('pdeps', path) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def tearDownClass(self): | ||||
|         if 'pdeps' in sys.modules: | ||||
|             del sys.modules['pdeps'] | ||||
| 
 | ||||
|     def test_process_errors(self): | ||||
|         # Issue #14492: m_import.match(line) can be None. | ||||
|         with tempfile.TemporaryDirectory() as tmpdir: | ||||
|             fn = os.path.join(tmpdir, 'foo') | ||||
|             with open(fn, 'w') as stream: | ||||
|                 stream.write("#!/this/will/fail") | ||||
|             self.pdeps.process(fn, {}) | ||||
| 
 | ||||
|     def test_inverse_attribute_error(self): | ||||
|         # Issue #14492: this used to fail with an AttributeError. | ||||
|         self.pdeps.inverse({'a': []}) | ||||
| 
 | ||||
| 
 | ||||
| def test_main(): | ||||
|     support.run_unittest(*[obj for obj in globals().values() | ||||
|                                if isinstance(obj, type)]) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 R David Murray
						R David Murray