Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r requirements.txt
flake8==3.5.0
flake8==3.6.0
pytest==3.9.3
pytest-cov==2.6.0
62 changes: 31 additions & 31 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_run(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run)
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0

Expand All @@ -319,7 +319,7 @@ def test_fails(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run)
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -329,7 +329,7 @@ def test_action(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['-a', 'lint'])
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0

Expand All @@ -340,8 +340,8 @@ def test_action_with_fix(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['-a', 'lint', '--fix'])
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert not result.exception
assert result.exit_code == 0
assert project.read('pass.py') == 'FIXED'
Expand All @@ -354,8 +354,8 @@ def test_action_stage_modified_files(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['-a', 'lint', '--fix', '--stage-modified-files'])
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert not result.exception
assert result.exit_code == 0
assert project.read('pass.py') == 'FIXED'
Expand All @@ -367,7 +367,7 @@ def test_action_fails(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['-a', 'lint'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand Down Expand Up @@ -398,7 +398,7 @@ def test_plugin(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['-p', 'simple'])
assert re.search('simple.+?\[SUCCESS]', result.output)
assert re.search(r'simple.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0

Expand All @@ -408,7 +408,7 @@ def test_plugin_fails(self, cli_runner, project, mock_plugin):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['-p', 'simple'])
assert re.search('simple.+?\[FAILURE]', result.output)
assert re.search(r'simple.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -429,7 +429,7 @@ def test_on_file(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['pass.py'])
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0

Expand All @@ -439,7 +439,7 @@ def test_on_file_fail(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['fail.py'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -449,7 +449,7 @@ def test_dir(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['dir'])
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0

Expand All @@ -459,7 +459,7 @@ def test_dir_fail(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['dir'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -469,7 +469,7 @@ def test_file(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['pass.py'])
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0

Expand All @@ -479,7 +479,7 @@ def test_file_fail(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['fail.py'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -492,7 +492,7 @@ def test_include_untracked(self, cli_runner, project):
assert result.exit_code == 0

result = cli_runner.invoke(cli.run, ['--include-untracked'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -508,7 +508,7 @@ def test_include_unstaged(self, cli_runner, project):
assert result.exit_code == 0

result = cli_runner.invoke(cli.run, ['--include-unstaged'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -520,7 +520,7 @@ def test_unstaged_changes(self, cli_runner, project):
with chdir(project.path):
result = cli_runner.invoke(cli.run)
assert 'You have unstaged changes.' in result.output
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2
assert project.read('pass.py') == 'x'
Expand All @@ -533,7 +533,7 @@ def test_include_unstaged_changes(self, cli_runner, project):
with chdir(project.path):
result = cli_runner.invoke(cli.run, ['--include-unstaged-changes'])
assert 'You have unstaged changes.' in result.output
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0
assert project.read('pass.py') == 'x'
Expand All @@ -545,7 +545,7 @@ def test_use_tracked_files(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['--use-tracked-files'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand All @@ -558,7 +558,7 @@ def test_use_tracked_files_include_untracked(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['--use-tracked-files', '--include-untracked'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2

Expand Down Expand Up @@ -605,7 +605,7 @@ def test_junit_xml(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run, ['--junit-xml=junit.xml'])
assert re.search('Linting.+?\[FAILURE]', result.output)
assert re.search(r'Linting.+?\[FAILURE]', result.output)
assert result.exception
assert result.exit_code == 2
assert project.exists('junit.xml')
Expand All @@ -620,7 +620,7 @@ def test_errors(self, cli_runner, project):

with chdir(project.path):
result = cli_runner.invoke(cli.run)
assert re.search('Linting.+?\[ERROR!!]', result.output)
assert re.search(r'Linting.+?\[ERROR!!]', result.output)
assert result.exception
assert result.exit_code == 1

Expand All @@ -640,7 +640,7 @@ def test_use_shortcut(self, cli_runner, project):
with chdir(project.path):
result = cli_runner.invoke(cli.use, ['lint'])
assert '$ therapist run --action lint --include-untracked' in result.output
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert not result.exception
assert result.exit_code == 0

Expand All @@ -652,8 +652,8 @@ def test_use_extended_shortcut(self, cli_runner, project):
with chdir(project.path):
result = cli_runner.invoke(cli.use, ['fix'])
assert '$ therapist run --action lint --fix --include-untracked' in result.output
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert not result.exception
assert result.exit_code == 0
assert project.read('pass.py') == 'FIXED'
Expand All @@ -667,8 +667,8 @@ def test_extend_extended_shortcut(self, cli_runner, project):
with chdir(project.path):
result = cli_runner.invoke(cli.use, ['fix:all'])
assert '$ therapist run --action lint --fix --include-untracked --use-tracked-files' in result.output
assert re.search('Linting.+?\[SUCCESS]', result.output)
assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert re.search(r'Linting.+?\[SUCCESS]', result.output)
assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL)
assert not result.exception
assert result.exit_code == 0
assert project.read('pass.py') == 'FIXED'
Expand Down Expand Up @@ -783,7 +783,7 @@ def test_hook_with_fix(self, cli_runner, project):
project.git.add('.')

out, err, code = project.git.commit(m='Add a file.')
assert re.search('Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL)
assert re.search(r'Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL)
assert '[SUCCESS]' in err

out, err, code = project.git.status(porcelain=True)
Expand All @@ -804,7 +804,7 @@ def test_hook_with_fix_without_stage_modified_files(self, cli_runner, project):
project.git.add('.')

out, err, code = project.git.commit(m='Add a file.')
assert re.search('Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL)
assert re.search(r'Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL)
assert '[SUCCESS]' in err

out, err, code = project.git.status(porcelain=True)
Expand Down
8 changes: 4 additions & 4 deletions therapist/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ def run(**kwargs):
if plugin:
try:
processes = [config.plugins.get(plugin)]
except config.plugins.DoesNotExist as err:
output('{}\nAvailable plugins:'.format(err.message))
except config.plugins.DoesNotExist as e:
output('{}\nAvailable plugins:'.format(e.message))

for p in config.plugins:
output(p.name)
Expand All @@ -273,8 +273,8 @@ def run(**kwargs):
if action:
try:
processes = [config.actions.get(action)]
except config.actions.DoesNotExist as err:
output('{}\nAvailable actions:'.format(err.message))
except config.actions.DoesNotExist as e:
output('{}\nAvailable actions:'.format(e.message))

for a in config.actions:
output(a.name)
Expand Down
2 changes: 1 addition & 1 deletion therapist/utils/git/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __init__(self, status):
self.is_modified = status[1] == 'M'

if self.is_renamed:
matches = re.search('(\S+?)\s+->\s+(\S+?)$', status[3:])
matches = re.search(r'(\S+?)\s+->\s+(\S+?)$', status[3:])
self.original_path = matches.groups()[0]
self.path = matches.groups()[1]
else:
Expand Down