示例#1
0
def test_load_config_env_var_empty():
    os.environ['FOE_CONFIG'] = ''
    cfg = load_config()
    for section, options in _defaults.items():
        assert cfg.has_section(section)
        for option in options.keys():
            assert cfg.has_option(section, option)
            assert cfg.get(section, option) == os.path.expanduser(os.path.expandvars(options[option]))
示例#2
0
def test_show_all_matches():
    cfg = load_config()
    find_settings = load_settings()
    find_settings['dirs'] = [os.path.dirname(__file__)]
    find_settings['file_patterns'] = '*{file}'.format(file=os.path.basename(__file__))
    find_settings['pattern'] = 'test'
    assert execute_module_command(show_command, command=show_command.commands[0],
            command_line=[], cfg=cfg, find_settings=find_settings)
示例#3
0
def test_edit_at_least_one_match():
    cfg = load_config()
    cfg.set('edit', 'editor', 'echo')
    find_settings = load_settings()
    find_settings['dirs'] = [os.path.dirname(__file__)]
    find_settings['file_patterns'] = '*{file}'.format(file=os.path.basename(__file__))
    find_settings['pattern'] = 'test'
    assert execute_module_command(edit_command, command=edit_command.commands[0],
            command_line=['1'], cfg=cfg, find_settings=find_settings)
示例#4
0
def test_edit_current_dir():
    cfg = load_config()
    find_settings = load_settings()
    find_settings['dirs'] = [os.path.dirname(__file__)]
    assert not execute_module_command(edit_command, command=edit_command.commands[0],
            command_line=['1'], cfg=cfg, find_settings=find_settings)
示例#5
0
def test_edit_no_settings():
    cfg = load_config()
    assert not execute_module_command(edit_command, command=edit_command.commands[0],
            command_line=['1'], cfg=cfg)
示例#6
0
def test_edit_number_invalid():
    cfg = load_config()
    assert not execute_module_command(edit_command, command=edit_command.commands[0],
            command_line=['0'], cfg=cfg)
示例#7
0
def test_print_match_interactive_mode():
    cfg = load_config()
    m = re.search(r'test', 'test')
    match = {'match': m, 'filename': 'test', 'line': '1337'}
    assert find_command.print_match(match, 1337, cfg=cfg, interactive=True) is None
示例#8
0
def test_foe_pattern_print_format_unknown_key():
    cfg = load_config()
    cfg.set('match', 'PRINT_FORMAT', '{asdf}')
    assert not execute_module_command(find_command, command=find_command.commands[0],
            command_line=['test', '-f', __file__], cfg=cfg)
示例#9
0
def test_foe_pattern_match():
    assert execute_module_command(find_command, command=find_command.commands[0],
            command_line=['test', '-f', __file__], cfg=load_config())
示例#10
0
def test_history_file():
    with tempfile.NamedTemporaryFile() as f:
        cfg = load_config()
        cfg.set('interactive', 'HISTORY_FILE', f.name)
        assert _setup_readline(cfg=cfg)
示例#11
0
def test_no_history_file():
    cfg = load_config()
    cfg.set('interactive', 'HISTORY_FILE', '')
    assert _setup_readline(cfg=cfg)