summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-06-12 02:40:22 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-06-12 02:40:22 (GMT)
commit1546bc43feb5f0ccb09710342ac3267fcf8cf55d (patch)
tree8e447a7ca66a62c12e792ca098cc0c45f18ed5b0
parent28a4f0f9659e6f64eee8905b21953e7ba6ff68fa (diff)
downloadcpython-1546bc43feb5f0ccb09710342ac3267fcf8cf55d.zip
cpython-1546bc43feb5f0ccb09710342ac3267fcf8cf55d.tar.gz
cpython-1546bc43feb5f0ccb09710342ac3267fcf8cf55d.tar.bz2
add a couple test cases which involve longs and floats in 'e' format.
-rw-r--r--Lib/test/test_csv.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 00ba8cd..ba7cc09 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -423,6 +423,21 @@ class TestDictFields(unittest.TestCase):
"4": 'DEFAULT', "5": 'DEFAULT',
"6": 'DEFAULT'})
+ def test_read_multi(self):
+ sample = [
+ '2147483648,43.0e12,17,abc,def\r\n',
+ '147483648,43.0e2,17,abc,def\r\n',
+ '47483648,43.0,170,abc,def\r\n'
+ ]
+
+ reader = csv.DictReader(sample,
+ fieldnames="i1 float i2 s1 s2".split())
+ self.assertEqual(reader.next(), {"i1": '2147483648',
+ "float": '43.0e12',
+ "i2": '17',
+ "s1": 'abc',
+ "s2": 'def'})
+
def test_read_with_blanks(self):
reader = csv.DictReader(["1,2,abc,4,5,6\r\n","\r\n",
"1,2,abc,4,5,6\r\n"],
@@ -557,6 +572,12 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
05/05/03?05/05/03?05/05/03?05/05/03?05/05/03?05/05/03
'''
+ sample4 = '''\
+2147483648;43.0e12;17;abc;def
+147483648;43.0e2;17;abc;def
+47483648;43.0;170;abc;def
+'''
+
def test_has_header(self):
sniffer = csv.Sniffer()
self.assertEqual(sniffer.has_header(self.sample1), False)
@@ -582,6 +603,8 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
self.assertEqual(dialect.delimiter, "?")
dialect = sniffer.sniff(self.sample3, delimiters="/,")
self.assertEqual(dialect.delimiter, "/")
+ dialect = sniffer.sniff(self.sample4)
+ self.assertEqual(dialect.delimiter, ";")
if not hasattr(sys, "gettotalrefcount"):
if test_support.verbose: print "*** skipping leakage tests ***"