summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyman <devnull@localhost>2010-02-27 21:03:39 +0000
committerfuzzyman <devnull@localhost>2010-02-27 21:03:39 +0000
commit3ae5465a3129213d97b53a5eca5bf79c07033b57 (patch)
treee988015c56847b069b4fff6a8139d0a21598631d
parent045d26e83cafc87e1da5d7960f1cadc88696b20e (diff)
downloadconfigobj-3ae5465a3129213d97b53a5eca5bf79c07033b57.tar.gz
Removing 2.2 compatibility code, a validate test that doesn't pass and using unittest2 where available.
-rw-r--r--functionaltests/test_configobj.py7
-rw-r--r--functionaltests/test_validate_errors.py8
-rw-r--r--validate.py22
3 files changed, 16 insertions, 21 deletions
diff --git a/functionaltests/test_configobj.py b/functionaltests/test_configobj.py
index 31e63d9..437b5a9 100644
--- a/functionaltests/test_configobj.py
+++ b/functionaltests/test_configobj.py
@@ -1,9 +1,14 @@
from __future__ import with_statement
import os
-import unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
from configobj import ConfigObj
+# Python 2.6 only
from warnings import catch_warnings
diff --git a/functionaltests/test_validate_errors.py b/functionaltests/test_validate_errors.py
index ed85ec3..4517817 100644
--- a/functionaltests/test_validate_errors.py
+++ b/functionaltests/test_validate_errors.py
@@ -1,5 +1,9 @@
import os
-import unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
from configobj import ConfigObj, get_extra_values
from validate import Validator
@@ -58,7 +62,5 @@ class TestValidateErrors(unittest.TestCase):
])
self.assertEqual(sorted(extra_values), expected)
-
-
if __name__ == '__main__':
unittest.main()
diff --git a/validate.py b/validate.py
index 08c9867..cca057d 100644
--- a/validate.py
+++ b/validate.py
@@ -128,7 +128,7 @@
A badly formatted set of arguments will raise a ``VdtParamError``.
"""
-__version__ = '1.0.1'
+__version__ = '1.0.2'
__all__ = (
@@ -268,8 +268,6 @@ def dottedQuadToNum(ip):
16908291
>>> int(dottedQuadToNum('1.2.3.4'))
16909060
- >>> dottedQuadToNum('1.2.3. 4')
- 16909060
>>> dottedQuadToNum('255.255.255.255')
4294967295L
>>> dottedQuadToNum('255.255.255.256')
@@ -284,7 +282,7 @@ def dottedQuadToNum(ip):
return struct.unpack('!L',
socket.inet_aton(ip.strip()))[0]
except socket.error:
- # bug in inet_aton, corrected in Python 2.3
+ # bug in inet_aton, corrected in Python 2.4
if ip.strip() == '255.255.255.255':
return 0xFFFFFFFFL
else:
@@ -592,7 +590,7 @@ class Validator(object):
# no information needed here - to be handled by caller
raise VdtMissingValue()
value = self._handle_none(default)
-
+
if value is None:
return None
@@ -601,7 +599,7 @@ class Validator(object):
def _handle_none(self, value):
if value == 'None':
- value = None
+ return None
elif value in ("'None'", '"None"'):
# Special case a quoted None
value = self._unquote(value)
@@ -667,17 +665,7 @@ class Validator(object):
# Default must be deleted if the value is specified too,
# otherwise the check function will get a spurious "default" keyword arg
- try:
- default = fun_kwargs.pop('default', None)
- except AttributeError:
- # Python 2.2 compatibility
- default = None
- try:
- default = fun_kwargs['default']
- del fun_kwargs['default']
- except KeyError:
- pass
-
+ default = fun_kwargs.pop('default', None)
return fun_name, fun_args, fun_kwargs, default