sIniFile = ""
@given('The configobj OTCmd2.ini exists')
def vIniFileExists():
    global sIniFile
    import os
    sIniFile = os.path.join(os.path.dirname(OTCmd2.__file__), 'OTCmd2.ini')
    assert sIniFile and os.path.exists(sIniFile)

oConfig = None
@given('The configobj OTCmd2.ini is parseable')
def vIniParseable():
    global oConfig
    from configobj import ConfigObj
    oConfig = ConfigObj(sIniFile, unrepr=True)
    assert oConfig

@given(p('The configobj has keys:\n{sKeys}'))
def vIniHasKey(sKeys):
    for sKey in sKeys.split():
        assert sKey in oConfig.keys()

@given(p('The configobj Section "{sSection}" has keys:\n{sKeys}'))
def vSectionHasKey(sSection, sKeys):
    for sKey in sKeys.split():
        assert sKey in oConfig[sSection].keys()

@then('Life is Good!')
def vLifeIsGood():
    pass
sSHARE_EXAMPLES = ""
def vAddShareExamples(sStr):
    global lSHARE_EXAMPLES
    lSHARE_EXAMPLES += [sStr]

@given('Create the OTCmd2 instance')
def vTestCreated(oMain, capsys):
    # oMain.cmdqueue = ['help']
    oMain.onecmd('set echo True')
    sOut, sErr = capsys.readouterr()
    assert sOut
    assert 'True' in sOut
    #? should be sErr
    assert not sOut.startswith('ERR')

@then(p('The "{uCmd}" command stdout contains "{uStr}"'))
@then(p('The "{uCmd}" command output contains "{uStr}"'))
def vTestContains(oMain, capsys, uCmd, uStr):
    oMain.onecmd(uCmd)
    sOut, sErr = capsys.readouterr()
    assert sOut
    assert uStr in sOut
    #? should be sErr
    assert not sOut.startswith('ERR')

@then(p('The "{uCmd}" command stderr contains "{uStr}"'))
@then(p('The "{uCmd}" command error contains "{uStr}"'))
def vTestContains(oMain, capsys, uCmd, uStr):
    oMain.onecmd(uCmd)
    sOut, sErr = capsys.readouterr()
    assert sOut or sErr
Exemple #3
0
    global lSHARE_EXAMPLES
    lSHARE_EXAMPLES += [sStr]


@given('Create the OTCmd2 instance')
def vTestCreated(oMain, capsys):
    # oMain.cmdqueue = ['help']
    oMain.onecmd('set echo True')
    sOut, sErr = capsys.readouterr()
    assert sOut
    assert 'True' in sOut
    #? should be sErr
    assert not sOut.startswith('ERR')


@then(p('The "{uCmd}" command stdout contains "{uStr}"'))
@then(p('The "{uCmd}" command output contains "{uStr}"'))
def vTestContains(oMain, capsys, uCmd, uStr):
    oMain.onecmd(uCmd)
    sOut, sErr = capsys.readouterr()
    assert sOut
    assert uStr in sOut
    #? should be sErr
    assert not sOut.startswith('ERR')


@then(p('The "{uCmd}" command stderr contains "{uStr}"'))
@then(p('The "{uCmd}" command error contains "{uStr}"'))
def vTestContains(oMain, capsys, uCmd, uStr):
    oMain.onecmd(uCmd)
    sOut, sErr = capsys.readouterr()
Exemple #4
0
    sIniFile = os.path.join(os.path.dirname(OTCmd2.__file__), 'OTCmd2.ini')
    assert sIniFile and os.path.exists(sIniFile)


oConfig = None


@given('The configobj OTCmd2.ini is parseable')
def vIniParseable():
    global oConfig
    from configobj import ConfigObj
    oConfig = ConfigObj(sIniFile, unrepr=True)
    assert oConfig


@given(p('The configobj has keys:\n{sKeys}'))
def vIniHasKey(sKeys):
    for sKey in sKeys.split():
        assert sKey in oConfig.keys()


@given(p('The configobj Section "{sSection}" has keys:\n{sKeys}'))
def vSectionHasKey(sSection, sKeys):
    for sKey in sKeys.split():
        assert sKey in oConfig[sSection].keys()


@then('Life is Good!')
def vLifeIsGood():
    pass