ยปCore Development>Code coverage>Lib/distutils/tests/test_build.py

Python code coverage for Lib/distutils/tests/test_build.py

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