mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.11] gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265) (#109678)
* gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265) (cherry picked from commit1110c5bc82) * gh-108303: Add `Lib/test/tokenizedata` to `TESTSUBDIRS` (#109314) (cherry picked from commit42ab2cbd7b) --------- Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
37b261799b
commit
8d99502aac
18 changed files with 40 additions and 24 deletions
|
|
@ -2493,16 +2493,17 @@ def tarfilecmd_failure(self, *args):
|
|||
return script_helper.assert_python_failure('-m', 'tarfile', *args)
|
||||
|
||||
def make_simple_tarfile(self, tar_name):
|
||||
files = [support.findfile('tokenize_tests.txt'),
|
||||
files = [support.findfile('tokenize_tests.txt',
|
||||
subdir='tokenizedata'),
|
||||
support.findfile('tokenize_tests-no-coding-cookie-'
|
||||
'and-utf8-bom-sig-only.txt')]
|
||||
'and-utf8-bom-sig-only.txt',
|
||||
subdir='tokenizedata')]
|
||||
self.addCleanup(os_helper.unlink, tar_name)
|
||||
with tarfile.open(tar_name, 'w') as tf:
|
||||
for tardata in files:
|
||||
tf.add(tardata, arcname=os.path.basename(tardata))
|
||||
|
||||
def make_evil_tarfile(self, tar_name):
|
||||
files = [support.findfile('tokenize_tests.txt')]
|
||||
self.addCleanup(os_helper.unlink, tar_name)
|
||||
with tarfile.open(tar_name, 'w') as tf:
|
||||
benign = tarfile.TarInfo('benign')
|
||||
|
|
@ -2583,9 +2584,11 @@ def test_list_command_invalid_file(self):
|
|||
self.assertEqual(rc, 1)
|
||||
|
||||
def test_create_command(self):
|
||||
files = [support.findfile('tokenize_tests.txt'),
|
||||
files = [support.findfile('tokenize_tests.txt',
|
||||
subdir='tokenizedata'),
|
||||
support.findfile('tokenize_tests-no-coding-cookie-'
|
||||
'and-utf8-bom-sig-only.txt')]
|
||||
'and-utf8-bom-sig-only.txt',
|
||||
subdir='tokenizedata')]
|
||||
for opt in '-c', '--create':
|
||||
try:
|
||||
out = self.tarfilecmd(opt, tmpname, *files)
|
||||
|
|
@ -2596,9 +2599,11 @@ def test_create_command(self):
|
|||
os_helper.unlink(tmpname)
|
||||
|
||||
def test_create_command_verbose(self):
|
||||
files = [support.findfile('tokenize_tests.txt'),
|
||||
files = [support.findfile('tokenize_tests.txt',
|
||||
subdir='tokenizedata'),
|
||||
support.findfile('tokenize_tests-no-coding-cookie-'
|
||||
'and-utf8-bom-sig-only.txt')]
|
||||
'and-utf8-bom-sig-only.txt',
|
||||
subdir='tokenizedata')]
|
||||
for opt in '-v', '--verbose':
|
||||
try:
|
||||
out = self.tarfilecmd(opt, '-c', tmpname, *files,
|
||||
|
|
@ -2610,7 +2615,7 @@ def test_create_command_verbose(self):
|
|||
os_helper.unlink(tmpname)
|
||||
|
||||
def test_create_command_dotless_filename(self):
|
||||
files = [support.findfile('tokenize_tests.txt')]
|
||||
files = [support.findfile('tokenize_tests.txt', subdir='tokenizedata')]
|
||||
try:
|
||||
out = self.tarfilecmd('-c', dotlessname, *files)
|
||||
self.assertEqual(out, b'')
|
||||
|
|
@ -2621,7 +2626,7 @@ def test_create_command_dotless_filename(self):
|
|||
|
||||
def test_create_command_dot_started_filename(self):
|
||||
tar_name = os.path.join(TEMPDIR, ".testtar")
|
||||
files = [support.findfile('tokenize_tests.txt')]
|
||||
files = [support.findfile('tokenize_tests.txt', subdir='tokenizedata')]
|
||||
try:
|
||||
out = self.tarfilecmd('-c', tar_name, *files)
|
||||
self.assertEqual(out, b'')
|
||||
|
|
@ -2631,9 +2636,11 @@ def test_create_command_dot_started_filename(self):
|
|||
os_helper.unlink(tar_name)
|
||||
|
||||
def test_create_command_compressed(self):
|
||||
files = [support.findfile('tokenize_tests.txt'),
|
||||
files = [support.findfile('tokenize_tests.txt',
|
||||
subdir='tokenizedata'),
|
||||
support.findfile('tokenize_tests-no-coding-cookie-'
|
||||
'and-utf8-bom-sig-only.txt')]
|
||||
'and-utf8-bom-sig-only.txt',
|
||||
subdir='tokenizedata')]
|
||||
for filetype in (GzipTest, Bz2Test, LzmaTest):
|
||||
if not filetype.open:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue