gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265)

This commit is contained in:
Nikita Sobolev 2023-09-12 09:37:42 +03:00 committed by GitHub
parent 8c813faf86
commit 1110c5bc82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 40 additions and 25 deletions

View file

@ -132,7 +132,9 @@ class PyCompileTestsBase:
os.chmod(self.directory, mode.st_mode)
def test_bad_coding(self):
bad_coding = os.path.join(os.path.dirname(__file__), 'bad_coding2.py')
bad_coding = os.path.join(os.path.dirname(__file__),
'tokenizedata',
'bad_coding2.py')
with support.captured_stderr():
self.assertIsNone(py_compile.compile(bad_coding, doraise=False))
self.assertFalse(os.path.exists(
@ -195,7 +197,9 @@ class PyCompileTestsBase:
self.assertEqual(flags, 0b1)
def test_quiet(self):
bad_coding = os.path.join(os.path.dirname(__file__), 'bad_coding2.py')
bad_coding = os.path.join(os.path.dirname(__file__),
'tokenizedata',
'bad_coding2.py')
with support.captured_stderr() as stderr:
self.assertIsNone(py_compile.compile(bad_coding, doraise=False, quiet=2))
self.assertIsNone(py_compile.compile(bad_coding, doraise=True, quiet=2))
@ -260,14 +264,18 @@ class PyCompileCLITestCase(unittest.TestCase):
self.assertTrue(os.path.exists(self.cache_path))
def test_bad_syntax(self):
bad_syntax = os.path.join(os.path.dirname(__file__), 'badsyntax_3131.py')
bad_syntax = os.path.join(os.path.dirname(__file__),
'tokenizedata',
'badsyntax_3131.py')
rc, stdout, stderr = self.pycompilecmd_failure(bad_syntax)
self.assertEqual(rc, 1)
self.assertEqual(stdout, b'')
self.assertIn(b'SyntaxError', stderr)
def test_bad_syntax_with_quiet(self):
bad_syntax = os.path.join(os.path.dirname(__file__), 'badsyntax_3131.py')
bad_syntax = os.path.join(os.path.dirname(__file__),
'tokenizedata',
'badsyntax_3131.py')
rc, stdout, stderr = self.pycompilecmd_failure('-q', bad_syntax)
self.assertEqual(rc, 1)
self.assertEqual(stdout, b'')