Issue #18829: Add tests for the csv module for invalid characters (delimiter,

escapechar, quotechar)
This commit is contained in:
Victor Stinner 2014-01-02 12:53:13 +01:00
parent 5f8d485982
commit 6a31b0fa19
1 changed files with 13 additions and 0 deletions

View File

@ -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 = """\