diff options
author | Andrew McNamara <andrewm@object-craft.com.au> | 2005-01-12 01:55:21 (GMT) |
---|---|---|
committer | Andrew McNamara <andrewm@object-craft.com.au> | 2005-01-12 01:55:21 (GMT) |
commit | af1e312b3b9f9b1048359005c74f2dbda1a93cde (patch) | |
tree | 1a085592fe8766b6cec76fc52ae358bdcf10fc9b /Lib | |
parent | cf0fd5ab2944eac38c2cd9c0904b24fd8e30e32f (diff) | |
download | cpython-af1e312b3b9f9b1048359005c74f2dbda1a93cde.zip cpython-af1e312b3b9f9b1048359005c74f2dbda1a93cde.tar.gz cpython-af1e312b3b9f9b1048359005c74f2dbda1a93cde.tar.bz2 |
Improve test coverage fractionally.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_csv.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index 82a36e9..fd26e78 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -30,6 +30,8 @@ class Test_Csv(unittest.TestCase): self.assertRaises(TypeError, ctor, arg, lineterminator=None) self.assertRaises(TypeError, ctor, arg, lineterminator=1) self.assertRaises(TypeError, ctor, arg, quoting=None) + self.assertRaises(TypeError, ctor, arg, + quoting=csv.QUOTE_ALL, quotechar='') def test_reader_arg_valid(self): self._test_arg_valid(csv.reader, []) @@ -231,15 +233,21 @@ class Test_Csv(unittest.TestCase): def test_read_bigfield(self): # This exercises the buffer realloc functionality and field size # limits. - size = 50000 - bigstring = 'X' * size - bigline = '%s,%s' % (bigstring, bigstring) - self._read_test([bigline], [[bigstring, bigstring]]) - csv.set_field_limit(size) - self._read_test([bigline], [[bigstring, bigstring]]) - self.assertEqual(csv.set_field_limit(), size) - csv.set_field_limit(size-1) - self.assertRaises(csv.Error, self._read_test, [bigline], []) + limit = csv.set_field_limit() + try: + size = 50000 + bigstring = 'X' * size + bigline = '%s,%s' % (bigstring, bigstring) + self._read_test([bigline], [[bigstring, bigstring]]) + csv.set_field_limit(size) + self._read_test([bigline], [[bigstring, bigstring]]) + self.assertEqual(csv.set_field_limit(), size) + csv.set_field_limit(size-1) + self.assertRaises(csv.Error, self._read_test, [bigline], []) + self.assertRaises(TypeError, csv.set_field_limit, None) + self.assertRaises(TypeError, csv.set_field_limit, 1, None) + finally: + csv.set_field_limit(limit) class TestDialectRegistry(unittest.TestCase): def test_registry_badargs(self): @@ -252,6 +260,12 @@ class TestDialectRegistry(unittest.TestCase): self.assertRaises(csv.Error, csv.unregister_dialect, "nonesuch") self.assertRaises(TypeError, csv.register_dialect, None) self.assertRaises(TypeError, csv.register_dialect, None, None) + self.assertRaises(TypeError, csv.register_dialect, "nonesuch", 0, 0) + self.assertRaises(TypeError, csv.register_dialect, "nonesuch", + badargument=None) + self.assertRaises(TypeError, csv.register_dialect, "nonesuch", + quoting=None) + self.assertRaises(TypeError, csv.register_dialect, []) def test_registry(self): class myexceltsv(csv.excel): |