mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Allow dialect-describing keywords to be supplied to register_dialect,
record objects of internal dialect type, rather than instances of python objects.
This commit is contained in:
parent
91b97463cd
commit
86625972a1
2 changed files with 21 additions and 28 deletions
|
@ -272,13 +272,22 @@ class TestDialectRegistry(unittest.TestCase):
|
|||
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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue