Merged revisions 86940 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86940 | eric.araujo | 2010-12-02 23:16:19 +0100 (jeu., 02 déc. 2010) | 2 lines

  Fix wrong test code in test_csv (#10602)
........
This commit is contained in:
Éric Araujo 2010-12-02 22:29:59 +00:00
parent 5d5d1fbbcb
commit 032603efb6
1 changed files with 7 additions and 12 deletions

View File

@ -314,22 +314,17 @@ class TestDialectRegistry(unittest.TestCase):
expected_dialects = csv.list_dialects() + [name]
expected_dialects.sort()
csv.register_dialect(name, myexceltsv)
try:
self.assertTrue(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)
self.addCleanup(csv.unregister_dialect, name)
self.assertEqual(csv.get_dialect(name).delimiter, '\t')
got_dialects = sorted(csv.list_dialects())
self.assertEqual(expected_dialects, got_dialects)
def test_register_kwargs(self):
name = 'fedcba'
csv.register_dialect(name, delimiter=';')
try:
self.assertTrue(csv.get_dialect(name).delimiter, '\t')
self.assertTrue(list(csv.reader('X;Y;Z', name)), ['X', 'Y', 'Z'])
finally:
csv.unregister_dialect(name)
self.addCleanup(csv.unregister_dialect, name)
self.assertEqual(csv.get_dialect(name).delimiter, ';')
self.assertEqual([['X', 'Y', 'Z']], list(csv.reader(['X;Y;Z'], name)))
def test_incomplete_dialect(self):
class myexceltsv(csv.Dialect):