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

Side by Side Diff: Lib/test/test_site.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 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:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_signal.py ('k') | Lib/test/test_socket.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Tests for 'site'. 1 """Tests for 'site'.
2 2
3 Tests assume the initial paths in sys.path once the interpreter has begun 3 Tests assume the initial paths in sys.path once the interpreter has begun
4 executing have not been removed. 4 executing have not been removed.
5 5
6 """ 6 """
7 import unittest 7 import unittest
8 import test.support 8 import test.support
9 from test.support import captured_stderr, TESTFN, EnvironmentVarGuard 9 from test.support import captured_stderr, TESTFN, EnvironmentVarGuard
10 import builtins 10 import builtins
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 # that is tested for 157 # that is tested for
158 try: 158 try:
159 pth_file.create() 159 pth_file.create()
160 site.addsitedir(pth_file.base_dir, set()) 160 site.addsitedir(pth_file.base_dir, set())
161 self.pth_file_tests(pth_file) 161 self.pth_file_tests(pth_file)
162 finally: 162 finally:
163 pth_file.cleanup() 163 pth_file.cleanup()
164 164
165 @unittest.skipUnless(site.ENABLE_USER_SITE, "requires access to PEP 370 " 165 @unittest.skipUnless(site.ENABLE_USER_SITE, "requires access to PEP 370 "
166 "user-site (site.ENABLE_USER_SITE)") 166 "user-site (site.ENABLE_USER_SITE)")
167 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
167 def test_s_option(self): 168 def test_s_option(self):
168 usersite = site.USER_SITE 169 usersite = site.USER_SITE
169 self.assertIn(usersite, sys.path) 170 self.assertIn(usersite, sys.path)
170 171
171 env = os.environ.copy() 172 env = os.environ.copy()
172 rc = subprocess.call([sys.executable, '-c', 173 rc = subprocess.call([sys.executable, '-c',
173 'import sys; sys.exit(%r in sys.path)' % usersite], 174 'import sys; sys.exit(%r in sys.path)' % usersite],
174 env=env) 175 env=env)
175 self.assertEqual(rc, 1) 176 self.assertEqual(rc, 1)
176 177
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 """Test side-effects from importing 'site'.""" 315 """Test side-effects from importing 'site'."""
315 316
316 def setUp(self): 317 def setUp(self):
317 """Make a copy of sys.path""" 318 """Make a copy of sys.path"""
318 self.sys_path = sys.path[:] 319 self.sys_path = sys.path[:]
319 320
320 def tearDown(self): 321 def tearDown(self):
321 """Restore sys.path""" 322 """Restore sys.path"""
322 sys.path[:] = self.sys_path 323 sys.path[:] = self.sys_path
323 324
325 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
324 def test_abs_paths(self): 326 def test_abs_paths(self):
325 # Make sure all imported modules have their __file__ and __cached__ 327 # Make sure all imported modules have their __file__ and __cached__
326 # attributes as absolute paths. Arranging to put the Lib directory on 328 # attributes as absolute paths. Arranging to put the Lib directory on
327 # PYTHONPATH would cause the os module to have a relative path for 329 # PYTHONPATH would cause the os module to have a relative path for
328 # __file__ if abs_paths() does not get run. sys and builtins (the 330 # __file__ if abs_paths() does not get run. sys and builtins (the
329 # only other modules imported before site.py runs) do not have 331 # only other modules imported before site.py runs) do not have
330 # __file__ or __cached__ because they are built-in. 332 # __file__ or __cached__ because they are built-in.
331 parent = os.path.relpath(os.path.dirname(os.__file__)) 333 parent = os.path.relpath(os.path.dirname(os.__file__))
332 env = os.environ.copy() 334 env = os.environ.copy()
333 env['PYTHONPATH'] = parent 335 env['PYTHONPATH'] = parent
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 with test.support.transient_internet(url): 431 with test.support.transient_internet(url):
430 with urllib.request.urlopen(req) as data: 432 with urllib.request.urlopen(req) as data:
431 code = data.getcode() 433 code = data.getcode()
432 except urllib.error.HTTPError as e: 434 except urllib.error.HTTPError as e:
433 code = e.code 435 code = e.code
434 self.assertEqual(code, 200, msg="Can't find " + url) 436 self.assertEqual(code, 200, msg="Can't find " + url)
435 437
436 438
437 class StartupImportTests(unittest.TestCase): 439 class StartupImportTests(unittest.TestCase):
438 440
441 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
439 def test_startup_imports(self): 442 def test_startup_imports(self):
440 # This tests checks which modules are loaded by Python when it 443 # This tests checks which modules are loaded by Python when it
441 # initially starts upon startup. 444 # initially starts upon startup.
442 popen = subprocess.Popen([sys.executable, '-I', '-v', '-c', 445 popen = subprocess.Popen([sys.executable, '-I', '-v', '-c',
443 'import sys; print(set(sys.modules))'], 446 'import sys; print(set(sys.modules))'],
444 stdout=subprocess.PIPE, 447 stdout=subprocess.PIPE,
445 stderr=subprocess.PIPE) 448 stderr=subprocess.PIPE)
446 stdout, stderr = popen.communicate() 449 stdout, stderr = popen.communicate()
447 stdout = stdout.decode('utf-8') 450 stdout = stdout.decode('utf-8')
448 stderr = stderr.decode('utf-8') 451 stderr = stderr.decode('utf-8')
(...skipping 14 matching lines...) Expand all
463 # http://bugs.python.org/issue19218> 466 # http://bugs.python.org/issue19218>
464 collection_mods = {'_collections', 'collections', 'functools', 467 collection_mods = {'_collections', 'collections', 'functools',
465 'heapq', 'itertools', 'keyword', 'operator', 468 'heapq', 'itertools', 'keyword', 'operator',
466 'reprlib', 'types', 'weakref' 469 'reprlib', 'types', 'weakref'
467 }.difference(sys.builtin_module_names) 470 }.difference(sys.builtin_module_names)
468 self.assertFalse(modules.intersection(collection_mods), stderr) 471 self.assertFalse(modules.intersection(collection_mods), stderr)
469 472
470 473
471 if __name__ == "__main__": 474 if __name__ == "__main__":
472 unittest.main() 475 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_signal.py ('k') | Lib/test/test_socket.py » ('j') | no next file with comments »

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