Exemplo n.º 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]))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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())
Exemplo n.º 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)
Exemplo n.º 11
0
def test_no_history_file():
    cfg = load_config()
    cfg.set('interactive', 'HISTORY_FILE', '')
    assert _setup_readline(cfg=cfg)