Commit b4b74e36 authored by Tarek Ziadé's avatar Tarek Ziadé

added a test for finalize_options

parent 343e5f79
...@@ -12,7 +12,7 @@ this header file lives". ...@@ -12,7 +12,7 @@ this header file lives".
__revision__ = "$Id$" __revision__ = "$Id$"
import sys, os, string, re import sys, os, string, re
from types import *
from distutils.core import Command from distutils.core import Command
from distutils.errors import DistutilsExecError from distutils.errors import DistutilsExecError
from distutils.sysconfig import customize_compiler from distutils.sysconfig import customize_compiler
...@@ -68,19 +68,18 @@ class config(Command): ...@@ -68,19 +68,18 @@ class config(Command):
def finalize_options(self): def finalize_options(self):
if self.include_dirs is None: if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or [] self.include_dirs = self.distribution.include_dirs or []
elif type(self.include_dirs) is StringType: elif isinstance(self.include_dirs, str):
self.include_dirs = string.split(self.include_dirs, os.pathsep) self.include_dirs = self.include_dirs.split(os.pathsep)
if self.libraries is None: if self.libraries is None:
self.libraries = [] self.libraries = []
elif type(self.libraries) is StringType: elif isinstance(self.libraries, str):
self.libraries = [self.libraries] self.libraries = [self.libraries]
if self.library_dirs is None: if self.library_dirs is None:
self.library_dirs = [] self.library_dirs = []
elif type(self.library_dirs) is StringType: elif isinstance(self.library_dirs, str):
self.library_dirs = string.split(self.library_dirs, os.pathsep) self.library_dirs = self.library_dirs.split(os.pathsep)
def run (self): def run (self):
pass pass
......
...@@ -46,6 +46,21 @@ class ConfigTestCase(support.LoggingSilencer, ...@@ -46,6 +46,21 @@ class ConfigTestCase(support.LoggingSilencer,
match = cmd.search_cpp(pattern='command', body='// xxx') match = cmd.search_cpp(pattern='command', body='// xxx')
self.assertEquals(match, 1) 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(): def test_suite():
return unittest.makeSuite(ConfigTestCase) return unittest.makeSuite(ConfigTestCase)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment