summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Forrington <nick.forrington@gmail.com>2019-03-12 20:12:51 -0500
committerAdam J. Stewart <ajstewart426@gmail.com>2019-03-12 20:12:51 -0500
commit6bda37f542cbaeb92855cf39ec2c961b95dadcb2 (patch)
tree10f258309ed25b58b04a5dd094dd270252ff54df /lib
parentda28b592fc96b97688cdb22880918859b9708537 (diff)
downloadspack-6bda37f542cbaeb92855cf39ec2c961b95dadcb2.tar.gz
spack-6bda37f542cbaeb92855cf39ec2c961b95dadcb2.tar.bz2
spack-6bda37f542cbaeb92855cf39ec2c961b95dadcb2.tar.xz
spack-6bda37f542cbaeb92855cf39ec2c961b95dadcb2.zip
Fix clearing EnvironmentModifications with python2 (#10791)
* Fix clearing EnvironmentModifications with python2 * Add EnvironmentModifications::clear unit test Use re-assignment rather than del to clear array * Fix flake issues
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/environment_modifications.py7
-rw-r--r--lib/spack/spack/util/environment.py2
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/spack/spack/test/environment_modifications.py b/lib/spack/spack/test/environment_modifications.py
index 4d2d179b10..a54d9d82aa 100644
--- a/lib/spack/spack/test/environment_modifications.py
+++ b/lib/spack/spack/test/environment_modifications.py
@@ -306,3 +306,10 @@ def test_preserve_environment(prepare_environment_for_tests):
assert 'NOT_SET' not in os.environ
assert os.environ['UNSET_ME'] == 'foo'
assert os.environ['PATH_LIST'] == '/path/second:/path/third'
+
+
+def test_clear(env):
+ env.set('A', 'dummy value')
+ assert len(env) > 0
+ env.clear()
+ assert len(env) == 0
diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py
index 14e4c06501..c7ea4d67f4 100644
--- a/lib/spack/spack/util/environment.py
+++ b/lib/spack/spack/util/environment.py
@@ -353,7 +353,7 @@ class EnvironmentModifications(object):
"""
Clears the current list of modifications
"""
- self.env_modifications.clear()
+ self.env_modifications = []
def apply_modifications(self):
"""Applies the modifications and clears the list."""