summaryrefslogtreecommitdiff
path: root/test_configobj.py
diff options
context:
space:
mode:
authorfuzzyman <devnull@localhost>2009-10-26 23:20:29 +0000
committerfuzzyman <devnull@localhost>2009-10-26 23:20:29 +0000
commit9fd92dd09a4791046489bc7604881bcab819ee4a (patch)
tree0d2e57f6452cb9d92493bd798fd16fe7c50b9c00 /test_configobj.py
parent949fdba09a524bc873ed0d328d416cc4935e092e (diff)
downloadconfigobj-9fd92dd09a4791046489bc7604881bcab819ee4a.tar.gz
Change in behavior for missing values / sections in ConfigObj.validate when preserve_errors is True.
Diffstat (limited to 'test_configobj.py')
-rw-r--r--test_configobj.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/test_configobj.py b/test_configobj.py
index 43d1009..be4a5bd 100644
--- a/test_configobj.py
+++ b/test_configobj.py
@@ -1535,24 +1535,21 @@ def _test_validate():
>>> for entry in flatten_errors(cfg, res):
... section_list, key, error = entry
... section_list.insert(0, '[root]')
- ... if key is not None:
- ... section_list.append(key)
- ... else:
- ... section_list.append('[missing]')
+ ... section_list.append(key)
... section_string = ', '.join(section_list)
- ... errors.append((section_string, ' = ', error))
+ ... errors.append((section_string, ' = ', error or 'missing'))
>>> errors.sort()
>>> for entry in errors:
- ... print entry[0], entry[1], (entry[2] or 0)
- [root], option2 = 0
+ ... print entry[0], entry[1], entry[2]
+ [root], option2 = missing
[root], option3 = the value "Bad_value" is of the wrong type.
- [root], section1, option2 = 0
+ [root], section1, option2 = missing
[root], section1, option3 = the value "Bad_value" is of the wrong type.
[root], section2, another_option = the value "Probably" is of the wrong type.
- [root], section3, section3b, section3b-sub, [missing] = 0
+ [root], section3, section3b, section3b-sub, value = missing
[root], section3, section3b, value2 = the value "a" is of the wrong type.
[root], section3, section3b, value3 = the value "11" is too big.
- [root], section4, [missing] = 0
+ [root], section4, another_option = missing
"""
@@ -2101,6 +2098,21 @@ def _test_invalid_lists():
>>> c = ConfigObj(v)
>>> c['string']
['foo']
+ >>> v = ['string = foo, "']
+ >>> c = ConfigObj(v)
+ Traceback (most recent call last):
+ ParseError: Parse error in value at line 1.
+ """
+
+def _test_validation_with_preserve_errors():
+ """
+ >>> v = Validator()
+ >>> spec = ['[section]', 'foo = integer']
+ >>> c = ConfigObj(configspec=spec)
+ >>> c.validate(v)
+ False
+ >>> c.validate(v, preserve_errors=True)
+ {'section': {'foo': False}}
"""
# TODO: Test BOM handling