示例#1
0
 def test_alternate_quotes(self):
     p1 = CsvSingleQuotedProtocol() # old style
     p2 = CsvProtocol(quotechar="'") # new style
     line = "'foo',  'bar',  'baz',  1,  2,  3.333"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p1.read(line), (None, res))
     self.assertEqual(p2.read(line), (None, res))
示例#2
0
 def test_alternate_quotes(self):
     p1 = CsvSingleQuotedProtocol()  # old style
     p2 = CsvProtocol(quotechar="'")  # new style
     line = "'foo',  'bar',  'baz',  1,  2,  3.333"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p1.read(line), (None, res))
     self.assertEqual(p2.read(line), (None, res))
示例#3
0
 def test_alternate_delimiter(self):
     p = CsvProtocol(delimiter='|')
     line = "foo|bar|baz|1|2|3.333\n"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))
示例#4
0
 def test_trailing_separator(self):
     p = CsvProtocol()
     line = '"foo",  "bar",  "baz",  1,  2,  3.333, '
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333', u'']
     self.assertEqual(p.read(line), (None, res))
示例#5
0
 def test_read_unicode(self):
     p = CsvProtocol()
     line = '"Paul",  "Erdős",  "foo",  1,  2,  3.333'
     res = [u'Paul', u'Erdős', u'foo', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))
示例#6
0
 def test_drop_quotes(self):
     p = CsvProtocol()
     line = "\"foo\",  \"bar\",  \"baz\",  1,  2,  3.333"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))
示例#7
0
 def test_read_one_line(self):
     p = CsvProtocol()
     line = "foo,  bar,  baz,  1,  2,  3.333\n"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))
示例#8
0
 def test_alternate_delimiter(self):
     p = CsvProtocol(delimiter='|')
     line = "foo|bar|baz|1|2|3.333\n"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))
示例#9
0
 def test_trailing_separator(self):
     p = CsvProtocol()
     line = '"foo",  "bar",  "baz",  1,  2,  3.333, '
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333', u'']
     self.assertEqual(p.read(line), (None, res))
示例#10
0
 def test_read_unicode(self):
     p = CsvProtocol()
     line = '"Paul",  "Erdős",  "foo",  1,  2,  3.333'
     res = [u'Paul', u'Erdős', u'foo', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))
示例#11
0
 def test_drop_quotes(self):
     p = CsvProtocol()
     line = "\"foo\",  \"bar\",  \"baz\",  1,  2,  3.333"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))
示例#12
0
 def test_read_one_line(self):
     p = CsvProtocol()
     line = "foo,  bar,  baz,  1,  2,  3.333\n"
     res = [u'foo', u'bar', u'baz', u'1', u'2', u'3.333']
     self.assertEqual(p.read(line), (None, res))