diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-06-30 09:18:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 09:18:18 (GMT) |
commit | 21cbdae90ffdac047d27d1b83a5442fabcf89f7c (patch) | |
tree | 8cead832cdbbd9b4ab28e8c7b87cf8ba6d3e667f /Lib/test/test_linecache.py | |
parent | 68fb03249f3b17146db42b00a75718b823a2280c (diff) | |
download | cpython-21cbdae90ffdac047d27d1b83a5442fabcf89f7c.zip cpython-21cbdae90ffdac047d27d1b83a5442fabcf89f7c.tar.gz cpython-21cbdae90ffdac047d27d1b83a5442fabcf89f7c.tar.bz2 |
gh-92336: linecache.getline should not raise exceptions on decoding errors (GH-94410)
Diffstat (limited to 'Lib/test/test_linecache.py')
-rw-r--r-- | Lib/test/test_linecache.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_linecache.py b/Lib/test/test_linecache.py index c6e2dad..72dd401 100644 --- a/Lib/test/test_linecache.py +++ b/Lib/test/test_linecache.py @@ -73,12 +73,10 @@ class GetLineTestsBadData(TempFile): # file_byte_string = b'Bad data goes here' def test_getline(self): - self.assertRaises((SyntaxError, UnicodeDecodeError), - linecache.getline, self.file_name, 1) + self.assertEqual(linecache.getline(self.file_name, 1), '') def test_getlines(self): - self.assertRaises((SyntaxError, UnicodeDecodeError), - linecache.getlines, self.file_name) + self.assertEqual(linecache.getlines(self.file_name), []) class EmptyFile(GetLineTestsGoodData, unittest.TestCase): @@ -92,9 +90,11 @@ class SingleEmptyLine(GetLineTestsGoodData, unittest.TestCase): class GoodUnicode(GetLineTestsGoodData, unittest.TestCase): file_list = ['á\n', 'b\n', 'abcdef\n', 'ááááá\n'] +class BadUnicode_NoDeclaration(GetLineTestsBadData, unittest.TestCase): + file_byte_string = b'\n\x80abc' -class BadUnicode(GetLineTestsBadData, unittest.TestCase): - file_byte_string = b'\x80abc' +class BadUnicode_WithDeclaration(GetLineTestsBadData, unittest.TestCase): + file_byte_string = b'# coding=utf-8\n\x80abc' class LineCacheTests(unittest.TestCase): |