[Python-checkins] cpython: Minor tweaks to packaging tests.
eric.araujo
python-checkins at python.org
Fri Jun 17 19:41:39 CEST 2011
http://hg.python.org/cpython/rev/e914c963ab7f
changeset: 70851:e914c963ab7f
user: Éric Araujo <merwok at netwok.org>
date: Fri Jun 17 15:47:41 2011 +0200
summary:
Minor tweaks to packaging tests.
- Move a tearDown method right after setUp
- Use assertRaises instead of reinventing it
- Skip a test instead of commenting it out, as a reminder
files:
Lib/packaging/tests/test_command_build_ext.py | 20 ++--
Lib/packaging/tests/test_pypi_dist.py | 34 +++++-----
Lib/packaging/tests/test_util.py | 8 +--
3 files changed, 28 insertions(+), 34 deletions(-)
diff --git a/Lib/packaging/tests/test_command_build_ext.py b/Lib/packaging/tests/test_command_build_ext.py
--- a/Lib/packaging/tests/test_command_build_ext.py
+++ b/Lib/packaging/tests/test_command_build_ext.py
@@ -37,6 +37,16 @@
site.USER_BASE = self.mkdtemp()
build_ext.USER_BASE = site.USER_BASE
+ def tearDown(self):
+ # Get everything back to normal
+ unload('xx')
+ sys.path.remove(self.tmp_dir)
+ if sys.version > "2.6":
+ site.USER_BASE = self.old_user_base
+ build_ext.USER_BASE = self.old_user_base
+
+ super(BuildExtTestCase, self).tearDown()
+
def _fixup_command(self, cmd):
# When Python was build with --enable-shared, -L. is not good enough
# to find the libpython<blah>.so. This is because regrtest runs it
@@ -103,16 +113,6 @@
self.assertTrue(isinstance(xx.Null(), xx.Null))
self.assertTrue(isinstance(xx.Str(), xx.Str))
- def tearDown(self):
- # Get everything back to normal
- unload('xx')
- sys.path.remove(self.tmp_dir)
- if sys.version > "2.6":
- site.USER_BASE = self.old_user_base
- build_ext.USER_BASE = self.old_user_base
-
- super(BuildExtTestCase, self).tearDown()
-
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
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
@@ -239,7 +239,6 @@
def test_prefer_final(self):
# Can order the distributions using prefer_final
-
fb10 = ReleaseInfo("FooBar", "1.0") # final distribution
fb11a = ReleaseInfo("FooBar", "1.1a1") # alpha
fb12a = ReleaseInfo("FooBar", "1.2a1") # alpha
@@ -252,22 +251,23 @@
dists.sort_releases(prefer_final=False)
self.assertEqual(fb12b, dists[0])
-# def test_prefer_source(self):
-# # Ordering support prefer_source
-# fb_source = Dist("FooBar", "1.0", type="source")
-# fb_binary = Dist("FooBar", "1.0", type="binary")
-# fb2_binary = Dist("FooBar", "2.0", type="binary")
-# dists = ReleasesList([fb_binary, fb_source])
-#
-# dists.sort_distributions(prefer_source=True)
-# self.assertEqual(fb_source, dists[0])
-#
-# dists.sort_distributions(prefer_source=False)
-# self.assertEqual(fb_binary, dists[0])
-#
-# dists.append(fb2_binary)
-# dists.sort_distributions(prefer_source=True)
-# self.assertEqual(fb2_binary, dists[0])
+ @unittest.skip('method not implemented yet')
+ def test_prefer_source(self):
+ # Ordering supports prefer_source
+ fb_source = Dist("FooBar", "1.0", type="source")
+ fb_binary = Dist("FooBar", "1.0", type="binary")
+ fb2_binary = Dist("FooBar", "2.0", type="binary")
+ dists = ReleasesList([fb_binary, fb_source])
+
+ dists.sort_distributions(prefer_source=True)
+ self.assertEqual(fb_source, dists[0])
+
+ dists.sort_distributions(prefer_source=False)
+ self.assertEqual(fb_binary, dists[0])
+
+ dists.append(fb2_binary)
+ dists.sort_distributions(prefer_source=True)
+ self.assertEqual(fb2_binary, dists[0])
def test_get_last(self):
dists = ReleasesList('Foo')
diff --git a/Lib/packaging/tests/test_util.py b/Lib/packaging/tests/test_util.py
--- a/Lib/packaging/tests/test_util.py
+++ b/Lib/packaging/tests/test_util.py
@@ -700,14 +700,8 @@
'{a**a,babar}',
'{bob,b**z}',
]
- msg = "%r is not supposed to be a valid pattern"
for pattern in invalids:
- try:
- iglob(pattern)
- except ValueError:
- continue
- else:
- self.fail(msg % pattern)
+ self.assertRaises(ValueError, iglob, pattern)
class EggInfoToDistInfoTestCase(support.TempdirManager,
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list