diff options
author | Skip Montanaro <skip@pobox.com> | 2003-05-19 15:33:36 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2003-05-19 15:33:36 (GMT) |
commit | 77892373313b7195e16755abe0604bd734df4736 (patch) | |
tree | 71fe6dd39510d42b94b9f6a5831efb5ce9210af7 /Lib/test/test_csv.py | |
parent | c626658a2803bb48a25b6c845ab60d72be1ed5d4 (diff) | |
download | cpython-77892373313b7195e16755abe0604bd734df4736.zip cpython-77892373313b7195e16755abe0604bd734df4736.tar.gz cpython-77892373313b7195e16755abe0604bd734df4736.tar.bz2 |
* Correct Sniffer doc to correspond to the implementation.
* Add optional delimiters arg to Sniffer.sniff() which restricts the set of
candidate field delimiters.
Diffstat (limited to 'Lib/test/test_csv.py')
-rw-r--r-- | Lib/test/test_csv.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index c0ad645..00ba8cd 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -551,6 +551,12 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back header = '''\ "venue","city","state","date","performers" ''' + sample3 = '''\ +05/05/03?05/05/03?05/05/03?05/05/03?05/05/03?05/05/03 +05/05/03?05/05/03?05/05/03?05/05/03?05/05/03?05/05/03 +05/05/03?05/05/03?05/05/03?05/05/03?05/05/03?05/05/03 +''' + def test_has_header(self): sniffer = csv.Sniffer() self.assertEqual(sniffer.has_header(self.sample1), False) @@ -568,6 +574,15 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back self.assertEqual(dialect.quotechar, "'") self.assertEqual(dialect.skipinitialspace, False) + def test_delimiters(self): + sniffer = csv.Sniffer() + dialect = sniffer.sniff(self.sample3) + self.assertEqual(dialect.delimiter, "0") + dialect = sniffer.sniff(self.sample3, delimiters="?,") + self.assertEqual(dialect.delimiter, "?") + dialect = sniffer.sniff(self.sample3, delimiters="/,") + self.assertEqual(dialect.delimiter, "/") + if not hasattr(sys, "gettotalrefcount"): if test_support.verbose: print "*** skipping leakage tests ***" else: |