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