1 | n/a | """Tests for distutils.command.build.""" |
---|
2 | n/a | import unittest |
---|
3 | n/a | import os |
---|
4 | n/a | import sys |
---|
5 | n/a | from test.support import run_unittest |
---|
6 | n/a | |
---|
7 | n/a | from distutils.command.build import build |
---|
8 | n/a | from distutils.tests import support |
---|
9 | n/a | from sysconfig import get_platform |
---|
10 | n/a | |
---|
11 | n/a | class BuildTestCase(support.TempdirManager, |
---|
12 | n/a | support.LoggingSilencer, |
---|
13 | n/a | unittest.TestCase): |
---|
14 | n/a | |
---|
15 | n/a | def test_finalize_options(self): |
---|
16 | n/a | pkg_dir, dist = self.create_dist() |
---|
17 | n/a | cmd = build(dist) |
---|
18 | n/a | cmd.finalize_options() |
---|
19 | n/a | |
---|
20 | n/a | # if not specified, plat_name gets the current platform |
---|
21 | n/a | self.assertEqual(cmd.plat_name, get_platform()) |
---|
22 | n/a | |
---|
23 | n/a | # build_purelib is build + lib |
---|
24 | n/a | wanted = os.path.join(cmd.build_base, 'lib') |
---|
25 | n/a | self.assertEqual(cmd.build_purelib, wanted) |
---|
26 | n/a | |
---|
27 | n/a | # build_platlib is 'build/lib.platform-x.x[-pydebug]' |
---|
28 | n/a | # examples: |
---|
29 | n/a | # build/lib.macosx-10.3-i386-2.7 |
---|
30 | n/a | plat_spec = '.%s-%d.%d' % (cmd.plat_name, *sys.version_info[:2]) |
---|
31 | n/a | if hasattr(sys, 'gettotalrefcount'): |
---|
32 | n/a | self.assertTrue(cmd.build_platlib.endswith('-pydebug')) |
---|
33 | n/a | plat_spec += '-pydebug' |
---|
34 | n/a | wanted = os.path.join(cmd.build_base, 'lib' + plat_spec) |
---|
35 | n/a | self.assertEqual(cmd.build_platlib, wanted) |
---|
36 | n/a | |
---|
37 | n/a | # by default, build_lib = build_purelib |
---|
38 | n/a | self.assertEqual(cmd.build_lib, cmd.build_purelib) |
---|
39 | n/a | |
---|
40 | n/a | # build_temp is build/temp.<plat> |
---|
41 | n/a | wanted = os.path.join(cmd.build_base, 'temp' + plat_spec) |
---|
42 | n/a | self.assertEqual(cmd.build_temp, wanted) |
---|
43 | n/a | |
---|
44 | n/a | # build_scripts is build/scripts-x.x |
---|
45 | n/a | wanted = os.path.join(cmd.build_base, |
---|
46 | n/a | 'scripts-%d.%d' % sys.version_info[:2]) |
---|
47 | n/a | self.assertEqual(cmd.build_scripts, wanted) |
---|
48 | n/a | |
---|
49 | n/a | # executable is os.path.normpath(sys.executable) |
---|
50 | n/a | self.assertEqual(cmd.executable, os.path.normpath(sys.executable)) |
---|
51 | n/a | |
---|
52 | n/a | def test_suite(): |
---|
53 | n/a | return unittest.makeSuite(BuildTestCase) |
---|
54 | n/a | |
---|
55 | n/a | if __name__ == "__main__": |
---|
56 | n/a | run_unittest(test_suite()) |
---|