Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13085)

Side by Side Diff: Lib/test/test_csv.py

Issue 18829: csv produces confusing error message when passed a non-string delimiter
Patch Set: Created 6 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Modules/_csv.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2001,2002 Python Software Foundation 1 # Copyright (C) 2001,2002 Python Software Foundation
2 # csv package unit tests 2 # csv package unit tests
3 3
4 import io 4 import io
5 import sys 5 import sys
6 import os 6 import os
7 import unittest 7 import unittest
8 from io import StringIO 8 from io import StringIO
9 from tempfile import TemporaryFile 9 from tempfile import TemporaryFile
10 import csv 10 import csv
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 skipinitialspace = True 783 skipinitialspace = True
784 lineterminator = '\r\n' 784 lineterminator = '\r\n'
785 quoting = csv.QUOTE_NONE 785 quoting = csv.QUOTE_NONE
786 d = mydialect() 786 d = mydialect()
787 787
788 mydialect.lineterminator = ":::" 788 mydialect.lineterminator = ":::"
789 d = mydialect() 789 d = mydialect()
790 790
791 mydialect.lineterminator = 4 791 mydialect.lineterminator = 4
792 self.assertRaises(csv.Error, mydialect) 792 self.assertRaises(csv.Error, mydialect)
793
794 def test_invaliddelimiter(self):
795 class mydialect(csv.Dialect):
796 delimiter = b","
797
798 with self.assertRaises(csv.Error) as cm:
799 mydialect()
800 self.assertEqual(str(cm.exception),
801 '"delimiter" must be an 1-character string')
793 802
794 803
795 class TestSniffer(unittest.TestCase): 804 class TestSniffer(unittest.TestCase):
796 sample1 = """\ 805 sample1 = """\
797 Harry's, Arlington Heights, IL, 2/1/03, Kimi Hayes 806 Harry's, Arlington Heights, IL, 2/1/03, Kimi Hayes
798 Shark City, Glendale Heights, IL, 12/28/02, Prezence 807 Shark City, Glendale Heights, IL, 12/28/02, Prezence
799 Tommy's Place, Blue Island, IL, 12/28/02, Blue Sunday/White Crow 808 Tommy's Place, Blue Island, IL, 12/28/02, Blue Sunday/White Crow
800 Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back 809 Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
801 """ 810 """
802 sample2 = """\ 811 sample2 = """\
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 1015
1007 1016
1008 def test_main(): 1017 def test_main():
1009 mod = sys.modules[__name__] 1018 mod = sys.modules[__name__]
1010 support.run_unittest( 1019 support.run_unittest(
1011 *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')] 1020 *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
1012 ) 1021 )
1013 1022
1014 if __name__ == '__main__': 1023 if __name__ == '__main__':
1015 test_main() 1024 test_main()
OLDNEW
« no previous file with comments | « no previous file | Modules/_csv.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+