/Lib/distutils/tests/__init__.py

http://unladen-swallow.googlecode.com/ · Python · 35 lines · 31 code · 0 blank · 4 comment · 0 complexity · 097972c10894d4998235aa240c1eb261 MD5 · raw file

  1. """Test suite for distutils.
  2. This test suite consists of a collection of test modules in the
  3. distutils.tests package. Each test module has a name starting with
  4. 'test' and contains a function test_suite(). The function is expected
  5. to return an initialized unittest.TestSuite instance.
  6. Tests for the command classes in the distutils.command package are
  7. included in distutils.tests as well, instead of using a separate
  8. distutils.command.tests package, since command identification is done
  9. by import rather than matching pre-defined names.
  10. """
  11. import os
  12. import sys
  13. import unittest
  14. here = os.path.dirname(__file__)
  15. def test_suite():
  16. suite = unittest.TestSuite()
  17. for fn in os.listdir(here):
  18. if fn.startswith("test") and fn.endswith(".py"):
  19. modname = "distutils.tests." + fn[:-3]
  20. __import__(modname)
  21. module = sys.modules[modname]
  22. suite.addTest(module.test_suite())
  23. return suite
  24. if __name__ == "__main__":
  25. unittest.main(defaultTest="test_suite")