PageRenderTime 274ms CodeModel.GetById 140ms app.highlight 7ms RepoModel.GetById 124ms app.codeStats 0ms

/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
 3import os
 4import unittest
 5
 6from distutils.command.install import install
 7from distutils.core import Distribution
 8
 9from distutils.tests import support
10
11
12class 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
51def test_suite():
52    return unittest.makeSuite(InstallTestCase)
53
54if __name__ == "__main__":
55    unittest.main(defaultTest="test_suite")