Пример #1
0
    def testParser(self):
        testcase = '''時間 交易A       交易B
==== =========== ===========
t1     A.read(p)
t2   A.update(p)
t3               B.read(p)
t4               B.update(p)
==== =========== ===========
'''
        d = parser.parse(testcase.decode('utf8'))
        self.assertEqual('table', d.type)
        header = d.children[0]
        self.assertEqual('tr', header.type)
        th1 = header.children[0]
        self.assertEqual('th', th1.type)
        self.assertEqual(u'時間', th1.value)
        th2 = header.children[1]
        self.assertEqual(u'交易A', th2.value)

        r2 = d.children[1]
        self.assertEqual('tr', r2.type)
        td1 = r2.children[0]
        self.assertEqual('td', td1.type)
        self.assertEqual('t1', td1.value)
        td2 = r2.children[1]
        self.assertEqual('A.read(p)', td2.value)
Пример #2
0
    def testSingleRowTable(self):
        case = '''name
======
金叔分
曹晶蓮
李美紅
======
'''
        t = parser.parse(case.decode('utf8'))
        self.assertEqual('table', t.type)
        header = t.children[0]
        self.assertEqual('tr', header.type)
        th1 = header.children[0]
        self.assertEqual('th', th1.type)
        self.assertEqual(u'name', th1.value)

        r2 = t.children[1]
        self.assertEqual('tr', r2.type)
        td1 = r2.children[0]
        self.assertEqual('td', td1.type)
        self.assertEqual(u'金叔分', td1.value)

        self.assertEqual(4, len(t.children))