diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-01-02 11:53:13 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-01-02 11:53:13 (GMT) |
commit | 6a31b0fa19cb5684b144a2f3e5ba1d59b4fd7913 (patch) | |
tree | e69944cbffa5db0d0c178f2b9a80c0ead2ff1c67 /Lib | |
parent | 5f8d48598263ea24a046fd8539fe33e43f96fb15 (diff) | |
download | cpython-6a31b0fa19cb5684b144a2f3e5ba1d59b4fd7913.zip cpython-6a31b0fa19cb5684b144a2f3e5ba1d59b4fd7913.tar.gz cpython-6a31b0fa19cb5684b144a2f3e5ba1d59b4fd7913.tar.bz2 |
Issue #18829: Add tests for the csv module for invalid characters (delimiter,
escapechar, quotechar)
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 = """\ |