Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_pep263.py

    r2 r391  
    3131        self.assertEqual(len(d['a']), len(d['b']))
    3232
     33    def test_issue7820(self):
     34        # Ensure that check_bom() restores all bytes in the right order if
     35        # check_bom() fails in pydebug mode: a buffer starts with the first
     36        # byte of a valid BOM, but next bytes are different
     37
     38        # one byte in common with the UTF-16-LE BOM
     39        self.assertRaises(SyntaxError, eval, '\xff\x20')
     40
     41        # two bytes in common with the UTF-8 BOM
     42        self.assertRaises(SyntaxError, eval, '\xef\xbb\x20')
     43
     44    def test_error_message(self):
     45        compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec')
     46        compile('\xef\xbb\xbf\n', 'dummy', 'exec')
     47        compile('\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec')
     48        with self.assertRaisesRegexp(SyntaxError, 'fake'):
     49            compile('# -*- coding: fake -*-\n', 'dummy', 'exec')
     50        with self.assertRaisesRegexp(SyntaxError, 'iso-8859-15'):
     51            compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n',
     52                    'dummy', 'exec')
     53        with self.assertRaisesRegexp(SyntaxError, 'BOM'):
     54            compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n',
     55                    'dummy', 'exec')
     56        with self.assertRaisesRegexp(SyntaxError, 'fake'):
     57            compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec')
     58        with self.assertRaisesRegexp(SyntaxError, 'BOM'):
     59            compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec')
     60
     61
    3362def test_main():
    3463    test_support.run_unittest(PEP263Test)
Note: See TracChangeset for help on using the changeset viewer.