summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--distutils2/tests/__main__.py1
-rw-r--r--distutils2/tests/test_command_clean.py9
-rw-r--r--distutils2/tests/test_command_install_data.py2
-rw-r--r--distutils2/tests/test_command_install_dist.py9
-rw-r--r--distutils2/tests/test_command_test.py3
-rw-r--r--distutils2/tests/test_command_upload.py3
-rw-r--r--distutils2/tests/test_command_upload_docs.py6
-rw-r--r--distutils2/tests/test_create.py3
-rw-r--r--distutils2/tests/test_uninstall.py8
-rw-r--r--distutils2/tests/test_util.py28
-rw-r--r--distutils2/tests/test_version.py4
11 files changed, 32 insertions, 44 deletions
diff --git a/distutils2/tests/__main__.py b/distutils2/tests/__main__.py
index e238ed6..f9b9494 100644
--- a/distutils2/tests/__main__.py
+++ b/distutils2/tests/__main__.py
@@ -3,7 +3,6 @@
# Ripped from importlib tests, thanks Brett!
import os
-import sys
from test.test_support import reap_children, reap_threads, run_unittest
from distutils2.tests import unittest
diff --git a/distutils2/tests/test_command_clean.py b/distutils2/tests/test_command_clean.py
index 7b8effa..910628a 100644
--- a/distutils2/tests/test_command_clean.py
+++ b/distutils2/tests/test_command_clean.py
@@ -5,7 +5,8 @@ from distutils2.command.clean import clean
from distutils2.tests import unittest, support
-class cleanTestCase(support.TempdirManager, support.LoggingCatcher,
+class CleanTestCase(support.TempdirManager,
+ support.LoggingCatcher,
unittest.TestCase):
def test_simple_run(self):
@@ -23,7 +24,7 @@ class cleanTestCase(support.TempdirManager, support.LoggingCatcher,
if name == 'build_base':
continue
for f in ('one', 'two', 'three'):
- self.write_file(os.path.join(path, f))
+ self.write_file((path, f))
# let's run the command
cmd.all = True
@@ -36,13 +37,11 @@ class cleanTestCase(support.TempdirManager, support.LoggingCatcher,
'%r was not removed' % path)
# let's run the command again (should spit warnings but succeed)
- cmd.all = True
- cmd.ensure_finalized()
cmd.run()
def test_suite():
- return unittest.makeSuite(cleanTestCase)
+ return unittest.makeSuite(CleanTestCase)
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
diff --git a/distutils2/tests/test_command_install_data.py b/distutils2/tests/test_command_install_data.py
index ba93cce..3143341 100644
--- a/distutils2/tests/test_command_install_data.py
+++ b/distutils2/tests/test_command_install_data.py
@@ -62,6 +62,7 @@ class InstallDataTestCase(support.TempdirManager,
# let's try with warn_dir one
cmd.warn_dir = True
+ cmd.finalized = False
cmd.ensure_finalized()
cmd.run()
@@ -80,6 +81,7 @@ class InstallDataTestCase(support.TempdirManager,
cmd.data_files = {one: '{inst}/one', two: '{inst2}/two',
three: '{inst3}/three'}
+ cmd.finalized = False
cmd.ensure_finalized()
cmd.run()
diff --git a/distutils2/tests/test_command_install_dist.py b/distutils2/tests/test_command_install_dist.py
index 409de06..23cbd08 100644
--- a/distutils2/tests/test_command_install_dist.py
+++ b/distutils2/tests/test_command_install_dist.py
@@ -93,21 +93,20 @@ class InstallTestCase(support.TempdirManager,
self.old_expand = os.path.expanduser
os.path.expanduser = _expanduser
- try:
- # this is the actual test
- self._test_user_site()
- finally:
+ def cleanup():
_CONFIG_VARS['userbase'] = self.old_user_base
_SCHEMES.set(scheme, 'purelib', self.old_user_site)
os.path.expanduser = self.old_expand
- def _test_user_site(self):
+ self.addCleanup(cleanup)
+
schemes = get_scheme_names()
for key in ('nt_user', 'posix_user', 'os2_home'):
self.assertIn(key, schemes)
dist = Distribution({'name': 'xx'})
cmd = install_dist(dist)
+
# making sure the user option is there
options = [name for name, short, lable in
cmd.user_options]
diff --git a/distutils2/tests/test_command_test.py b/distutils2/tests/test_command_test.py
index 2b832cb..a5748fe 100644
--- a/distutils2/tests/test_command_test.py
+++ b/distutils2/tests/test_command_test.py
@@ -140,7 +140,8 @@ class TestTest(TempdirManager,
cmd.run()
self.assertEqual(['build has run'], record)
- def _test_works_with_2to3(self):
+ @unittest.skip('needs to be written')
+ def test_works_with_2to3(self):
pass
def test_checks_requires(self):
diff --git a/distutils2/tests/test_command_upload.py b/distutils2/tests/test_command_upload.py
index 76281ca..ac1ec54 100644
--- a/distutils2/tests/test_command_upload.py
+++ b/distutils2/tests/test_command_upload.py
@@ -44,6 +44,7 @@ repository:http://another.pypi/
"""
+#@skip if no threading, see end of file
class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
support.LoggingCatcher, PyPIServerTestCase):
@@ -129,7 +130,7 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
dist_files = [(command, pyversion, filename)]
docs_path = os.path.join(self.tmp_dir, "build", "docs")
os.makedirs(docs_path)
- self.write_file(os.path.join(docs_path, "index.html"), "yellow")
+ self.write_file((docs_path, "index.html"), "yellow")
self.write_file(self.rc, PYPIRC)
# let's run it
diff --git a/distutils2/tests/test_command_upload_docs.py b/distutils2/tests/test_command_upload_docs.py
index d6edc37..589e6a9 100644
--- a/distutils2/tests/test_command_upload_docs.py
+++ b/distutils2/tests/test_command_upload_docs.py
@@ -32,6 +32,7 @@ password = long_island
"""
+#@skip if no threading, see end of file
class UploadDocsTestCase(support.TempdirManager,
support.EnvironRestorer,
support.LoggingCatcher,
@@ -69,9 +70,8 @@ class UploadDocsTestCase(support.TempdirManager,
if sample_dir is None:
sample_dir = self.mkdtemp()
os.mkdir(os.path.join(sample_dir, "docs"))
- self.write_file(os.path.join(sample_dir, "docs", "index.html"),
- "Ce mortel ennui")
- self.write_file(os.path.join(sample_dir, "index.html"), "Oh la la")
+ self.write_file((sample_dir, "docs", "index.html"), "Ce mortel ennui")
+ self.write_file((sample_dir, "index.html"), "Oh la la")
return sample_dir
def test_zip_dir(self):
diff --git a/distutils2/tests/test_create.py b/distutils2/tests/test_create.py
index a268c4f..b0b488f 100644
--- a/distutils2/tests/test_create.py
+++ b/distutils2/tests/test_create.py
@@ -82,8 +82,7 @@ class CreateTestCase(support.TempdirManager,
os.mkdir(os.path.join(tempdir, dir_))
for file_ in files:
- path = os.path.join(tempdir, file_)
- self.write_file(path, 'xxx')
+ self.write_file((tempdir, file_), 'xxx')
mainprogram._find_files()
mainprogram.data['packages'].sort()
diff --git a/distutils2/tests/test_uninstall.py b/distutils2/tests/test_uninstall.py
index fc664a3..573ecdd 100644
--- a/distutils2/tests/test_uninstall.py
+++ b/distutils2/tests/test_uninstall.py
@@ -1,6 +1,5 @@
"""Tests for the distutils2.uninstall module."""
import os
-import sys
import logging
import distutils2.util
@@ -31,16 +30,12 @@ class UninstallTestCase(support.TempdirManager,
def setUp(self):
super(UninstallTestCase, self).setUp()
- self.addCleanup(setattr, sys, 'stdout', sys.stdout)
- self.addCleanup(setattr, sys, 'stderr', sys.stderr)
- self.addCleanup(os.chdir, os.getcwd())
self.addCleanup(enable_cache)
self.root_dir = self.mkdtemp()
self.cwd = os.getcwd()
disable_cache()
def tearDown(self):
- os.chdir(self.cwd)
distutils2.util._path_created.clear()
super(UninstallTestCase, self).tearDown()
@@ -61,8 +56,7 @@ class UninstallTestCase(support.TempdirManager,
kw['pkg'] = pkg
pkg_dir = os.path.join(project_dir, pkg)
- os.mkdir(pkg_dir)
- os.mkdir(os.path.join(pkg_dir, 'sub'))
+ os.makedirs(os.path.join(pkg_dir, 'sub'))
self.write_file((project_dir, 'setup.cfg'), SETUP_CFG % kw)
self.write_file((pkg_dir, '__init__.py'), '#')
diff --git a/distutils2/tests/test_util.py b/distutils2/tests/test_util.py
index 2c4b980..31a44b8 100644
--- a/distutils2/tests/test_util.py
+++ b/distutils2/tests/test_util.py
@@ -360,24 +360,20 @@ class UtilTestCase(support.EnvironRestorer,
#
root = self.mkdtemp()
pkg1 = os.path.join(root, 'pkg1')
- os.mkdir(pkg1)
- self.write_file(os.path.join(pkg1, '__init__.py'))
- os.mkdir(os.path.join(pkg1, 'pkg2'))
- self.write_file(os.path.join(pkg1, 'pkg2', '__init__.py'))
- os.mkdir(os.path.join(pkg1, 'pkg3'))
- self.write_file(os.path.join(pkg1, 'pkg3', '__init__.py'))
- os.mkdir(os.path.join(pkg1, 'pkg3', 'pkg6'))
- self.write_file(os.path.join(pkg1, 'pkg3', 'pkg6', '__init__.py'))
- os.mkdir(os.path.join(pkg1, 'pkg4'))
- os.mkdir(os.path.join(pkg1, 'pkg4', 'pkg8'))
- self.write_file(os.path.join(pkg1, 'pkg4', 'pkg8', '__init__.py'))
- pkg5 = os.path.join(root, 'pkg5')
- os.mkdir(pkg5)
- self.write_file(os.path.join(pkg5, '__init__.py'))
+ os.makedirs(os.path.join(pkg1, 'pkg2'))
+ os.makedirs(os.path.join(pkg1, 'pkg3', 'pkg6'))
+ os.makedirs(os.path.join(pkg1, 'pkg4', 'pkg8'))
+ os.makedirs(os.path.join(root, 'pkg5'))
+ self.write_file((pkg1, '__init__.py'))
+ self.write_file((pkg1, 'pkg2', '__init__.py'))
+ self.write_file((pkg1, 'pkg3', '__init__.py'))
+ self.write_file((pkg1, 'pkg3', 'pkg6', '__init__.py'))
+ self.write_file((pkg1, 'pkg4', 'pkg8', '__init__.py'))
+ self.write_file((root, 'pkg5', '__init__.py'))
res = find_packages([root], ['pkg1.pkg2'])
- self.assertEqual(set(res), set(['pkg1', 'pkg5', 'pkg1.pkg3',
- 'pkg1.pkg3.pkg6']))
+ self.assertEqual(sorted(res),
+ ['pkg1', 'pkg1.pkg3', 'pkg1.pkg3.pkg6', 'pkg5'])
def test_resolve_name(self):
# test raw module name
diff --git a/distutils2/tests/test_version.py b/distutils2/tests/test_version.py
index 1928bbd..ab4ab58 100644
--- a/distutils2/tests/test_version.py
+++ b/distutils2/tests/test_version.py
@@ -1,6 +1,5 @@
"""Tests for distutils2.version."""
import doctest
-import os
from distutils2.version import NormalizedVersion as V
from distutils2.version import HugeMajorVersionNumError, IrrationalVersionError
@@ -46,7 +45,6 @@ class VersionTestCase(unittest.TestCase):
def test_from_parts(self):
for v, s in self.versions:
- parts = v.parts
v2 = V.from_parts(*v.parts)
self.assertEqual(v, v2)
self.assertEqual(str(v), str(v2))
@@ -192,7 +190,7 @@ class VersionTestCase(unittest.TestCase):
'Hey (>=2.5,<2.7)')
for predicate in predicates:
- v = VersionPredicate(predicate)
+ VersionPredicate(predicate)
self.assertTrue(VersionPredicate('Hey (>=2.5,<2.7)').match('2.6'))
self.assertTrue(VersionPredicate('Ho').match('2.6'))