From 294c5981e2f75c834e8e694a27ea27adac8095b4 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Mon, 8 Jan 2018 22:41:04 +0200 Subject: [PATCH] Add a test for importing a package (__init__.py) with a syntax error twice --- tests/test_apps/cliapp/syntaxerror/__init__.py | 1 + tests/test_cli.py | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/test_apps/cliapp/syntaxerror/__init__.py diff --git a/tests/test_apps/cliapp/syntaxerror/__init__.py b/tests/test_apps/cliapp/syntaxerror/__init__.py new file mode 100644 index 00000000..a4694fdb --- /dev/null +++ b/tests/test_apps/cliapp/syntaxerror/__init__.py @@ -0,0 +1 @@ +spam()spam() diff --git a/tests/test_cli.py b/tests/test_cli.py index 811ef0c8..693ff582 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -243,6 +243,15 @@ def test_locate_app_suppress_raise(): ) +def test_locate_app_init_syntax_error(test_apps): + info = ScriptInfo() + with pytest.raises(SyntaxError): + locate_app(info, 'cliapp.syntaxerror', None) + + with pytest.raises(SyntaxError): + locate_app(info, 'cliapp.syntaxerror', None) + + def test_get_version(test_apps, capsys): """Test of get_version.""" from flask import __version__ as flask_ver