added a test for finalize_options

This commit is contained in:
Tarek Ziadé 2009-04-12 16:45:32 +00:00
parent f6f4b3084c
commit e643bed198
2 changed files with 21 additions and 7 deletions

View File

@ -12,7 +12,7 @@ this header file lives".
__revision__ = "$Id$"
import sys, os, string, re
from types import *
from distutils.core import Command
from distutils.errors import DistutilsExecError
from distutils.sysconfig import customize_compiler
@ -68,19 +68,18 @@ class config(Command):
def finalize_options(self):
if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or []
elif type(self.include_dirs) is StringType:
self.include_dirs = string.split(self.include_dirs, os.pathsep)
elif isinstance(self.include_dirs, str):
self.include_dirs = self.include_dirs.split(os.pathsep)
if self.libraries is None:
self.libraries = []
elif type(self.libraries) is StringType:
elif isinstance(self.libraries, str):
self.libraries = [self.libraries]
if self.library_dirs is None:
self.library_dirs = []
elif type(self.library_dirs) is StringType:
self.library_dirs = string.split(self.library_dirs, os.pathsep)
elif isinstance(self.library_dirs, str):
self.library_dirs = self.library_dirs.split(os.pathsep)
def run (self):
pass

View File

@ -46,6 +46,21 @@ class ConfigTestCase(support.LoggingSilencer,
match = cmd.search_cpp(pattern='command', body='// xxx')
self.assertEquals(match, 1)
def test_finalize_options(self):
# finalize_options does a bit of transformation
# on options
pkg_dir, dist = self.create_dist()
cmd = config(dist)
cmd.include_dirs = 'one%stwo' % os.pathsep
cmd.libraries = 'one'
cmd.library_dirs = 'three%sfour' % os.pathsep
cmd.ensure_finalized()
self.assertEquals(cmd.include_dirs, ['one', 'two'])
self.assertEquals(cmd.libraries, ['one'])
self.assertEquals(cmd.library_dirs, ['three', 'four'])
def test_suite():
return unittest.makeSuite(ConfigTestCase)