def test_parse_defaultgetter(self):

    def defaultget(option):
        if (not hasattr(option, 'type')):
            return
        if (option.type is int):
            option.default = 42
        elif (option.type is str):
            option.default = 'world'
    parser = parseopt.Parser(processopt=defaultget)
    parser.addoption('--this', dest='this', type=int, action='store')
    parser.addoption('--hello', dest='hello', type=str, action='store')
    parser.addoption('--no', dest='no', action='store_true')
    option = parser.parse([])
    assert (option.hello == 'world')
    assert (option.this == 42)
    assert (option.no is False)
def test_parse_defaultgetter(self):

    def defaultget(option):
        if (not hasattr(option, 'type')):
            return
        if (option.type is int):
            option.default = 42
        elif (option.type is str):
            option.default = 'world'
    parser = parseopt.Parser(processopt=defaultget)
    parser.addoption('--this', dest='this', type=int, action='store')
    parser.addoption('--hello', dest='hello', type=str, action='store')
    parser.addoption('--no', dest='no', action='store_true')
    option = parser.parse([])
    assert (option.hello == 'world')
    assert (option.this == 42)
    assert (option.no is False)