summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/modules/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/test/modules/common.py')
-rw-r--r--lib/spack/spack/test/modules/common.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/spack/spack/test/modules/common.py b/lib/spack/spack/test/modules/common.py
new file mode 100644
index 0000000000..b13a65a62e
--- /dev/null
+++ b/lib/spack/spack/test/modules/common.py
@@ -0,0 +1,53 @@
+##############################################################################
+# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+
+import spack.modules.common
+
+
+def test_update_dictionary_extending_list():
+ target = {
+ 'foo': {
+ 'a': 1,
+ 'b': 2,
+ 'd': 4
+ },
+ 'bar': [1, 2, 4],
+ 'baz': 'foobar'
+ }
+ update = {
+ 'foo': {
+ 'c': 3,
+ },
+ 'bar': [3],
+ 'baz': 'foobaz',
+ 'newkey': {
+ 'd': 4
+ }
+ }
+ spack.modules.common.update_dictionary_extending_lists(target, update)
+ assert len(target) == 4
+ assert len(target['foo']) == 4
+ assert len(target['bar']) == 4
+ assert target['baz'] == 'foobaz'