| LEFT | RIGHT |
| 1 # -*- coding: iso-8859-1 -*- | 1 # -*- coding: iso-8859-1 -*- |
| 2 import unittest, test.support | 2 import unittest, test.support |
| 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 | 7 |
| 8 # count the number of test runs, used to create unique | 8 # count the number of test runs, used to create unique |
| 9 # strings to intern in test_intern() | 9 # strings to intern in test_intern() |
| 10 numruns = 0 | 10 numruns = 0 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 def test_sys_flags(self): | 444 def test_sys_flags(self): |
| 445 self.assertTrue(sys.flags) | 445 self.assertTrue(sys.flags) |
| 446 attrs = ("debug", "division_warning", | 446 attrs = ("debug", "division_warning", |
| 447 "inspect", "interactive", "optimize", "dont_write_bytecode", | 447 "inspect", "interactive", "optimize", "dont_write_bytecode", |
| 448 "no_user_site", "no_site", "ignore_environment", "verbose", | 448 "no_user_site", "no_site", "ignore_environment", "verbose", |
| 449 "bytes_warning", "hash_randomization") | 449 "bytes_warning", "hash_randomization") |
| 450 for attr in attrs: | 450 for attr in attrs: |
| 451 self.assertTrue(hasattr(sys.flags, attr), attr) | 451 self.assertTrue(hasattr(sys.flags, attr), attr) |
| 452 self.assertEqual(type(getattr(sys.flags, attr)), int, attr) | 452 self.assertEqual(type(getattr(sys.flags, attr)), int, attr) |
| 453 self.assertTrue(repr(sys.flags)) | 453 self.assertTrue(repr(sys.flags)) |
| 454 self.assertEqual(len(sys.flags), len(attrs)) | 454 # NOTE: len(sys.flags) is #flags - 1 in 3.1 for backwards compatibility |
| 455 self.assertEqual(len(sys.flags), len(attrs) - 1) |
| 455 | 456 |
| 456 def test_clear_type_cache(self): | 457 def test_clear_type_cache(self): |
| 457 sys._clear_type_cache() | 458 sys._clear_type_cache() |
| 458 | 459 |
| 459 def test_ioencoding(self): | 460 def test_ioencoding(self): |
| 460 env = dict(os.environ) | 461 env = dict(os.environ) |
| 461 | 462 |
| 462 # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424, | 463 # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424, |
| 463 # not representable in ASCII. | 464 # not representable in ASCII. |
| 464 | 465 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 try: | 782 try: |
| 782 raise TypeError | 783 raise TypeError |
| 783 except TypeError: | 784 except TypeError: |
| 784 tb = sys.exc_info()[2] | 785 tb = sys.exc_info()[2] |
| 785 # traceback | 786 # traceback |
| 786 if tb != None: | 787 if tb != None: |
| 787 check(tb, size(h + '2P2i')) | 788 check(tb, size(h + '2P2i')) |
| 788 # symtable entry | 789 # symtable entry |
| 789 # XXX | 790 # XXX |
| 790 # sys.flags | 791 # sys.flags |
| 791 check(sys.flags, size(vh) + self.P * len(sys.flags)) | 792 # NOTE: len(sys.flags) is #flags - 1 in 3.1 for backwards compatibility |
| 793 check(sys.flags, size(vh) + self.P * (len(sys.flags) + 1)) |
| 792 | 794 |
| 793 def test_getfilesystemencoding(self): | 795 def test_getfilesystemencoding(self): |
| 794 import codecs | 796 import codecs |
| 795 | 797 |
| 796 def check_fsencoding(fs_encoding): | 798 def check_fsencoding(fs_encoding): |
| 797 if sys.platform == 'darwin': | 799 if sys.platform == 'darwin': |
| 798 self.assertEqual(fs_encoding, 'utf-8') | 800 self.assertEqual(fs_encoding, 'utf-8') |
| 799 elif fs_encoding is None: | 801 elif fs_encoding is None: |
| 800 return | 802 return |
| 801 codecs.lookup(fs_encoding) | 803 codecs.lookup(fs_encoding) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 830 try: | 832 try: |
| 831 self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx") | 833 self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx") |
| 832 finally: | 834 finally: |
| 833 sys.setfilesystemencoding(old) | 835 sys.setfilesystemencoding(old) |
| 834 | 836 |
| 835 def test_main(): | 837 def test_main(): |
| 836 test.support.run_unittest(SysModuleTest, SizeofTest) | 838 test.support.run_unittest(SysModuleTest, SizeofTest) |
| 837 | 839 |
| 838 if __name__ == "__main__": | 840 if __name__ == "__main__": |
| 839 test_main() | 841 test_main() |
| LEFT | RIGHT |