class _ListOption(UserList.UserList):
- def __init__(self, allowedElems, initlist):
+ def __init__(self, initlist=[], allowedElems=[]):
UserList.UserList.__init__(self, filter(None, initlist))
self.allowedElems = allowedElems[:]
self.allowedElems.sort()
if notAllowed:
raise ValueError("Invalid value(s) for option: %s" %
string.join(notAllowed, ','))
- return _ListOption(allowedElems, val)
+ return _ListOption(val, allowedElems)
## def _validator(key, val, env):
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import copy
import sys
import unittest
caught = 1
assert caught, "did not catch expected ValueError"
+ def test_copy(self):
+ """Test copying a ListOption like an Environment would"""
+ opts = SCons.Options.Options()
+ opts.Add(SCons.Options.ListOption('test', 'test option help', 'all',
+ ['one', 'two', 'three']))
+
+ o = opts.options[0]
+
+ l = o.converter('all')
+ n = l.__class__(copy.copy(l))
if __name__ == "__main__":
suite = unittest.makeSuite(ListOptionTestCase, 'test_')
class CallableComposite(UserList.UserList):
"""A simple composite callable class that, when called, will invoke all
of its contained callables with the same arguments."""
- def __init__(self, seq = []):
- UserList.UserList.__init__(self, seq)
-
def __call__(self, *args, **kwargs):
retvals = map(lambda x, args=args, kwargs=kwargs: apply(x,
args,
>>> someList.strip()
[ 'foo', 'bar' ]
"""
- def __init__(self, seq = []):
- UserList.UserList.__init__(self, seq)
-
def __nonzero__(self):
return len(self.data) != 0
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that setting Options in an Environment doesn't prevent the
+Environment from being copied.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+gpib_options = ['NI_GPIB', 'NI_ENET']
+gpib_include = '/'
+
+#0.96 broke copying ListOptions ???
+opts = Options('config.py', ARGUMENTS)
+opts.AddOptions(
+ BoolOption('gpib', 'enable gpib support', 1),
+ ListOption('gpib_options',
+ 'whether and what kind of gpib support shall be enabled',
+ 'all',
+ gpib_options),
+ )
+env = Environment(options = opts, CPPPATH = ['#/'])
+new_env=env.Copy()
+""")
+
+test.run(arguments = '.')
+
+test.pass_test()