Beispiel #1
0
	def test_simplest_columns(self):
		cols = ['one', 'two', 'three', 'four']
		expected = dict(one='one', two='two', three='three', four='four')
		got = csv.parse_line(simplest, column_names=cols)
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
		for k, v in got.items():
			self.failUnlessEqual(k, v, 'column names were improperly assigned')
Beispiel #2
0
	def test_hard(self):
		expected = ['one', 'two', 'three', 'four\nwith return', 'five']
		got = csv.parse_line(hard)
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
Beispiel #3
0
	def test_tricky(self):
		expected = ['one', 'two with end "', 'three', 'four']
		got = csv.parse_line(tricky)
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
Beispiel #4
0
	def test_simple(self):
		expected = ['one', 'two with " here', 'three', 'four']
		got = csv.parse_line(simple)
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
Beispiel #5
0
	def test_simpler(self):
		expected = ['one', 'two', 'three', 'last one']
		got = csv.parse_line(simpler)
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
Beispiel #6
0
	def test_known_bad_1(self):
		expected = ['LCD1066', 'Take Your Time', '', '', 'LCD1066-4', 'Letter From Home, The Harmonic Branching', '9m34s', 'Lovely Music', 'Tyranny, "Blue" Gene', 'Tyranny, "Blue" Gene (piano)', '', '', '', '', '', '', '', '', '']
		got = csv.parse_line(known_bad_1, separator="\t")
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
Beispiel #7
0
	def test_openoffice_tsv(self):
		result = csv.parse_line(openoffice_tsv, separator='\t')
		self.failUnlessEqual('col1', result[0])
		self.failUnlessEqual('col2', result[1])
		self.failUnlessEqual('col3', result[2])
Beispiel #8
0
	def test_tab_quote_bug(self):
		result = csv.parse_line(tab_quote_bug, separator='\t', qualifier=None)
		self.failUnless('"Mariana"' in result[9], result[9])
		result = csv.parse_line(tab_quote_bug, separator='\t')
		self.failUnless('"Mariana"' in result[9], result[9])
Beispiel #9
0
	def test_tabs_oo(self):
		expected = ['#1234', 'something else here', 'another quoted string', '1234']
		got = csv.parse_line(tabs_oo, separator='\t')
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
Beispiel #10
0
	def test_tabs_quoted(self):
		expected = ['one', 'two here', 'three', 'four']
		got = csv.parse_line(tabs_quoted, separator='\t')
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))
Beispiel #11
0
	def test_hardest(self):
		expected = ['one', 'two\nwith return\nand """ quotes', 'three', 'four']
		got = csv.parse_line(hardest)
		self.failUnlessEqual(got, expected, 'Got %s when expecting %s' % (got, expected))