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