aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguyroz <none@none>2011-09-16 23:10:06 +0300
committerguyroz <none@none>2011-09-16 23:10:06 +0300
commit4593c7e5cdc0e467a1c1957a0c864db804c4147a (patch)
tree8e981c23e015353d2c2c645100d2c7574be3d9b4
parent0da4543c2641cb04affb1d9b9e1d15f6e4f3fbea (diff)
downloadexternal_python_setuptools-4593c7e5cdc0e467a1c1957a0c864db804c4147a.tar.gz
external_python_setuptools-4593c7e5cdc0e467a1c1957a0c864db804c4147a.tar.bz2
external_python_setuptools-4593c7e5cdc0e467a1c1957a0c864db804c4147a.zip
Issue #237: fixing test on Python2.3
Added an _assertIn method (copied from a more recent version of unittest) and replaced the calls to assertTrue, which does not exist in Python 2.3 --HG-- branch : distribute extra : rebase_source : a8ba9e47fdcbc2dbee8e801b5d1d5d84c989266f
-rw-r--r--setuptools/tests/test_resources.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index c10ca210..227ecfdf 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -8,6 +8,16 @@ try: frozenset
except NameError:
from sets import ImmutableSet as frozenset
+def safe_repr(obj, short=False):
+ """ copied from Python2.7"""
+ try:
+ result = repr(obj)
+ except Exception:
+ result = object.__repr__(obj)
+ if not short or len(result) < _MAX_LENGTH:
+ return result
+ return result[:_MAX_LENGTH] + ' [truncated]...'
+
class Metadata(EmptyProvider):
"""Mock object to return metadata as if from an on-disk distribution"""
@@ -580,6 +590,13 @@ class NamespaceTests(TestCase):
pkg_resources._namespace_packages = self._ns_pkgs.copy()
sys.path = self._prev_sys_path[:]
+ def _assertIn(self, member, container):
+ """ assertIn and assertTrue does not exist in Python2.3"""
+ if member not in container:
+ standardMsg = '%s not found in %s' % (safe_repr(member),
+ safe_repr(container))
+ self.fail(self._formatMessage(msg, standardMsg))
+
def test_two_levels_deep(self):
"""
Test nested namespace packages
@@ -603,13 +620,13 @@ class NamespaceTests(TestCase):
pkg2_init.write(ns_str)
pkg2_init.close()
import pkg1
- self.assertTrue("pkg1" in pkg_resources._namespace_packages.keys())
+ self._assertIn("pkg1", pkg_resources._namespace_packages.keys())
try:
import pkg1.pkg2
except ImportError, e:
self.fail("Distribute tried to import the parent namespace package")
# check the _namespace_packages dict
- self.assertTrue("pkg1.pkg2" in pkg_resources._namespace_packages.keys())
+ self._assertIn("pkg1.pkg2", pkg_resources._namespace_packages.keys())
self.assertEqual(pkg_resources._namespace_packages["pkg1"], ["pkg1.pkg2"])
# check the __path__ attribute contains both paths
self.assertEqual(pkg1.pkg2.__path__, [