diff options
author | Éric Araujo <merwok@netwok.org> | 2010-12-02 22:16:19 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2010-12-02 22:16:19 (GMT) |
commit | 5137d648cd5b586d1f7063ce9e625cb6c2996704 (patch) | |
tree | a342ea7a5279b8f4fa7b017b58af3e6f05596ae6 /Lib | |
parent | 98338227a7fe2ebb3e820c547ab05af259320642 (diff) | |
download | cpython-5137d648cd5b586d1f7063ce9e625cb6c2996704.zip cpython-5137d648cd5b586d1f7063ce9e625cb6c2996704.tar.gz cpython-5137d648cd5b586d1f7063ce9e625cb6c2996704.tar.bz2 |
Fix wrong test code in test_csv (#10602)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_csv.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index c3da185..8ca1e62 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -313,22 +313,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): |