summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2010-12-02 22:29:59 (GMT)
committerÉric Araujo <merwok@netwok.org>2010-12-02 22:29:59 (GMT)
commit032603efb64713a55481b738dc21141600c67a5a (patch)
treeaca06cddb7160cc38537478e403e42758c070837
parent5d5d1fbbcb79a7849a62992f32947b583c4c7788 (diff)
downloadcpython-032603efb64713a55481b738dc21141600c67a5a.zip
cpython-032603efb64713a55481b738dc21141600c67a5a.tar.gz
cpython-032603efb64713a55481b738dc21141600c67a5a.tar.bz2
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) ........
-rw-r--r--Lib/test/test_csv.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 75d1a91..d553a78 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -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):