

def testParseText(self):
    tplt = 'Value unused (.)\n\nStart\n  ^Trivial SFM\n'
    t = textfsm.TextFSM(cStringIO.StringIO(tplt))
    data = 'Non-matching text\nline1\nline 2\n'
    self.failIf(t.ParseText(data))
    data = 'Matching text\nTrivial SFM\nline 2\n'
    self.failIf(t.ParseText(data))
    tplt = 'Value boo (.*)\n\nStart\n  ^$boo -> Next.Record\n\nEOF\n'
    t = textfsm.TextFSM(cStringIO.StringIO(tplt))
    data = 'Matching text'
    result = t.ParseText(data)
    self.failUnlessEqual(str(result), "[['Matching text']]")
    t.Reset()
    data = 'Matching text\nAnd again'
    result = t.ParseText(data)
    self.failUnlessEqual(str(result), "[['Matching text'], ['And again']]")
    tplt = 'Value Required boo (one)\nValue Filldown hoo (two)\n\nStart\n  ^$boo -> Next.Record\n  ^$hoo -> Next.Record\n\nEOF\n'
    t = textfsm.TextFSM(cStringIO.StringIO(tplt))
    data = 'two\none'
    result = t.ParseText(data)
    self.failUnlessEqual(str(result), "[['one', 'two']]")
    t = textfsm.TextFSM(cStringIO.StringIO(tplt))
    data = 'two\none\none'
    t.Reset()
    result = t.ParseText(data)
    self.failUnlessEqual(str(result), "[['one', 'two'], ['one', 'two']]")
    tplt = 'Value Required,Filldown boo (one)\nValue Filldown,Required hoo (two)\n\nStart\n  ^$boo -> Next.Record\n  ^$hoo -> Next.Record\n\nEOF\n'
    t = textfsm.TextFSM(cStringIO.StringIO(tplt))
    data = 'two\none\none'
    result = t.ParseText(data)
    self.failUnlessEqual(str(result), "[['one', 'two'], ['one', 'two']]")

dataset/ETHPy150Open google/textfsm/textfsm_test.py UnitTestFSM.testParseText/original