4
4
5
5
from flask_minify import minify , parsers
6
6
from flask_minify .cache import MemoryCache
7
- from flask_minify .exceptions import MissingApp
7
+ from flask_minify .exceptions import FlaskMinifyException
8
8
from flask_minify .utils import does_content_type_match , is_empty
9
9
10
10
from .constants import (
@@ -89,13 +89,14 @@ def test_request_falsy_endpoint(self):
89
89
90
90
assert (list (matches ), exists ) == ([], False )
91
91
92
- def test_access_missing_app_raises_exception (self ):
93
- """test accessing a missing flask app raises an exception """
92
+ def test_access_app_after_lazy_initialization (self ):
93
+ """"""
94
94
self .mock_app = None
95
95
ext = self .minify_defaults
96
+ mock_app = mock .MagicMock ()
97
+ ext .init_app (mock_app )
96
98
97
- with pytest .raises (MissingApp ):
98
- ext .app
99
+ assert ext .app == mock_app
99
100
100
101
101
102
class TestParsers :
@@ -116,6 +117,16 @@ class CustomParser(parsers.Lesscpy):
116
117
117
118
assert minified == COMPILED_LESS_RAW
118
119
120
+ def test_parser_raising_exception_with_failsafe_disabled (self ):
121
+ class CustomParser (parsers .Lesscpy ):
122
+ def executer (self , content , ** options ):
123
+ raise Exception ("something went wrong" )
124
+
125
+ parser = parsers .Parser ({"style" : CustomParser })
126
+
127
+ with pytest .raises (FlaskMinifyException ):
128
+ parser .minify (LESS_RAW , "style" )
129
+
119
130
120
131
class TestMemoryCache :
121
132
def setup (self ):
0 commit comments