Allow dialect-describing keywords to be supplied to register_dialect,
record objects of internal dialect type, rather than instances of
python objects.
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 66b0ea9..cdda179 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -272,13 +272,22 @@
expected_dialects.sort()
csv.register_dialect(name, myexceltsv)
try:
- self.failUnless(isinstance(csv.get_dialect(name), myexceltsv))
+ self.failUnless(csv.get_dialect(name).delimiter, '\t')
got_dialects = csv.list_dialects()
got_dialects.sort()
self.assertEqual(expected_dialects, got_dialects)
finally:
csv.unregister_dialect(name)
+ def test_register_kwargs(self):
+ name = 'fedcba'
+ csv.register_dialect(name, delimiter=';')
+ try:
+ self.failUnless(csv.get_dialect(name).delimiter, '\t')
+ self.failUnless(list(csv.reader('X;Y;Z', name)), ['X', 'Y', 'Z'])
+ finally:
+ csv.unregister_dialect(name)
+
def test_incomplete_dialect(self):
class myexceltsv(csv.Dialect):
delimiter = "\t"