Skip to content

Commit

Permalink
Display a decent error message when aborting due to FrozenFlaskWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Jun 23, 2017
1 parent 00d14d3 commit 9672d65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion elsa/_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import urllib.parse
import warnings

Expand Down Expand Up @@ -39,7 +40,11 @@ def freeze_app(app, freezer, path, base_url):
# make sure Frozen Flask warnings are treated as errors
warnings.filterwarnings('error', category=flask_frozen.FrozenFlaskWarning)

freezer.freeze()
try:
freezer.freeze()
except flask_frozen.FrozenFlaskWarning as w:
print('Error:', w, file=sys.stderr)
sys.exit(1)


def inject_cname(app):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,15 @@ def test_freeze_different_warning_is_fine(elsa):
# tests just success of the command


def test_freeze_mishmash_decent_error_msg(elsa, capsys):
elsa.run('freeze', script='mishmash.py', should_fail=True)
out, err = capsys.readouterr()
print('OUT', out)
print('ERR', err)
assert 'Traceback' not in err
assert 'does not match' in err


def test_freeze_cname(elsa):
elsa.run('freeze')
with open(CNAME_FIXTURES) as f:
Expand Down

0 comments on commit 9672d65

Please sign in to comment.