[Python-checkins] cpython: skip more tests in packaging if threading is not supported

tarek.ziade python-checkins at python.org
Mon May 23 00:41:35 CEST 2011


http://hg.python.org/cpython/rev/e2e00f45fc3b
changeset:   70280:e2e00f45fc3b
user:        Tarek Ziade <tarek at ziade.org>
date:        Mon May 23 00:41:27 2011 +0200
summary:
  skip more tests in packaging if threading is not supported

files:
  Lib/packaging/tests/test_command_upload.py |  8 +++++++-
  Lib/packaging/tests/test_pypi_dist.py      |  8 +++++++-
  Lib/packaging/tests/test_pypi_xmlrpc.py    |  7 ++++++-
  3 files changed, 20 insertions(+), 3 deletions(-)


diff --git a/Lib/packaging/tests/test_command_upload.py b/Lib/packaging/tests/test_command_upload.py
--- a/Lib/packaging/tests/test_command_upload.py
+++ b/Lib/packaging/tests/test_command_upload.py
@@ -7,7 +7,12 @@
 from packaging.errors import PackagingOptionError
 
 from packaging.tests import unittest, support
-from packaging.tests.pypi_server import PyPIServer, PyPIServerTestCase
+try:
+    import threading
+    from packaging.tests.pypi_server import PyPIServerTestCase
+except ImportError:
+    threading = None
+    PyPIServerTestCase = unittest.TestCase
 
 
 PYPIRC_NOPASSWORD = """\
@@ -39,6 +44,7 @@
 """
 
 
+ at unittest.skipIf(threading is None, 'needs threading')
 class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
                      support.LoggingCatcher, PyPIServerTestCase):
 
diff --git a/Lib/packaging/tests/test_pypi_dist.py b/Lib/packaging/tests/test_pypi_dist.py
--- a/Lib/packaging/tests/test_pypi_dist.py
+++ b/Lib/packaging/tests/test_pypi_dist.py
@@ -8,7 +8,11 @@
 
 from packaging.tests import unittest
 from packaging.tests.support import TempdirManager, requires_zlib
-from packaging.tests.pypi_server import use_pypi_server
+try:
+    import threading
+    from packaging.tests.pypi_server import use_pypi_server
+except ImportError:
+    threading = use_pypi_server = None
 
 
 def Dist(*args, **kwargs):
@@ -120,6 +124,7 @@
         # assert we can't compare dists with different names
         self.assertRaises(TypeError, foo1.__eq__, bar)
 
+    @unittest.skipIf(threading is None, 'needs threading')
     @use_pypi_server("downloads_with_md5")
     def test_download(self, server):
         # Download is possible, and the md5 is checked if given
@@ -158,6 +163,7 @@
                           hashname="invalid_hashname",
                           hashval="value")
 
+    @unittest.skipIf(threading is None, 'needs threading')
     @requires_zlib
     @use_pypi_server('downloads_with_md5')
     def test_unpack(self, server):
diff --git a/Lib/packaging/tests/test_pypi_xmlrpc.py b/Lib/packaging/tests/test_pypi_xmlrpc.py
--- a/Lib/packaging/tests/test_pypi_xmlrpc.py
+++ b/Lib/packaging/tests/test_pypi_xmlrpc.py
@@ -9,7 +9,12 @@
     from packaging.tests.pypi_server import use_xmlrpc_server
 except ImportError:
     threading = None
-    use_xmlrpc_server = None
+    def use_xmlrpc_server():
+        def _use(func):
+            def __use(*args, **kw):
+                return func(*args, **kw)
+            return __use
+        return _use
 
 
 @unittest.skipIf(threading is None, "Needs threading")

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list