Skip to content

Commit

Permalink
fixed unmatched elif
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed Jun 9, 2016
1 parent 705f647 commit 5cf611d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions flask_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def prepare_exec_for_file(filename):
module = []

# Chop off file extensions or package markers
if filename.endswith('.py'):
filename = filename[:-3]
elif os.path.split(filename)[1] == '__init__.py':
if os.path.split(filename)[1] == '__init__.py':
filename = os.path.dirname(filename)
elif filename.endswith('.py'):
filename = filename[:-3]
else:
raise NoAppException('The file provided (%s) does exist but is not a '
'valid Python file. This means that it cannot '
Expand Down
10 changes: 9 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from flask import Flask, current_app

from flask_cli.cli import AppGroup, FlaskGroup, NoAppException, ScriptInfo, \
find_best_app, locate_app, with_appcontext
find_best_app, locate_app, with_appcontext, prepare_exec_for_file
from flask_cli.ext import FlaskCLI


Expand Down Expand Up @@ -49,6 +49,14 @@ class mod:
pytest.raises(NoAppException, find_best_app, mod)


def test_prepare_exec_for_file():
"""Test of prepare_exec_for_file."""
assert prepare_exec_for_file('test.py') == 'test'
assert prepare_exec_for_file('/usr/share/__init__.py') == 'share'
with pytest.raises(NoAppException):
prepare_exec_for_file('test.txt')


def test_locate_app():
"""Test of locate_app."""
assert locate_app("app").name == "testapp"
Expand Down

0 comments on commit 5cf611d

Please sign in to comment.