Exemplo n.º 1
0
    def testCblock(self):           
        case = '字元塊'
        d = parser.parse(case)
        self.assertEqual('para', d.type)
        self.assertEqual(1, len(d.children))
        cb = d.children[0]
        self.assertEqual('cblock', cb.type)
        self.assertEqual('字元塊', cb.value)

        case = '''字元塊1
字元塊2
'''
        d = parser.parse(case)
        self.assertEqual('para', d.type)
        self.assertEqual(1, len(d.children))
        cb = d.children[0]
        self.assertEqual('cblock', cb.type)
        self.assertEqual('字元塊1字元塊2', cb.value)

        case = '''字元塊1
字元塊2_3_4_5
[test.sql][label:name:type][name:type]
'''
        d = inliner.parse(case)
        self.assertEqual('para', d.type)
        self.assertEqual(1, len(d.children))
        cb = d.children[0]                                    
        self.assertEqual('cblock', cb.type)
        self.assertEqual(case.replace('\n',''), cb.value)

        case = '''字元塊1''[[test.sql]]''
字元塊2
'''
        d = inliner.parse(case)
        self.assertEqual('para', d.type)
        self.assertEqual(1, len(d.children))
        cb = d.children[0]                                    
        self.assertEqual('cblock', cb.type)
        self.assertEqual('字元塊1[[test.sql]]字元塊2', cb.value)

        case = '用戶端與 KDC 在確認彼此的身份之後,' \
               '用戶端即送出 Msg1 訊息給 KDC:'

        p = inliner.parse(case)
        self.assertEqual('para', p.type)
        self.assertEqual('__string__', p.source)
        self.assertEqual(1, len(d.children))

        cb = p.children[0]                                    
        self.assertEqual('cblock', cb.type)
        self.assertEqual(case, cb.value)
Exemplo n.º 2
0
    def testUnicode(self):
        case = u'交易A'
               
        p = inliner.parse(case)
        self.assertEqual('para', p.type)
        self.assertEqual(u'交易A', p.value)

        cb = p[0]
        self.assertEqual('cblock', cb.type)
        self.assertEqual(case, cb.value)
Exemplo n.º 3
0
    def testReference(self):
        case = '''字元塊1
字元塊2
[[test.sql]][[label|address]]
'''
        #import pdb
        #pdb.set_trace()
        d = inliner.parse(case)
        self.assertEqual('para', d.type)
        self.assertEqual(3, len(d.children))

        cb = d.children[0]
        self.assertEqual('cblock', cb.type)
        self.assertEqual('字元塊1字元塊2', cb.value)

        ref = d.children[1]
        self.assertEqual('reference', ref.type)
        self.assertEqual('test.sql', ref.address)

        ref = d.children[2]
        self.assertEqual('reference', ref.type)
        self.assertEqual('label', ref.label)
        self.assertEqual('address', ref.address)