Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_csv.TestSniffer Class Reference
Collaboration diagram for test.test_csv.TestSniffer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_has_header
def test_sniff
def test_delimiters
def test_doublequote

Static Public Attributes

string sample1
string sample2
string header
string sample3
string sample4
string sample5 = "aaa\tbbb\r\nAAA\t\r\nBBB\t\r\n"
string sample6 = "a|b|c\r\nd|e|f\r\n"
string sample7 = "'a'|'b'|'c'\r\n'd'|e|f\r\n"

Detailed Description

Definition at line 766 of file test_csv.py.


Member Function Documentation

Definition at line 815 of file test_csv.py.

00815 
00816     def test_delimiters(self):
00817         sniffer = csv.Sniffer()
00818         dialect = sniffer.sniff(self.sample3)
00819         # given that all three lines in sample3 are equal,
00820         # I think that any character could have been 'guessed' as the
00821         # delimiter, depending on dictionary order
00822         self.assertIn(dialect.delimiter, self.sample3)
00823         dialect = sniffer.sniff(self.sample3, delimiters="?,")
00824         self.assertEqual(dialect.delimiter, "?")
00825         dialect = sniffer.sniff(self.sample3, delimiters="/,")
00826         self.assertEqual(dialect.delimiter, "/")
00827         dialect = sniffer.sniff(self.sample4)
00828         self.assertEqual(dialect.delimiter, ";")
00829         dialect = sniffer.sniff(self.sample5)
00830         self.assertEqual(dialect.delimiter, "\t")
00831         dialect = sniffer.sniff(self.sample6)
00832         self.assertEqual(dialect.delimiter, "|")
00833         dialect = sniffer.sniff(self.sample7)
00834         self.assertEqual(dialect.delimiter, "|")
00835         self.assertEqual(dialect.quotechar, "'")

Here is the call graph for this function:

Definition at line 836 of file test_csv.py.

00836 
00837     def test_doublequote(self):
00838         sniffer = csv.Sniffer()
00839         dialect = sniffer.sniff(self.header)
00840         self.assertFalse(dialect.doublequote)
00841         dialect = sniffer.sniff(self.sample2)
00842         self.assertTrue(dialect.doublequote)

Here is the call graph for this function:

Definition at line 798 of file test_csv.py.

00798 
00799     def test_has_header(self):
00800         sniffer = csv.Sniffer()
00801         self.assertEqual(sniffer.has_header(self.sample1), False)
00802         self.assertEqual(sniffer.has_header(self.header+self.sample1), True)

Here is the call graph for this function:

Definition at line 803 of file test_csv.py.

00803 
00804     def test_sniff(self):
00805         sniffer = csv.Sniffer()
00806         dialect = sniffer.sniff(self.sample1)
00807         self.assertEqual(dialect.delimiter, ",")
00808         self.assertEqual(dialect.quotechar, '"')
00809         self.assertEqual(dialect.skipinitialspace, True)
00810 
00811         dialect = sniffer.sniff(self.sample2)
00812         self.assertEqual(dialect.delimiter, ":")
00813         self.assertEqual(dialect.quotechar, "'")
00814         self.assertEqual(dialect.skipinitialspace, False)

Here is the call graph for this function:


Member Data Documentation

Initial value:
'''\
"venue","city","state","date","performers"
'''

Definition at line 779 of file test_csv.py.

Initial value:
"""\
Harry's, Arlington Heights, IL, 2/1/03, Kimi Hayes
Shark City, Glendale Heights, IL, 12/28/02, Prezence
Tommy's Place, Blue Island, IL, 12/28/02, Blue Sunday/White Crow
Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
"""

Definition at line 767 of file test_csv.py.

Initial value:
"""\
'Harry''s':'Arlington Heights':'IL':'2/1/03':'Kimi Hayes'
'Shark City':'Glendale Heights':'IL':'12/28/02':'Prezence'
'Tommy''s Place':'Blue Island':'IL':'12/28/02':'Blue Sunday/White Crow'
'Stonecutters ''Seafood'' and Chop House':'Lemont':'IL':'12/19/02':'Week Back'
"""

Definition at line 773 of file test_csv.py.

Initial value:
'''\
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
'''

Definition at line 782 of file test_csv.py.

Initial value:
'''\
2147483648;43.0e12;17;abc;def
147483648;43.0e2;17;abc;def
47483648;43.0;170;abc;def
'''

Definition at line 788 of file test_csv.py.

string test.test_csv.TestSniffer.sample5 = "aaa\tbbb\r\nAAA\t\r\nBBB\t\r\n" [static]

Definition at line 794 of file test_csv.py.

Definition at line 795 of file test_csv.py.

Definition at line 796 of file test_csv.py.


The documentation for this class was generated from the following file: