Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/tests/test_install.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 8214bdb48c52 |
| children | cd0191a9b5c9 |
| rev | line source |
|---|---|
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
1 """Tests for distutils.command.install.""" |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
2 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 import os |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
4 import sys |
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
5 import unittest |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
6 import site |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
7 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
8 from test.test_support import captured_stdout, run_unittest |
|
56152
2df8bedec6d3
improved distutils test coverage: now the DEBUG mode is covered too (will help fix the issue #6954 in py3k branch)
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55593
diff
changeset
|
9 |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
10 from distutils import sysconfig |
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
11 from distutils.command.install import install |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
12 from distutils.command import install as install_module |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
13 from distutils.command.build_ext import build_ext |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
14 from distutils.command.install import INSTALL_SCHEMES |
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
15 from distutils.core import Distribution |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
16 from distutils.errors import DistutilsOptionError |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
17 from distutils.extension import Extension |
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
18 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
19 from distutils.tests import support |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
20 |
|
59343
ad22bc22dddc
reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
58450
diff
changeset
|
21 |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
22 def _make_ext_name(modname): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
23 if os.name == 'nt' and sys.executable.endswith('_d.exe'): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
24 modname += '_d' |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
25 return modname + sysconfig.get_config_var('SO') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
26 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
27 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
28 class InstallTestCase(support.TempdirManager, |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
29 support.LoggingSilencer, |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
30 unittest.TestCase): |
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
31 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
32 def test_home_installation_scheme(self): |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
33 # This ensure two things: |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
34 # - that --home generates the desired set of directory names |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
35 # - test --home is supported on all platforms |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 builddir = self.mkdtemp() |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 destination = os.path.join(builddir, "installation") |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
38 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
39 dist = Distribution({"name": "foopkg"}) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
40 # script_name need not exist, it just need to be initialized |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
41 dist.script_name = os.path.join(builddir, "setup.py") |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
42 dist.command_obj["build"] = support.DummyCommand( |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
43 build_base=builddir, |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
44 build_lib=os.path.join(builddir, "lib"), |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
45 ) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
46 |
|
59343
ad22bc22dddc
reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
58450
diff
changeset
|
47 cmd = install(dist) |
|
ad22bc22dddc
reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
58450
diff
changeset
|
48 cmd.home = destination |
|
ad22bc22dddc
reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
58450
diff
changeset
|
49 cmd.ensure_finalized() |
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
50 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
51 self.assertEqual(cmd.install_base, destination) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
52 self.assertEqual(cmd.install_platbase, destination) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
53 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
54 def check_path(got, expected): |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
55 got = os.path.normpath(got) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
56 expected = os.path.normpath(expected) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
57 self.assertEqual(got, expected) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
58 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
59 libdir = os.path.join(destination, "lib", "python") |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
60 check_path(cmd.install_lib, libdir) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
61 check_path(cmd.install_platlib, libdir) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
62 check_path(cmd.install_purelib, libdir) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
63 check_path(cmd.install_headers, |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
64 os.path.join(destination, "include", "python", "foopkg")) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
65 check_path(cmd.install_scripts, os.path.join(destination, "bin")) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
66 check_path(cmd.install_data, destination) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
67 |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
68 def test_user_site(self): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
69 # site.USER_SITE was introduced in 2.6 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
70 if sys.version < '2.6': |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
71 return |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
72 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
73 # preparing the environment for the test |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
74 self.old_user_base = site.USER_BASE |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
75 self.old_user_site = site.USER_SITE |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
76 self.tmpdir = self.mkdtemp() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
77 self.user_base = os.path.join(self.tmpdir, 'B') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
78 self.user_site = os.path.join(self.tmpdir, 'S') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
79 site.USER_BASE = self.user_base |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
80 site.USER_SITE = self.user_site |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
81 install_module.USER_BASE = self.user_base |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
82 install_module.USER_SITE = self.user_site |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
83 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
84 def _expanduser(path): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
85 return self.tmpdir |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
86 self.old_expand = os.path.expanduser |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
87 os.path.expanduser = _expanduser |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
88 |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
89 def cleanup(): |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
90 site.USER_BASE = self.old_user_base |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
91 site.USER_SITE = self.old_user_site |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
92 install_module.USER_BASE = self.old_user_base |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
93 install_module.USER_SITE = self.old_user_site |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
94 os.path.expanduser = self.old_expand |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
95 |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
96 self.addCleanup(cleanup) |
|
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
97 |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
98 for key in ('nt_user', 'unix_user', 'os2_home'): |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
99 self.assertIn(key, INSTALL_SCHEMES) |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
100 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
101 dist = Distribution({'name': 'xx'}) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
102 cmd = install(dist) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
103 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
104 # making sure the user option is there |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
105 options = [name for name, short, lable in |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
106 cmd.user_options] |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
107 self.assertIn('user', options) |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
108 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
109 # setting a value |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
110 cmd.user = 1 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
111 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
112 # user base and site shouldn't be created yet |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
113 self.assertFalse(os.path.exists(self.user_base)) |
|
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
114 self.assertFalse(os.path.exists(self.user_site)) |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
115 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
116 # let's run finalize |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
117 cmd.ensure_finalized() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
118 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
119 # now they should |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
120 self.assertTrue(os.path.exists(self.user_base)) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
121 self.assertTrue(os.path.exists(self.user_site)) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
122 |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
123 self.assertIn('userbase', cmd.config_vars) |
|
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
124 self.assertIn('usersite', cmd.config_vars) |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
125 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
126 def test_handle_extra_path(self): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
127 dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'}) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
128 cmd = install(dist) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
129 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
130 # two elements |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
131 cmd.handle_extra_path() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
132 self.assertEqual(cmd.extra_path, ['path', 'dirs']) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
133 self.assertEqual(cmd.extra_dirs, 'dirs') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
134 self.assertEqual(cmd.path_file, 'path') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
135 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
136 # one element |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
137 cmd.extra_path = ['path'] |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
138 cmd.handle_extra_path() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
139 self.assertEqual(cmd.extra_path, ['path']) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
140 self.assertEqual(cmd.extra_dirs, 'path') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
141 self.assertEqual(cmd.path_file, 'path') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
142 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
143 # none |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
144 dist.extra_path = cmd.extra_path = None |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
145 cmd.handle_extra_path() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
146 self.assertEqual(cmd.extra_path, None) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
147 self.assertEqual(cmd.extra_dirs, '') |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
148 self.assertEqual(cmd.path_file, None) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
149 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
150 # three elements (no way !) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
151 cmd.extra_path = 'path,dirs,again' |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
152 self.assertRaises(DistutilsOptionError, cmd.handle_extra_path) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
153 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
154 def test_finalize_options(self): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
155 dist = Distribution({'name': 'xx'}) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
156 cmd = install(dist) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
157 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
158 # must supply either prefix/exec-prefix/home or |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
159 # install-base/install-platbase -- not both |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
160 cmd.prefix = 'prefix' |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
161 cmd.install_base = 'base' |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
162 self.assertRaises(DistutilsOptionError, cmd.finalize_options) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
163 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
164 # must supply either home or prefix/exec-prefix -- not both |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
165 cmd.install_base = None |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
166 cmd.home = 'home' |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
167 self.assertRaises(DistutilsOptionError, cmd.finalize_options) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
168 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
169 # can't combine user with with prefix/exec_prefix/home or |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
170 # install_(plat)base |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
171 cmd.prefix = None |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
172 cmd.user = 'user' |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
173 self.assertRaises(DistutilsOptionError, cmd.finalize_options) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
174 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
175 def test_record(self): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
176 install_dir = self.mkdtemp() |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
177 project_dir, dist = self.create_dist(py_modules=['hello'], |
|
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
178 scripts=['sayhi']) |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
179 os.chdir(project_dir) |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
180 self.write_file('hello.py', "def main(): print 'o hai'") |
|
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
181 self.write_file('sayhi', 'from hello import main; main()') |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
182 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
183 cmd = install(dist) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
184 dist.command_obj['install'] = cmd |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
185 cmd.root = install_dir |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
186 cmd.record = os.path.join(project_dir, 'filelist') |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
187 cmd.ensure_finalized() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
188 cmd.run() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
189 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
190 f = open(cmd.record) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
191 try: |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
192 content = f.read() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
193 finally: |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
194 f.close() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
195 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
196 found = [os.path.basename(line) for line in content.splitlines()] |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
197 expected = ['hello.py', 'hello.pyc', 'sayhi', |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
198 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
199 self.assertEqual(found, expected) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
200 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
201 def test_record_extensions(self): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
202 install_dir = self.mkdtemp() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
203 project_dir, dist = self.create_dist(ext_modules=[ |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
204 Extension('xx', ['xxmodule.c'])]) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
205 os.chdir(project_dir) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
206 support.copy_xxmodule_c(project_dir) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
207 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
208 buildextcmd = build_ext(dist) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
209 support.fixup_build_ext(buildextcmd) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
210 buildextcmd.ensure_finalized() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
211 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
212 cmd = install(dist) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
213 dist.command_obj['install'] = cmd |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
214 dist.command_obj['build_ext'] = buildextcmd |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
215 cmd.root = install_dir |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
216 cmd.record = os.path.join(project_dir, 'filelist') |
|
72091
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
217 cmd.ensure_finalized() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
218 cmd.run() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
219 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
220 f = open(cmd.record) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
221 try: |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
222 content = f.read() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
223 finally: |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
224 f.close() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
225 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
226 found = [os.path.basename(line) for line in content.splitlines()] |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
227 expected = [_make_ext_name('xx'), |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
228 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
229 self.assertEqual(found, expected) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
230 |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
231 def test_debug_mode(self): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
232 # this covers the code called when DEBUG is set |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
233 old_logs_len = len(self.logs) |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
234 install_module.DEBUG = True |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
235 try: |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
236 with captured_stdout(): |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
237 self.test_record() |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
238 finally: |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
239 install_module.DEBUG = False |
|
28065177560e
Backport tests for the distutils install command
Éric Araujo <merwok@netwok.org>
parents:
67854
diff
changeset
|
240 self.assertTrue(len(self.logs) > old_logs_len) |
|
56152
2df8bedec6d3
improved distutils test coverage: now the DEBUG mode is covered too (will help fix the issue #6954 in py3k branch)
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55593
diff
changeset
|
241 |
|
75277
8214bdb48c52
Synchronize some distutils tests with 3.2.
Éric Araujo <merwok@netwok.org>
parents:
72091
diff
changeset
|
242 |
|
32408
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
243 def test_suite(): |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
244 return unittest.makeSuite(InstallTestCase) |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
245 |
|
e0a7c461311b
Make distutils "install --home" support all platforms.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
246 if __name__ == "__main__": |
|
67854
6270946115d0
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
59343
diff
changeset
|
247 run_unittest(test_suite()) |
