mirror of https://github.com/python/cpython
Issue #18829: Add tests for the csv module for invalid characters (delimiter,
escapechar, quotechar)
This commit is contained in:
parent
5f8d485982
commit
6a31b0fa19
|
@ -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 = """\
|
||||
|
|
Loading…
Reference in New Issue