[Python-checkins] distutils2: Make "python test_config.py" work. See explanation in the diff.

tarek.ziade python-checkins at python.org
Sun Dec 26 14:21:44 CET 2010


tarek.ziade pushed df8727953b8a to distutils2:

http://hg.python.org/distutils2/rev/df8727953b8a
changeset:   832:df8727953b8a
user:        ?ric Araujo <merwok at netwok.org>
date:        Tue Nov 16 05:38:40 2010 +0100
summary:
  Make "python test_config.py" work.  See explanation in the diff.

files:
  distutils2/tests/test_config.py

diff --git a/distutils2/tests/test_config.py b/distutils2/tests/test_config.py
--- a/distutils2/tests/test_config.py
+++ b/distutils2/tests/test_config.py
@@ -74,7 +74,7 @@
 
 [global]
 commands =
-    distutils2.tests.test_config.Foo
+    distutils2.tests.test_config.FooBarBazTest
 
 compilers =
     distutils2.tests.test_config.DCompiler
@@ -99,7 +99,7 @@
     content['metadata']['version'] += '.dev1'
 
 
-class Foo(object):
+class FooBarBazTest(object):
 
     def __init__(self, dist):
         self.distribution = dist
@@ -193,8 +193,15 @@
              ('/etc/init.d ', ['init-script'])])
         self.assertEqual(dist.package_dir['two'], 'src')
 
-        # make sure we get the foo command loaded !
-        self.assertTrue(isinstance(dist.get_command_obj('foo'), Foo))
+        # Make sure we get the foo command loaded.  We use a string comparison
+        # instead of assertIsInstance because the class is not the same when
+        # this test is run directly: foo is distutils2.tests.test_config.Foo
+        # because get_command_class uses the full name, but a bare "Foo" in
+        # this file would be __main__.Foo when run as "python test_config.py".
+        # The name FooBarBazTest should be unique enough to prevent
+        # collisions.
+        self.assertEqual(dist.get_command_obj('foo').__class__.__name__,
+                         'FooBarBazTest')
 
         # did the README got loaded ?
         self.assertEquals(dist.metadata['description'], 'yeah')

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


More information about the Python-checkins mailing list