Skip to content

Commit 6bb18bb

Browse files
authored
[3.11] gh-108303: Fix and move badsyntax_pep3120.py (GH-109513) (#109724)
* [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]>
1 parent 567c3e8 commit 6bb18bb

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Lib/test/.ruff.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ select = [
33
"F811", # Redefinition of unused variable (useful for finding test methods with the same name)
44
]
55
extend-exclude = [
6+
# Excluded (these aren't actually executed, they're just "data files")
7+
"tokenizedata/*.py",
68
# Failed to lint
7-
"badsyntax_pep3120.py",
89
"encoded_modules/module_iso_8859_1.py",
910
"encoded_modules/module_koi8_r.py",
1011
"test_source_encoding.py",
1112
# Failed to parse
12-
"badsyntax_3131.py",
1313
"test_fstring.py",
1414
# TODO Fix: F811 Redefinition of unused name
1515
"test_buffer.py",

Lib/test/test_imp.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_find_module_encoding(self):
7878
with imp.find_module('module_' + mod, self.test_path)[0] as fd:
7979
self.assertEqual(fd.encoding, encoding)
8080

81-
path = [os.path.dirname(__file__)]
81+
path = [os.path.join(os.path.dirname(__file__), 'tokenizedata')]
8282
with self.assertRaises(SyntaxError):
8383
imp.find_module('badsyntax_pep3120', path)
8484

@@ -203,9 +203,11 @@ def test_issue5604(self):
203203
os_helper.rmtree('__pycache__')
204204

205205
def test_issue9319(self):
206-
path = os.path.dirname(__file__)
206+
path = os.path.join(os.path.dirname(__file__), "tokenizedata")
207207
self.assertRaises(SyntaxError,
208-
imp.find_module, "badsyntax_pep3120", [path])
208+
imp.find_module,
209+
"badsyntax_pep3120",
210+
[path])
209211

210212
def test_load_from_source(self):
211213
# Verify that the imp module can correctly load and find .py files

Lib/test/test_utf8source.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
2-
31
import unittest
42

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

1715
def test_badsyntax(self):
1816
try:
19-
import test.badsyntax_pep3120
17+
import test.tokenizedata.badsyntax_pep3120
2018
except SyntaxError as msg:
2119
msg = str(msg).lower()
2220
self.assertTrue('utf-8' in msg)

0 commit comments

Comments
 (0)