mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
Added Python Compile Rule
This commit is contained in:
parent
2f1460120e
commit
a0949b1102
17
tests/rules/test_python_compile.py
Normal file
17
tests/rules/test_python_compile.py
Normal file
@ -0,0 +1,17 @@
|
||||
import pytest
|
||||
from thefuck.rules.python_compile import match, get_new_command
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='python foo'),
|
||||
Command(script='python bar')])
|
||||
def test_match(command):
|
||||
assert match(command, None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, new_command', [
|
||||
(Command('python foo'), 'python foo.py'),
|
||||
(Command('python bar'), 'python bar.py')])
|
||||
def test_get_new_command(command, new_command):
|
||||
assert get_new_command(command, None) == new_command
|
15
thefuck/rules/python_compile.py
Normal file
15
thefuck/rules/python_compile.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Appends .py when compiling python files
|
||||
#
|
||||
# Example:
|
||||
# > python foo
|
||||
# error: python: can't open file 'foo': [Errno 2] No such file or directory
|
||||
|
||||
#
|
||||
#
|
||||
|
||||
def match(command, settings):
|
||||
return (command.script.startswith ('python ')
|
||||
and not command.script.endswith('.py'))
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return command.script + '.py'
|
Loading…
x
Reference in New Issue
Block a user