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

Side by Side Diff: Lib/test/test_sys.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_sysconfig.py ('k') | Lib/test/test_threading.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 import unittest, test.support 1 import unittest, test.support
2 from test.support.script_helper import assert_python_ok, assert_python_failure 2 from test.support.script_helper import assert_python_ok, assert_python_failure
3 import sys, io, os 3 import sys, io, os
4 import struct 4 import struct
5 import subprocess 5 import subprocess
6 import textwrap 6 import textwrap
7 import warnings 7 import warnings
8 import operator 8 import operator
9 import codecs 9 import codecs
10 import gc 10 import gc
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 for limit in (10, 25, 50, 75, 100, 150, 200): 248 for limit in (10, 25, 50, 75, 100, 150, 200):
249 # formula extracted from _Py_RecursionLimitLowerWaterMark() 249 # formula extracted from _Py_RecursionLimitLowerWaterMark()
250 if limit > 200: 250 if limit > 200:
251 depth = limit - 50 251 depth = limit - 50
252 else: 252 else:
253 depth = limit * 3 // 4 253 depth = limit * 3 // 4
254 set_recursion_limit_at_depth(depth, limit) 254 set_recursion_limit_at_depth(depth, limit)
255 finally: 255 finally:
256 sys.setrecursionlimit(oldlimit) 256 sys.setrecursionlimit(oldlimit)
257 257
258 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
258 def test_recursionlimit_fatalerror(self): 259 def test_recursionlimit_fatalerror(self):
259 # A fatal error occurs if a second recursion limit is hit when recoverin g 260 # A fatal error occurs if a second recursion limit is hit when recoverin g
260 # from a first one. 261 # from a first one.
261 code = textwrap.dedent(""" 262 code = textwrap.dedent("""
262 import sys 263 import sys
263 264
264 def f(): 265 def f():
265 try: 266 try:
266 f() 267 f()
267 except RecursionError: 268 except RecursionError:
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 576
576 def test_sys_getwindowsversion_no_instantiation(self): 577 def test_sys_getwindowsversion_no_instantiation(self):
577 # Skip if not being run on Windows. 578 # Skip if not being run on Windows.
578 test.support.get_attribute(sys, "getwindowsversion") 579 test.support.get_attribute(sys, "getwindowsversion")
579 self.assert_raise_on_new_sys_type(sys.getwindowsversion()) 580 self.assert_raise_on_new_sys_type(sys.getwindowsversion())
580 581
581 @test.support.cpython_only 582 @test.support.cpython_only
582 def test_clear_type_cache(self): 583 def test_clear_type_cache(self):
583 sys._clear_type_cache() 584 sys._clear_type_cache()
584 585
586 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
585 def test_ioencoding(self): 587 def test_ioencoding(self):
586 env = dict(os.environ) 588 env = dict(os.environ)
587 589
588 # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424, 590 # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424,
589 # not representable in ASCII. 591 # not representable in ASCII.
590 592
591 env["PYTHONIOENCODING"] = "cp424" 593 env["PYTHONIOENCODING"] = "cp424"
592 p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'], 594 p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
593 stdout = subprocess.PIPE, env=env) 595 stdout = subprocess.PIPE, env=env)
594 out = p.communicate()[0].strip() 596 out = p.communicate()[0].strip()
(...skipping 25 matching lines...) Expand all
620 self.assertIn(rb"'\xa2'", err) 622 self.assertIn(rb"'\xa2'", err)
621 623
622 env["PYTHONIOENCODING"] = ":surrogateescape" 624 env["PYTHONIOENCODING"] = ":surrogateescape"
623 p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xdcbd))'], 625 p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xdcbd))'],
624 stdout=subprocess.PIPE, env=env) 626 stdout=subprocess.PIPE, env=env)
625 out = p.communicate()[0].strip() 627 out = p.communicate()[0].strip()
626 self.assertEqual(out, b'\xbd') 628 self.assertEqual(out, b'\xbd')
627 629
628 @unittest.skipUnless(test.support.FS_NONASCII, 630 @unittest.skipUnless(test.support.FS_NONASCII,
629 'requires OS support of non-ASCII encodings') 631 'requires OS support of non-ASCII encodings')
632 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
630 def test_ioencoding_nonascii(self): 633 def test_ioencoding_nonascii(self):
631 env = dict(os.environ) 634 env = dict(os.environ)
632 635
633 env["PYTHONIOENCODING"] = "" 636 env["PYTHONIOENCODING"] = ""
634 p = subprocess.Popen([sys.executable, "-c", 637 p = subprocess.Popen([sys.executable, "-c",
635 'print(%a)' % test.support.FS_NONASCII], 638 'print(%a)' % test.support.FS_NONASCII],
636 stdout=subprocess.PIPE, env=env) 639 stdout=subprocess.PIPE, env=env)
637 out = p.communicate()[0].strip() 640 out = p.communicate()[0].strip()
638 self.assertEqual(out, os.fsencode(test.support.FS_NONASCII)) 641 self.assertEqual(out, os.fsencode(test.support.FS_NONASCII))
639 642
640 @unittest.skipIf(sys.base_prefix != sys.prefix, 643 @unittest.skipIf(sys.base_prefix != sys.prefix,
641 'Test is not venv-compatible') 644 'Test is not venv-compatible')
645 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
642 def test_executable(self): 646 def test_executable(self):
643 # sys.executable should be absolute 647 # sys.executable should be absolute
644 self.assertEqual(os.path.abspath(sys.executable), sys.executable) 648 self.assertEqual(os.path.abspath(sys.executable), sys.executable)
645 649
646 # Issue #7774: Ensure that sys.executable is an empty string if argv[0] 650 # Issue #7774: Ensure that sys.executable is an empty string if argv[0]
647 # has been set to an non existent program name and Python is unable to 651 # has been set to an non existent program name and Python is unable to
648 # retrieve the real program name 652 # retrieve the real program name
649 653
650 # For a normal installation, it should work without 'cwd' 654 # For a normal installation, it should work without 'cwd'
651 # argument. For test runs in the build directory, see #7774. 655 # argument. For test runs in the build directory, see #7774.
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 # XXX 1171 # XXX
1168 # sys.flags 1172 # sys.flags
1169 check(sys.flags, vsize('') + self.P * len(sys.flags)) 1173 check(sys.flags, vsize('') + self.P * len(sys.flags))
1170 1174
1171 1175
1172 def test_main(): 1176 def test_main():
1173 test.support.run_unittest(SysModuleTest, SizeofTest) 1177 test.support.run_unittest(SysModuleTest, SizeofTest)
1174 1178
1175 if __name__ == "__main__": 1179 if __name__ == "__main__":
1176 test_main() 1180 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_sysconfig.py ('k') | Lib/test/test_threading.py » ('j') | no next file with comments »

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