| 1 |
"""Tests for distutils.command.build.""" |
| 2 |
import unittest |
| 3 |
import os |
| 4 |
import sys |
| 5 |
|
| 6 |
from distutils.command.build import build |
| 7 |
from distutils.tests import support |
| 8 |
from sysconfig import get_platform |
| 9 |
|
| 10 |
class BuildTestCase(support.TempdirManager, |
| 11 |
support.LoggingSilencer, |
| 12 |
unittest.TestCase): |
| 13 |
|
| 14 |
@unittest.skipUnless(sys.executable, "test requires sys.executable") |
| 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-%d.%d' % (cmd.plat_name, *sys.version_info[:2]) |
| 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, |
| 46 |
'scripts-%d.%d' % sys.version_info[:2]) |
| 47 |
self.assertEqual(cmd.build_scripts, wanted) |
| 48 |
|
| 49 |
|
| 50 |
self.assertEqual(cmd.executable, os.path.normpath(sys.executable)) |
| 51 |
|
| 52 |
if __name__ == "__main__": |
| 53 |
unittest.main() |