Index: Lib/distutils/tests/test_build_ext.py =================================================================== --- Lib/distutils/tests/test_build_ext.py (revision 67313) +++ Lib/distutils/tests/test_build_ext.py (working copy) @@ -11,6 +11,10 @@ import unittest from test import support +# don't load and test the xx module more than once +# required to silence ref leak test +ALREADY_TESTED = False + class BuildExtTestCase(unittest.TestCase): def setUp(self): # Create a simple test environment @@ -23,6 +27,7 @@ shutil.copy(xx_c, self.tmp_dir) def test_build_ext(self): + global ALREADY_TESTED xx_c = os.path.join(self.tmp_dir, 'xxmodule.c') xx_ext = Extension('xx', [xx_c]) dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]}) @@ -45,6 +50,11 @@ finally: sys.stdout = old_stdout + if ALREADY_TESTED: + return + else: + ALREADY_TESTED = True + import xx for attr in ('error', 'foo', 'new', 'roj'):