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