diff options
author | Steven Knight <knight@baldmt.com> | 2002-05-06 21:58:02 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-05-06 21:58:02 (GMT) |
commit | 06b66d7da2547d860be7a124c54d3ddf2ee964e1 (patch) | |
tree | 21723d271fcc503c4057bb2c8164751d86c159e0 /src | |
parent | 7f24756809ba8ae0c2aa27e8ba8f906b7fef1d3d (diff) | |
download | SCons-06b66d7da2547d860be7a124c54d3ddf2ee964e1.zip SCons-06b66d7da2547d860be7a124c54d3ddf2ee964e1.tar.gz SCons-06b66d7da2547d860be7a124c54d3ddf2ee964e1.tar.bz2 |
Follow-on to Append() functionality: generalize the type tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Environment.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 32 |
2 files changed, 31 insertions, 17 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 432c394..c5f3407 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -201,16 +201,14 @@ class Environment: for key in kw.keys(): if not self._dict.has_key(key): self._dict[key] = kw[key] - elif type(self._dict[key]) is type(kw[key]): - self._dict[key] = self._dict[key] + kw[key] + elif SCons.Util.is_List(self._dict[key]) and not \ + SCons.Util.is_List(kw[key]): + self._dict[key] = self._dict[key] + [ kw[key] ] + elif SCons.Util.is_List(kw[key]) and not \ + SCons.Util.is_List(self._dict[key]): + self._dict[key] = [ self._dict[key] ] + kw[key] else: - l1 = self._dict[key] - if not SCons.Util.is_List(l1): - l1 = [l1] - l2 = kw[key] - if not SCons.Util.is_List(l2): - l2 = [l2] - self._dict[key] = l1 + l2 + self._dict[key] = self._dict[key] + kw[key] def Depends(self, target, dependency): """Explicity specify that 'target's depend on 'dependency'.""" diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index d1c5aa8..f16632d 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -253,14 +253,30 @@ class EnvironmentTestCase(unittest.TestCase): def test_Append(self): """Test appending to construction variables in an Environment """ - env1 = Environment(AAA = 'a', BBB = 'b', CCC = 'c', - DDD = ['d'], EEE = ['e'], FFF = ['f']) - env1.Append(BBB = 'B', CCC = ['C'], EEE = 'E', FFF = ['F'], - GGG = 'g', HHH = ['h']) - env2 = Environment(AAA = 'a', BBB = 'bB', CCC = ['c', 'C'], - DDD = ['d'], EEE = ['e', 'E'], FFF = ['f', 'F'], - GGG = 'g', HHH = ['h']) - assert env1 == env2 + import UserList + UL = UserList.UserList + env1 = Environment(AAA = 'a', BBB = 'b', CCC = 'c', DDD = 'd', + EEE = ['e'], FFF = ['f'], GGG = ['g'], HHH = ['h'], + III = UL(['i']), JJJ = UL(['j']), + KKK = UL(['k']), LLL = UL(['l'])) + env1.Append(BBB = 'B', CCC = ['C'], DDD = UL(['D']), + FFF = 'F', GGG = ['G'], HHH = UL(['H']), + JJJ = 'J', KKK = ['K'], LLL = UL(['L'])) + env2 = Environment(AAA = 'a', BBB = 'bB', + CCC = ['c', 'C'], DDD = UL(['d', 'D']), + EEE = ['e'], FFF = ['f', 'F'], + GGG = ['g', 'G'], HHH = UL(['h', 'H']), + III = UL(['i']), JJJ = UL(['j', 'J']), + KKK = UL(['k', 'K']), LLL = UL(['l', 'L'])) + assert env1 == env2, env1._dict + + env3 = Environment(X = {'x' : 7}) + try: + env3.Append(X = {'x' : 8}) + except TypeError: + pass + except: + raise def test_Depends(self): """Test the explicit Depends method.""" |