diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-01-02 11:53:50 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-01-02 11:53:50 (GMT) |
commit | 009771ee6b81321f66b3f6dcdc505597d7149407 (patch) | |
tree | 8bdeed94357538d235f1da5661f5eaf4d28475f8 /Lib/test/test_csv.py | |
parent | e8794526db95b7195a7bfeb273886b6c65afb1a3 (diff) | |
parent | 6a31b0fa19cb5684b144a2f3e5ba1d59b4fd7913 (diff) | |
download | cpython-009771ee6b81321f66b3f6dcdc505597d7149407.zip cpython-009771ee6b81321f66b3f6dcdc505597d7149407.tar.gz cpython-009771ee6b81321f66b3f6dcdc505597d7149407.tar.bz2 |
(Merge 3.3) Issue #18829: Add tests for the csv module for invalid characters
(delimiter, escapechar, quotechar)
Diffstat (limited to 'Lib/test/test_csv.py')
-rw-r--r-- | Lib/test/test_csv.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index cbde781..7e2485f 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -837,6 +837,20 @@ 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"): + with self.subTest(field_name=field_name): + 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 = """\ |