示例#1
0
    def test_iterative(self):
        """
        Ensure csv_unicode_reader consumes iteratively.
        """

        data = iter([u"this,is,a,test",
                     u"my,name,is,john"])
        reader = csv_unicode_reader(data)
        first_row = next(reader)
        self.assertEqual([u'this', u'is', u'a', u'test'], first_row)
        self.assertEqual(u"my,name,is,john", next(data))
示例#2
0
    def test_unicode_to_csv_unicode(self):
        """
        Ensure that a stream of unicode strings
        are converted to sequences by parsing
        with the csv module.
        """
        data = u'this,is,"a\na",test\nmy,name,is,john'
        stream = StringIO(data)

        self.assertEqual(
            [
                [u'this', u'is', u'a\na', u'test'],
                [u'my', u'name', u'is', u'john'],
            ],
            list(csv_unicode_reader(stream)))