mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
commit
ad548b8534
7 changed files with 111 additions and 47 deletions
|
@ -1,21 +1,19 @@
|
|||
"""Tests for distutils.command.sdist."""
|
||||
import os
|
||||
import tarfile
|
||||
import unittest
|
||||
import shutil
|
||||
import warnings
|
||||
import zipfile
|
||||
from os.path import join
|
||||
import sys
|
||||
import tempfile
|
||||
import warnings
|
||||
from textwrap import dedent
|
||||
|
||||
from test.support import captured_stdout, check_warnings, run_unittest
|
||||
|
||||
from distutils.command.sdist import sdist, show_formats
|
||||
from distutils.core import Distribution
|
||||
from distutils.tests.test_config import PyPIRCCommandTestCase
|
||||
from distutils.errors import DistutilsExecError, DistutilsOptionError
|
||||
from distutils.errors import DistutilsOptionError
|
||||
from distutils.spawn import find_executable
|
||||
from distutils.tests import support
|
||||
from distutils.log import WARN
|
||||
from distutils.archive_util import ARCHIVE_FORMATS
|
||||
|
||||
|
@ -346,13 +344,33 @@ class SDistTestCase(PyPIRCCommandTestCase):
|
|||
self.assertEqual(manifest[0],
|
||||
'# file GENERATED by distutils, do NOT edit')
|
||||
|
||||
@unittest.skipUnless(ZLIB_SUPPORT, "Need zlib support to run")
|
||||
def test_manifest_comments(self):
|
||||
# make sure comments don't cause exceptions or wrong includes
|
||||
contents = dedent("""\
|
||||
# bad.py
|
||||
#bad.py
|
||||
good.py
|
||||
""")
|
||||
dist, cmd = self.get_cmd()
|
||||
cmd.ensure_finalized()
|
||||
self.write_file((self.tmp_dir, cmd.manifest), contents)
|
||||
self.write_file((self.tmp_dir, 'good.py'), '# pick me!')
|
||||
self.write_file((self.tmp_dir, 'bad.py'), "# don't pick me!")
|
||||
self.write_file((self.tmp_dir, '#bad.py'), "# don't pick me!")
|
||||
cmd.run()
|
||||
self.assertEqual(cmd.filelist.files, ['good.py'])
|
||||
|
||||
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
||||
def test_manual_manifest(self):
|
||||
# check that a MANIFEST without a marker is left alone
|
||||
dist, cmd = self.get_cmd()
|
||||
cmd.ensure_finalized()
|
||||
self.write_file((self.tmp_dir, cmd.manifest), 'README.manual')
|
||||
self.write_file((self.tmp_dir, 'README.manual'),
|
||||
'This project maintains its MANIFEST file itself.')
|
||||
cmd.run()
|
||||
self.assertEqual(cmd.filelist.files, ['README.manual'])
|
||||
|
||||
f = open(cmd.manifest)
|
||||
try:
|
||||
|
@ -363,6 +381,15 @@ class SDistTestCase(PyPIRCCommandTestCase):
|
|||
|
||||
self.assertEqual(manifest, ['README.manual'])
|
||||
|
||||
archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz')
|
||||
archive = tarfile.open(archive_name)
|
||||
try:
|
||||
filenames = [tarinfo.name for tarinfo in archive]
|
||||
finally:
|
||||
archive.close()
|
||||
self.assertEqual(sorted(filenames), ['fake-1.0', 'fake-1.0/PKG-INFO',
|
||||
'fake-1.0/README.manual'])
|
||||
|
||||
def test_suite():
|
||||
return unittest.makeSuite(SDistTestCase)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue