diff options
author | Ludovico Cavedon <cavedon@debian.org> | 2010-06-12 16:34:16 -0700 |
---|---|---|
committer | Ludovico Cavedon <cavedon@debian.org> | 2010-06-12 16:34:16 -0700 |
commit | b58ade97bde0f26271ebbccf6959bfc5a30a88d2 (patch) | |
tree | 3d296c03823ea4806febf3d0d9becb8a90e57671 /tests | |
parent | 60b2e5ebf0b074436aaec91409d9863d015b9a73 (diff) |
Imported Upstream version 0.4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/__init__.py | 2 | ||||
-rw-r--r-- | tests/test_fuzz.py | 4 | ||||
-rw-r--r-- | tests/test_ini.py | 6 | ||||
-rw-r--r-- | tests/test_misc.py | 16 | ||||
-rw-r--r-- | tests/test_multiprocessing.py | 33 | ||||
-rw-r--r-- | tests/test_tidy.py | 3 |
6 files changed, 53 insertions, 11 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index 1269812..f1fa321 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -6,6 +6,7 @@ import test_fuzz import test_compat import test_unicode import test_tidy +import test_multiprocessing from iniparse import config from iniparse import ini @@ -20,4 +21,5 @@ class suite(unittest.TestSuite): test_compat.suite(), test_unicode.suite(), test_tidy.suite(), + test_multiprocessing.suite(), ]) diff --git a/tests/test_fuzz.py b/tests/test_fuzz.py index f63a718..5420dcc 100644 --- a/tests/test_fuzz.py +++ b/tests/test_fuzz.py @@ -4,7 +4,7 @@ import random import unittest import ConfigParser from StringIO import StringIO -from iniparse import compat, ini +from iniparse import compat, ini, tidy # TODO: # tabs @@ -101,7 +101,7 @@ class test_fuzz(unittest.TestCase): # compare the two configparsers self.assertEqualConfig(cc_py, cc) # check that tidy does not change semantics - ini.tidy(cc) + tidy(cc) cc_tidy = ConfigParser.RawConfigParser() cc_tidy.readfp(StringIO(str(cc.data))) self.assertEqualConfig(cc_py, cc_tidy) diff --git a/tests/test_ini.py b/tests/test_ini.py index bdb9080..6a76edb 100644 --- a/tests/test_ini.py +++ b/tests/test_ini.py @@ -223,8 +223,14 @@ but = also me p = ini.INIConfig(sio) p.new1.created = 1 setattr(getattr(p, 'new2'), 'created', 1) + p.new3['created'] = 1 + p['new4'].created = 1 + p['new5']['created'] = 1 self.assertEqual(p.new1.created, 1) self.assertEqual(p.new2.created, 1) + self.assertEqual(p.new3.created, 1) + self.assertEqual(p.new4.created, 1) + self.assertEqual(p.new5.created, 1) def test_order(self): sio = StringIO(self.s1) diff --git a/tests/test_misc.py b/tests/test_misc.py index 482c5c4..31cf4da 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -385,19 +385,19 @@ class test_pickle(unittest.TestCase): c = cfg_class() c.readfp(StringIO(self.s)) self.do_compat_checks(c) - p = pickle.dumps(c) - c = None - c2 = pickle.loads(p) - self.do_compat_checks(c2) + for i in range(0, pickle.HIGHEST_PROTOCOL+1): + p = pickle.dumps(c, protocol=i) + c2 = pickle.loads(p) + self.do_compat_checks(c2) def test_ini(self): c = ini.INIConfig() c._readfp(StringIO(self.s)) self.do_ini_checks(c) - p = pickle.dumps(c) - c = None - c2 = pickle.loads(p) - self.do_ini_checks(c2) + for i in range(0, pickle.HIGHEST_PROTOCOL+1): + p = pickle.dumps(c, protocol=i) + c2 = pickle.loads(p) + self.do_ini_checks(c2) class test_comment_syntax(unittest.TestCase): """Test changing comment syntax with change_comment_syntax""" diff --git a/tests/test_multiprocessing.py b/tests/test_multiprocessing.py new file mode 100644 index 0000000..f95a569 --- /dev/null +++ b/tests/test_multiprocessing.py @@ -0,0 +1,33 @@ +import unittest +try: + from multiprocessing import Process, Queue, Pipe + disabled = False +except ImportError: + disabled = True + +from iniparse import compat, ini + +class test_ini(unittest.TestCase): + """Test sending INIConfig objects.""" + + def test_queue(self): + def getxy(q, w): + cfg = q.get_nowait() + w.put(cfg.x.y) + cfg = ini.INIConfig() + cfg.x.y = '42' + q = Queue() + w = Queue() + q.put(cfg) + p = Process(target=getxy, args=(q, w)) + p.start() + self.assertEqual(w.get(timeout=1), '42') + +class suite(unittest.TestSuite): + def __init__(self): + if disabled: + unittest.TestSuite.__init__(self, []) + else: + unittest.TestSuite.__init__(self, [ + unittest.makeSuite(test_ini, 'test'), + ]) diff --git a/tests/test_tidy.py b/tests/test_tidy.py index 4990457..7304747 100644 --- a/tests/test_tidy.py +++ b/tests/test_tidy.py @@ -2,7 +2,8 @@ import unittest from textwrap import dedent from StringIO import StringIO -from iniparse.ini import INIConfig, EmptyLine, tidy +from iniparse import tidy,INIConfig +from iniparse.ini import EmptyLine from iniparse.compat import ConfigParser class test_tidy(unittest.TestCase): |