Copy should allow you to update the construction variables.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 19 Jul 2001 12:15:37 +0000 (12:15 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 19 Jul 2001 12:15:37 +0000 (12:15 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@10 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/scons/Environment.py
src/scons/EnvironmentTests.py

index c410162b8730db6dd33c7774282bb69af4add4f5..da71ba1740fab1536649fc68977c9e794e667089 100644 (file)
@@ -79,7 +79,9 @@ class Environment:
        (like a function).  There are no references to any mutable
        objects in the original Environment.
        """
-       return copy.deepcopy(self)
+       clone = copy.deepcopy(self)
+       apply(clone.Update, (), kw)
+       return clone
 
     def Scanners(self):
        pass    # XXX
index 5c6c151f6c9e16fa28cc580ecdde85b6848bacff..5d3e1ea30e6507feb051a32840f919c8443f427b 100644 (file)
@@ -61,6 +61,9 @@ class EnvironmentTestCase(unittest.TestCase):
        Update the copy independently afterwards and check that
        the original remains intact (that is, no dangling
        references point to objects in the copied environment).
+       Copy the original with some construction variable
+       updates and check that the original remains intact
+       and the copy has the updated values.
        """
        env1 = Environment(XXX = 'x', YYY = 'y')
        env2 = env1.Copy()
@@ -69,6 +72,12 @@ class EnvironmentTestCase(unittest.TestCase):
        assert env1 != env2
        assert env1 == env1copy
 
+       env3 = env1.Copy(XXX = 'x3', ZZZ = 'z3')
+       assert env3.Dictionary['XXX'] == 'x3'
+       assert env3.Dictionary['YYY'] == 'y'
+       assert env3.Dictionary['ZZZ'] == 'z3'
+       assert env1 == env1copy
+
     def test_Dictionary(self):
        """Test the simple ability to retrieve known construction
        variables from the Dictionary and check for well-known