Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(148014)

Delta Between Two Patch Sets: Lib/test/test_sysconfig.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 7 years ago
Right Patch Set: Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_symtable.py ('k') | Lib/test/test_sys.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import unittest 1 import unittest
2 import sys 2 import sys
3 import os 3 import os
4 import subprocess 4 import subprocess
5 import shutil 5 import shutil
6 from copy import copy 6 from copy import copy
7 7
8 from test.support import (run_unittest, TESTFN, unlink, 8 from test.support import (run_unittest, TESTFN, unlink, check_warnings,
9 captured_stdout, skip_unless_symlink) 9 captured_stdout, skip_unless_symlink)
10 10
11 import sysconfig 11 import sysconfig
12 from sysconfig import (get_paths, get_platform, get_config_vars, 12 from sysconfig import (get_paths, get_platform, get_config_vars,
13 get_path, get_path_names, _INSTALL_SCHEMES, 13 get_path, get_path_names, _INSTALL_SCHEMES,
14 _get_default_scheme, _expand_vars, 14 _get_default_scheme, _expand_vars,
15 get_scheme_names, get_config_var, _main) 15 get_scheme_names, get_config_var, _main)
16 import _osx_support 16 import _osx_support
17 17
18 class TestSysConfig(unittest.TestCase): 18 class TestSysConfig(unittest.TestCase):
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 self.assertTrue(os.path.isabs(srcdir), srcdir) 345 self.assertTrue(os.path.isabs(srcdir), srcdir)
346 self.assertTrue(os.path.isdir(srcdir), srcdir) 346 self.assertTrue(os.path.isdir(srcdir), srcdir)
347 347
348 if sysconfig._PYTHON_BUILD: 348 if sysconfig._PYTHON_BUILD:
349 # The python executable has not been installed so srcdir 349 # The python executable has not been installed so srcdir
350 # should be a full source checkout. 350 # should be a full source checkout.
351 Python_h = os.path.join(srcdir, 'Include', 'Python.h') 351 Python_h = os.path.join(srcdir, 'Include', 'Python.h')
352 self.assertTrue(os.path.exists(Python_h), Python_h) 352 self.assertTrue(os.path.exists(Python_h), Python_h)
353 self.assertTrue(sysconfig._is_python_source_dir(srcdir)) 353 self.assertTrue(sysconfig._is_python_source_dir(srcdir))
354 elif os.name == 'posix': 354 elif os.name == 'posix':
355 self.assertEqual(os.path.dirname(sysconfig.get_makefile_filename()), 355 makefile_dir = os.path.dirname(sysconfig.get_makefile_filename())
356 srcdir) 356 # Issue #19340: srcdir has been realpath'ed already
357 makefile_dir = os.path.realpath(makefile_dir)
358 self.assertEqual(makefile_dir, srcdir)
357 359
358 def test_srcdir_independent_of_cwd(self): 360 def test_srcdir_independent_of_cwd(self):
359 # srcdir should be independent of the current working directory 361 # srcdir should be independent of the current working directory
360 # See Issues #15322, #15364. 362 # See Issues #15322, #15364.
361 srcdir = sysconfig.get_config_var('srcdir') 363 srcdir = sysconfig.get_config_var('srcdir')
362 cwd = os.getcwd() 364 cwd = os.getcwd()
363 try: 365 try:
364 os.chdir('..') 366 os.chdir('..')
365 srcdir2 = sysconfig.get_config_var('srcdir') 367 srcdir2 = sysconfig.get_config_var('srcdir')
366 finally: 368 finally:
367 os.chdir(cwd) 369 os.chdir(cwd)
368 self.assertEqual(srcdir, srcdir2) 370 self.assertEqual(srcdir, srcdir2)
371
372 @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
373 'EXT_SUFFIX required for this test')
374 def test_SO_deprecation(self):
375 self.assertWarns(DeprecationWarning,
376 sysconfig.get_config_var, 'SO')
377
378 @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
379 'EXT_SUFFIX required for this test')
380 def test_SO_value(self):
381 with check_warnings(('', DeprecationWarning)):
382 self.assertEqual(sysconfig.get_config_var('SO'),
383 sysconfig.get_config_var('EXT_SUFFIX'))
384
385 @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
386 'EXT_SUFFIX required for this test')
387 def test_SO_in_vars(self):
388 vars = sysconfig.get_config_vars()
389 self.assertIsNotNone(vars['SO'])
390 self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
369 391
370 392
371 class MakefileTests(unittest.TestCase): 393 class MakefileTests(unittest.TestCase):
372 394
373 @unittest.skipIf(sys.platform.startswith('win'), 395 @unittest.skipIf(sys.platform.startswith('win'),
374 'Test is not Windows compatible') 396 'Test is not Windows compatible')
375 def test_get_makefile_filename(self): 397 def test_get_makefile_filename(self):
376 makefile = sysconfig.get_makefile_filename() 398 makefile = sysconfig.get_makefile_filename()
377 self.assertTrue(os.path.isfile(makefile), makefile) 399 self.assertTrue(os.path.isfile(makefile), makefile)
378 400
(...skipping 13 matching lines...) Expand all
392 'var4': '$/invalid', 414 'var4': '$/invalid',
393 'var5': 'dollar$5', 415 'var5': 'dollar$5',
394 }) 416 })
395 417
396 418
397 def test_main(): 419 def test_main():
398 run_unittest(TestSysConfig, MakefileTests) 420 run_unittest(TestSysConfig, MakefileTests)
399 421
400 if __name__ == "__main__": 422 if __name__ == "__main__":
401 test_main() 423 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+