/Lib/distutils/tests/test_install.py

http://unladen-swallow.googlecode.com/ · Python · 55 lines · 36 code · 14 blank · 5 comment · 1 complexity · ff65f5ded95f5d40ed324dcde75a9dda MD5 · raw file

  1. """Tests for distutils.command.install."""
  2. import os
  3. import unittest
  4. from distutils.command.install import install
  5. from distutils.core import Distribution
  6. from distutils.tests import support
  7. class InstallTestCase(support.TempdirManager, unittest.TestCase):
  8. def test_home_installation_scheme(self):
  9. # This ensure two things:
  10. # - that --home generates the desired set of directory names
  11. # - test --home is supported on all platforms
  12. builddir = self.mkdtemp()
  13. destination = os.path.join(builddir, "installation")
  14. dist = Distribution({"name": "foopkg"})
  15. # script_name need not exist, it just need to be initialized
  16. dist.script_name = os.path.join(builddir, "setup.py")
  17. dist.command_obj["build"] = support.DummyCommand(
  18. build_base=builddir,
  19. build_lib=os.path.join(builddir, "lib"),
  20. )
  21. cmd = install(dist)
  22. cmd.home = destination
  23. cmd.ensure_finalized()
  24. self.assertEqual(cmd.install_base, destination)
  25. self.assertEqual(cmd.install_platbase, destination)
  26. def check_path(got, expected):
  27. got = os.path.normpath(got)
  28. expected = os.path.normpath(expected)
  29. self.assertEqual(got, expected)
  30. libdir = os.path.join(destination, "lib", "python")
  31. check_path(cmd.install_lib, libdir)
  32. check_path(cmd.install_platlib, libdir)
  33. check_path(cmd.install_purelib, libdir)
  34. check_path(cmd.install_headers,
  35. os.path.join(destination, "include", "python", "foopkg"))
  36. check_path(cmd.install_scripts, os.path.join(destination, "bin"))
  37. check_path(cmd.install_data, destination)
  38. def test_suite():
  39. return unittest.makeSuite(InstallTestCase)
  40. if __name__ == "__main__":
  41. unittest.main(defaultTest="test_suite")