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

Delta Between Two Patch Sets: Lib/test/test_csv.py

Issue 18829: csv produces confusing error message when passed a non-string delimiter
Left Patch Set: Created 6 years ago
Right Patch Set: Created 6 years 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/csv.py ('k') | Modules/_csv.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 delimiter = ";" 774 delimiter = ";"
775 escapechar = '\\' 775 escapechar = '\\'
776 doublequote = False 776 doublequote = False
777 skipinitialspace = True 777 skipinitialspace = True
778 lineterminator = '\r\n' 778 lineterminator = '\r\n'
779 quoting = csv.QUOTE_NONE 779 quoting = csv.QUOTE_NONE
780 d = mydialect() 780 d = mydialect()
781 self.assertEqual(d.delimiter, ";") 781 self.assertEqual(d.delimiter, ";")
782 782
783 mydialect.delimiter = ":::" 783 mydialect.delimiter = ":::"
784 with self.assertRaises(csv.Error) as cm:
785 mydialect()
786 self.assertEqual(str(cm.exception),
787 '"delimiter" must be an 1-character string')
788
789 mydialect.delimiter = ""
784 with self.assertRaises(csv.Error) as cm: 790 with self.assertRaises(csv.Error) as cm:
785 mydialect() 791 mydialect()
786 self.assertEqual(str(cm.exception), 792 self.assertEqual(str(cm.exception),
787 '"delimiter" must be an 1-character string') 793 '"delimiter" must be an 1-character string')
788 794
789 mydialect.delimiter = b"," 795 mydialect.delimiter = b","
790 with self.assertRaises(csv.Error) as cm: 796 with self.assertRaises(csv.Error) as cm:
791 mydialect() 797 mydialect()
792 self.assertEqual(str(cm.exception), 798 self.assertEqual(str(cm.exception),
793 '"delimiter" must be string, not bytes') 799 '"delimiter" must be string, not bytes')
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 1040
1035 1041
1036 def test_main(): 1042 def test_main():
1037 mod = sys.modules[__name__] 1043 mod = sys.modules[__name__]
1038 support.run_unittest( 1044 support.run_unittest(
1039 *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')] 1045 *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
1040 ) 1046 )
1041 1047
1042 if __name__ == '__main__': 1048 if __name__ == '__main__':
1043 test_main() 1049 test_main()
LEFTRIGHT

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