

def testParseFSMState(self):
    f = cStringIO.StringIO('Value Beer (.)\nValue Wine (\\w)\n\nStart\n')
    t = textfsm.TextFSM(f)
    buf = 'Start\n  ^.\n'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMState, f)
    t.states = {
        
    }
    buf = '# Headline\nStart\n  ^.\n\n'
    f = cStringIO.StringIO(buf)
    t._ParseFSMState(f)
    self.failUnless(t.states['Start'])
    self.failUnlessEqual(str(t.states['Start'][0]), '  ^.')
    try:
        _ = t.states['Start'][1]
    except IndexError:
        pass
    buf = '# Headline\nStart\n  ^.\n  ^Hello World\n  ^Last-[Cc]ha$$nge\n'
    f = cStringIO.StringIO(buf)
    t._line_num = 0
    t.states = {
        
    }
    t._ParseFSMState(f)
    self.failUnlessEqual(str(t.states['Start'][0]), '  ^.')
    self.failUnlessEqual(str(t.states['Start'][1]), '  ^Hello World')
    self.failUnlessEqual(t.states['Start'][1].line_num, 4)
    self.failUnlessEqual(str(t.states['Start'][2]), '  ^Last-[Cc]ha$$nge')
    try:
        _ = t.states['Start'][3]
    except IndexError:
        pass
    t.states = {
        
    }
    buf = 'St%art\n  ^.\n  ^Hello World\n'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMState, f)
    buf = 'Start\n^.\n  ^Hello World\n'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMState, f)
    buf = '  Start\n  ^.\n  ^Hello World\n'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMState, f)
    buf = '# Headline\nStart\n  ^.${Beer}${Wine}.\n  ^Hello $Beer\n  ^Last-[Cc]ha$$nge\n'
    f = cStringIO.StringIO(buf)
    t.states = {
        
    }
    t._ParseFSMState(f)
    self.failUnlessEqual(str(t.states['Start'][0]), '  ^.${Beer}${Wine}.')
    self.failUnlessEqual(str(t.states['Start'][1]), '  ^Hello $Beer')
    self.failUnlessEqual(str(t.states['Start'][2]), '  ^Last-[Cc]ha$$nge')
    try:
        _ = t.states['Start'][3]
    except IndexError:
        pass
    t.states['bogus'] = []
    buf = 'nametoolong_nametoolong_nametoolong_nametoolong_nametoolo\n  ^.\n\n'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMState, f)

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