summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/test_sdist.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/tests/test_sdist.py')
-rw-r--r--Lib/distutils/tests/test_sdist.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index 9e27933..b7e5859 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -6,7 +6,9 @@ import zipfile
from os.path import join
import sys
import tempfile
+import warnings
+from test.support import check_warnings
from test.support import captured_stdout
from distutils.command.sdist import sdist
@@ -16,6 +18,7 @@ from distutils.tests.test_config import PyPIRCCommandTestCase
from distutils.errors import DistutilsExecError, DistutilsOptionError
from distutils.spawn import find_executable
from distutils.tests import support
+from distutils.log import WARN
from distutils.archive_util import ARCHIVE_FORMATS
SETUP_PY = """
@@ -38,12 +41,12 @@ somecode%(sep)sdoc.dat
somecode%(sep)sdoc.txt
"""
-class sdistTestCase(PyPIRCCommandTestCase):
+class SDistTestCase(PyPIRCCommandTestCase):
def setUp(self):
# PyPIRCCommandTestCase creates a temp dir already
# and put it in self.tmp_dir
- super(sdistTestCase, self).setUp()
+ super(SDistTestCase, self).setUp()
# setting up an environment
self.old_path = os.getcwd()
os.mkdir(join(self.tmp_dir, 'somecode'))
@@ -57,7 +60,7 @@ class sdistTestCase(PyPIRCCommandTestCase):
def tearDown(self):
# back to normal
os.chdir(self.old_path)
- super(sdistTestCase, self).tearDown()
+ super(SDistTestCase, self).tearDown()
def get_cmd(self, metadata=None):
"""Returns a cmd"""
@@ -214,6 +217,34 @@ class sdistTestCase(PyPIRCCommandTestCase):
manifest = open(join(self.tmp_dir, 'MANIFEST')).read()
self.assertEquals(manifest, MANIFEST % {'sep': os.sep})
+ def test_metadata_check_option(self):
+ # testing the `medata-check` option
+ dist, cmd = self.get_cmd(metadata={})
+
+ # this should raise some warnings !
+ # with the `check` subcommand
+ cmd.ensure_finalized()
+ cmd.run()
+ warnings = self.get_logs(WARN)
+ self.assertEquals(len(warnings), 2)
+
+ # trying with a complete set of metadata
+ self.clear_logs()
+ dist, cmd = self.get_cmd()
+ cmd.ensure_finalized()
+ cmd.metadata_check = 0
+ cmd.run()
+ warnings = self.get_logs(WARN)
+ self.assertEquals(len(warnings), 0)
+
+ def test_check_metadata_deprecated(self):
+ # makes sure make_metadata is deprecated
+ dist, cmd = self.get_cmd()
+ with check_warnings() as w:
+ warnings.simplefilter("always")
+ cmd.check_metadata()
+ self.assertEquals(len(w.warnings), 1)
+
def test_show_formats(self):
with captured_stdout() as stdout:
show_formats()
@@ -247,7 +278,7 @@ class sdistTestCase(PyPIRCCommandTestCase):
def test_suite():
- return unittest.makeSuite(sdistTestCase)
+ return unittest.makeSuite(SDistTestCase)
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")