

def testParseFSMVariables(self):
    f = cStringIO.StringIO('Value unused (.)\n\nStart\n')
    t = textfsm.TextFSM(f)
    buf = 'Value Filldown Beer (beer)\n\n'
    f = cStringIO.StringIO(buf)
    t._ParseFSMVariables(f)
    buf = '# Headline\nValue Filldown Beer (beer)\n\n'
    f = cStringIO.StringIO(buf)
    t._ParseFSMVariables(f)
    self.failUnlessEqual(str(t._GetValue('Beer')), 'Value Filldown Beer (beer)')
    buf = '# Headline\nValue Filldown Beer (beer)\nValue Required Spirits (whiskey)\nValue Filldown Wine (claret)\n\n'
    t._line_num = 0
    f = cStringIO.StringIO(buf)
    t._ParseFSMVariables(f)
    self.failUnlessEqual(str(t._GetValue('Beer')), 'Value Filldown Beer (beer)')
    self.failUnlessEqual(str(t._GetValue('Spirits')), 'Value Required Spirits (whiskey)')
    self.failUnlessEqual(str(t._GetValue('Wine')), 'Value Filldown Wine (claret)')
    buf = '# Headline\nValue Filldown Beer (beer)\n # A comment\nValue Spirits ()\nValue Filldown,Required Wine ((c|C)laret)\n\n'
    f = cStringIO.StringIO(buf)
    t._ParseFSMVariables(f)
    self.failUnlessEqual(str(t._GetValue('Beer')), 'Value Filldown Beer (beer)')
    self.failUnlessEqual(str(t._GetValue('Spirits')), 'Value Spirits ()')
    self.failUnlessEqual(str(t._GetValue('Wine')), 'Value Filldown,Required Wine ((c|C)laret)')
    buf = 'Value Beer (beer) beer'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMVariables, f)
    buf = 'Value Filldown, Required Spirits ()'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMVariables, f)
    buf = 'Value filldown,Required Wine ((c|C)laret)'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMVariables, f)
    buf = '# Headline\nValue Filldown Beer (bee(r), (and) (M)ead$)\n# A comment\nValue Spirits,and,some ()\nValue Filldown,Required Wine ((c|C)laret)\n\n'
    f = cStringIO.StringIO(buf)
    t._ParseFSMVariables(f)
    t.failUnlessEqual(str(t._GetValue('Beer')), 'Value Filldown Beer (bee(r), (and) (M)ead$)')
    self.failUnlessEqual(str(t._GetValue('Spirits,and,some')), 'Value Spirits,and,some ()')
    self.failUnlessEqual(str(t._GetValue('Wine')), 'Value Filldown,Required Wine ((c|C)laret)')
    buf = 'Value Filldown nametoolong_nametoolong_nametoolo_nametoolong_nametoolong (beer)\n\n'
    f = cStringIO.StringIO(buf)
    self.failUnlessRaises(textfsm.TextFSMTemplateError, t._ParseFSMVariables, f)

dataset/ETHPy150Open google/textfsm/textfsm_test.py UnitTestFSM.testParseFSMVariables/VarMisuse@337/831 `self`->`t`