diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_csv.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index f1d14b9..83f8cb3 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -828,6 +828,19 @@ class TestDialectValidity(unittest.TestCase): self.assertEqual(str(cm.exception), '"lineterminator" must be a string') + def test_invalid_chars(self): + def create_invalid(field_name, value): + class mydialect(csv.Dialect): + pass + setattr(mydialect, field_name, value) + d = mydialect() + + for field_name in ("delimiter", "escapechar", "quotechar"): + self.assertRaises(csv.Error, create_invalid, field_name, "") + self.assertRaises(csv.Error, create_invalid, field_name, "abc") + self.assertRaises(csv.Error, create_invalid, field_name, b'x') + self.assertRaises(csv.Error, create_invalid, field_name, 5) + class TestSniffer(unittest.TestCase): sample1 = """\ |