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

Side by Side Diff: Lib/test/support/__init__.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/regrtest.py ('k') | Lib/test/support/script_helper.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 """Supporting definitions for the Python regression tests.""" 1 """Supporting definitions for the Python regression tests."""
2 2
3 if __name__ != 'test.support': 3 if __name__ != 'test.support':
4 raise ImportError('support must be imported from the test package') 4 raise ImportError('support must be imported from the test package')
5 5
6 import collections.abc 6 import collections.abc
7 import contextlib 7 import contextlib
8 import errno 8 import errno
9 import faulthandler 9 import faulthandler
10 import fnmatch 10 import fnmatch
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 try: 784 try:
785 os.fsdecode(os.fsencode(character)) 785 os.fsdecode(os.fsencode(character))
786 except UnicodeError: 786 except UnicodeError:
787 pass 787 pass
788 else: 788 else:
789 FS_NONASCII = character 789 FS_NONASCII = character
790 break 790 break
791 791
792 # TESTFN_UNICODE is a non-ascii filename 792 # TESTFN_UNICODE is a non-ascii filename
793 TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f" 793 TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f"
794 if sys.platform == 'darwin': 794 if sys.platform in ('darwin', 'ios'):
795 # In Mac OS X's VFS API file names are, by definition, canonically 795 # In iOS and Mac OS X, VFS API file names are, by definition, canonically
796 # decomposed Unicode, encoded using UTF-8. See QA1173: 796 # decomposed Unicode, encoded using UTF-8. See QA1173:
797 # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html 797 # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
798 import unicodedata 798 import unicodedata
799 TESTFN_UNICODE = unicodedata.normalize('NFD', TESTFN_UNICODE) 799 TESTFN_UNICODE = unicodedata.normalize('NFD', TESTFN_UNICODE)
800 TESTFN_ENCODING = sys.getfilesystemencoding() 800 TESTFN_ENCODING = sys.getfilesystemencoding()
801 801
802 # TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be 802 # TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be
803 # encoded by the filesystem encoding (in strict mode). It can be None if we 803 # encoded by the filesystem encoding (in strict mode). It can be None if we
804 # cannot generate such filename. 804 # cannot generate such filename.
805 TESTFN_UNENCODABLE = None 805 TESTFN_UNENCODABLE = None
806 if os.name in ('nt', 'ce'): 806 if os.name in ('nt', 'ce'):
807 # skip win32s (0) or Windows 9x/ME (1) 807 # skip win32s (0) or Windows 9x/ME (1)
808 if sys.getwindowsversion().platform >= 2: 808 if sys.getwindowsversion().platform >= 2:
809 # Different kinds of characters from various languages to minimize the 809 # Different kinds of characters from various languages to minimize the
810 # probability that the whole name is encodable to MBCS (issue #9819) 810 # probability that the whole name is encodable to MBCS (issue #9819)
811 TESTFN_UNENCODABLE = TESTFN + "-\u5171\u0141\u2661\u0363\uDC80" 811 TESTFN_UNENCODABLE = TESTFN + "-\u5171\u0141\u2661\u0363\uDC80"
812 try: 812 try:
813 TESTFN_UNENCODABLE.encode(TESTFN_ENCODING) 813 TESTFN_UNENCODABLE.encode(TESTFN_ENCODING)
814 except UnicodeEncodeError: 814 except UnicodeEncodeError:
815 pass 815 pass
816 else: 816 else:
817 print('WARNING: The filename %r CAN be encoded by the filesystem enc oding (%s). ' 817 print('WARNING: The filename %r CAN be encoded by the filesystem enc oding (%s). '
818 'Unicode filename tests may not be effective' 818 'Unicode filename tests may not be effective'
819 % (TESTFN_UNENCODABLE, TESTFN_ENCODING)) 819 % (TESTFN_UNENCODABLE, TESTFN_ENCODING))
820 TESTFN_UNENCODABLE = None 820 TESTFN_UNENCODABLE = None
821 # Mac OS X denies unencodable filenames (invalid utf-8) 821 # Mac OS X and iOS deny unencodable filenames (invalid utf-8)
822 elif sys.platform != 'darwin': 822 elif sys.platform not in ('darwin', 'ios'):
823 try: 823 try:
824 # ascii and utf-8 cannot encode the byte 0xff 824 # ascii and utf-8 cannot encode the byte 0xff
825 b'\xff'.decode(TESTFN_ENCODING) 825 b'\xff'.decode(TESTFN_ENCODING)
826 except UnicodeDecodeError: 826 except UnicodeDecodeError:
827 # 0xff will be encoded using the surrogate character u+DCFF 827 # 0xff will be encoded using the surrogate character u+DCFF
828 TESTFN_UNENCODABLE = TESTFN \ 828 TESTFN_UNENCODABLE = TESTFN \
829 + b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape') 829 + b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape')
830 else: 830 else:
831 # File system encoding (eg. ISO-8859-* encodings) can encode 831 # File system encoding (eg. ISO-8859-* encodings) can encode
832 # the byte 0xff. Skip some unicode filename tests. 832 # the byte 0xff. Skip some unicode filename tests.
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 import tracemalloc 2425 import tracemalloc
2426 except ImportError: 2426 except ImportError:
2427 pass 2427 pass
2428 else: 2428 else:
2429 if tracemalloc.is_tracing(): 2429 if tracemalloc.is_tracing():
2430 raise unittest.SkipTest("run_in_subinterp() cannot be used " 2430 raise unittest.SkipTest("run_in_subinterp() cannot be used "
2431 "if tracemalloc module is tracing " 2431 "if tracemalloc module is tracing "
2432 "memory allocations") 2432 "memory allocations")
2433 import _testcapi 2433 import _testcapi
2434 return _testcapi.run_in_subinterp(code) 2434 return _testcapi.run_in_subinterp(code)
OLDNEW
« no previous file with comments | « Lib/test/regrtest.py ('k') | Lib/test/support/script_helper.py » ('j') | no next file with comments »

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