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