Skip to content
Permalink
Browse files

Merge pull request #990 from VisTrails/fix-config-unset-field

Fixes unset fields being missing from configuration objects
  • Loading branch information...
remram44 committed Jan 14, 2015
2 parents 76f5a15 + 34aff8a commit e2b31b4f4aa21e889f78caf07d0b1df342d7a191
Showing with 13 additions and 2 deletions.
  1. +13 −2 vistrails/core/configuration.py
@@ -37,6 +37,7 @@
import argparse
import ast
import copy
import itertools
import re
import shlex
import sys
@@ -1323,6 +1324,8 @@ def __eq__(self, other):
return False
seen_keys = set()
for name in self.keys():
if self.is_unset(name):
continue
seen_keys.add(name)
if name not in other.keys():
return False
@@ -1333,6 +1336,8 @@ def __eq__(self, other):
if val1 != val2:
return False
for name in other.keys():
if other.is_unset(name):
continue
if name not in seen_keys:
return False
return True
@@ -1438,14 +1443,15 @@ def allkeys(self):
Returns all options stored in this object.
"""

return self.db_config_keys_name_index.keys()
return self.db_config_keys_name_index.keys() + self._unset_keys.keys()

def keys(self):
"""keys(self) -> list of strings
Returns all public options stored in this object.
Public options are keys that do not start with a _
"""
return [k for k in self.db_config_keys_name_index
return [k for k in itertools.chain(self.db_config_keys_name_index,
self._unset_keys)
if not k.startswith('_')]

# def default():
@@ -1665,6 +1671,11 @@ def test_update(self):
conf2.showWindow = False
self.assertTrue(conf1.showWindow)

def test_unset_params(self):
conf = ConfigurationObject(test_field=(None, str))
self.assertTrue(conf.is_unset("test_field"))
self.assertIn("test_field", conf.keys())

def test_type_mismatch(self):
conf = default()
with self.assertRaises(TypeError):

0 comments on commit e2b31b4

Please sign in to comment.
You can’t perform that action at this time.