

def testFSMRule(self):
    line = '  ^A beer called ${beer}'
    r = textfsm.TextFSMRule(line)
    self.failUnlessEqual(r.match, '^A beer called ${beer}')
    self.failUnlessEqual(r.line_op, '')
    self.failUnlessEqual(r.new_state, '')
    self.failUnlessEqual(r.record_op, '')
    line = '  ^A $hi called ${beer}'
    r = textfsm.TextFSMRule(line)
    self.failUnlessEqual(r.match, '^A $hi called ${beer}')
    r.failUnlessEqual(r.line_op, '')
    self.failUnlessEqual(r.new_state, '')
    self.failUnlessEqual(r.record_op, '')
    line = '  ^A beer called ${beer} -> Next'
    r = textfsm.TextFSMRule(line)
    self.failUnlessEqual(r.match, '^A beer called ${beer}')
    self.failUnlessEqual(r.line_op, 'Next')
    self.failUnlessEqual(r.new_state, '')
    self.failUnlessEqual(r.record_op, '')
    line = '  ^A beer called ${beer} -> Continue.Record'
    r = textfsm.TextFSMRule(line)
    self.failUnlessEqual(r.match, '^A beer called ${beer}')
    self.failUnlessEqual(r.line_op, 'Continue')
    self.failUnlessEqual(r.new_state, '')
    self.failUnlessEqual(r.record_op, 'Record')
    line = '  ^A beer called ${beer} -> Next.NoRecord End'
    r = textfsm.TextFSMRule(line)
    self.failUnlessEqual(r.match, '^A beer called ${beer}')
    self.failUnlessEqual(r.line_op, 'Next')
    self.failUnlessEqual(r.new_state, 'End')
    self.failUnlessEqual(r.record_op, 'NoRecord')
    self.failUnlessRaises(textfsm.TextFSMTemplateError, textfsm.TextFSMRule, '  ^A beer called ${beer} -> Next Next Next')
    self.failUnlessRaises(textfsm.TextFSMTemplateError, textfsm.TextFSMRule, '  ^A beer called ${beer} -> Boo.hoo')
    self.failUnlessRaises(textfsm.TextFSMTemplateError, textfsm.TextFSMRule, '  ^A beer called ${beer} -> Continue.Record $Hi')

dataset/ETHPy150Open google/textfsm/textfsm_test.py UnitTestFSM.testFSMRule/VarMisuse@91/166 `self`->`r`