mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-18 11:12:30 +01:00
Test if the file exists in the fix_file
rule
This avoid false positives in `match`.
This commit is contained in:
@@ -158,19 +158,29 @@ ReferenceError: conole is not defined
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test', tests)
|
||||
def test_match(monkeypatch, test):
|
||||
def test_match(mocker, monkeypatch, test):
|
||||
mocker.patch('os.path.isfile', return_value=True)
|
||||
monkeypatch.setenv('EDITOR', 'dummy_editor')
|
||||
assert match(Command(stderr=test[4]), None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test', tests)
|
||||
def test_not_match(monkeypatch, test):
|
||||
def test_no_editor(mocker, monkeypatch, test):
|
||||
mocker.patch('os.path.isfile', return_value=True)
|
||||
if 'EDITOR' in os.environ:
|
||||
monkeypatch.delenv('EDITOR')
|
||||
|
||||
assert not match(Command(stderr=test[4]), None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test', tests)
|
||||
def test_not_file(mocker, monkeypatch, test):
|
||||
mocker.patch('os.path.isfile', return_value=False)
|
||||
monkeypatch.setenv('EDITOR', 'dummy_editor')
|
||||
|
||||
assert not match(Command(stderr=test[4]), None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test', tests)
|
||||
def test_get_new_command(monkeypatch, test):
|
||||
monkeypatch.setenv('EDITOR', 'dummy_editor')
|
||||
|
Reference in New Issue
Block a user