Skip to content

Commit

Permalink
[3.11] gh-108303: Fix and move badsyntax_pep3120.py (GH-109513) (#1…
Browse files Browse the repository at this point in the history
…09724)

* [3.11] gh-108303: Fix and move `badsyntax_pep3120.py` (GH-109513)

Co-authored-by: Alex Waygood <[email protected]>.
(cherry picked from commit 4dd47c6)

Backport to 3.11: update also test_imp.

Co-authored-by: Nikita Sobolev <[email protected]>
  • Loading branch information
sobolevn authored Sep 22, 2023
1 parent 567c3e8 commit 6bb18bb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Lib/test/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ select = [
"F811", # Redefinition of unused variable (useful for finding test methods with the same name)
]
extend-exclude = [
# Excluded (these aren't actually executed, they're just "data files")
"tokenizedata/*.py",
# Failed to lint
"badsyntax_pep3120.py",
"encoded_modules/module_iso_8859_1.py",
"encoded_modules/module_koi8_r.py",
"test_source_encoding.py",
# Failed to parse
"badsyntax_3131.py",
"test_fstring.py",
# TODO Fix: F811 Redefinition of unused name
"test_buffer.py",
Expand Down
8 changes: 5 additions & 3 deletions Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_find_module_encoding(self):
with imp.find_module('module_' + mod, self.test_path)[0] as fd:
self.assertEqual(fd.encoding, encoding)

path = [os.path.dirname(__file__)]
path = [os.path.join(os.path.dirname(__file__), 'tokenizedata')]
with self.assertRaises(SyntaxError):
imp.find_module('badsyntax_pep3120', path)

Expand Down Expand Up @@ -203,9 +203,11 @@ def test_issue5604(self):
os_helper.rmtree('__pycache__')

def test_issue9319(self):
path = os.path.dirname(__file__)
path = os.path.join(os.path.dirname(__file__), "tokenizedata")
self.assertRaises(SyntaxError,
imp.find_module, "badsyntax_pep3120", [path])
imp.find_module,
"badsyntax_pep3120",
[path])

def test_load_from_source(self):
# Verify that the imp module can correctly load and find .py files
Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_utf8source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.

import unittest

class PEP3120Test(unittest.TestCase):
Expand All @@ -16,7 +14,7 @@ def test_pep3120(self):

def test_badsyntax(self):
try:
import test.badsyntax_pep3120
import test.tokenizedata.badsyntax_pep3120
except SyntaxError as msg:
msg = str(msg).lower()
self.assertTrue('utf-8' in msg)
Expand Down
File renamed without changes.

0 comments on commit 6bb18bb

Please sign in to comment.