Skip to content

Commit

Permalink
Fix the test for basic app
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed Nov 21, 2023
1 parent 62ce443 commit ccd25b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/flask_debugtoolbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def process_response(self, response):
response.headers['content-type'].startswith('text/html')):
return response

if 'gzip' in response.headers.get('Content-Encoding'):
content_encoding = response.headers.get('Content-Encoding')
if content_encoding and 'gzip' in content_encoding:
response_html = gzip_decompress(response.data).decode()
else:
response_html = response.get_data(as_text=True)
Expand Down Expand Up @@ -258,7 +259,7 @@ def process_response(self, response):

content = ''.join((before, toolbar_html, after))
content = content.encode('utf-8')
if 'gzip' in response.headers.get('Content-Encoding'):
if content_encoding and 'gzip' in content_encoding:
content = gzip_compress(content)
response.response = [content]
response.content_length = len(content)
Expand Down
1 change: 1 addition & 0 deletions test/basic_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from flask_debugtoolbar import DebugToolbarExtension

app = Flask('basic_app')
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'abc123'
app.config['SQLALCHEMY_RECORD_QUERIES'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
Expand Down
2 changes: 1 addition & 1 deletion test/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

def load_app(name):
app = __import__(name).app
app.config['TESTING'] = True
return app.test_client()


def test_basic_app():
app = load_app('basic_app')
app.config['TESTING'] = True
index = app.get('/')
assert index.status_code == 200
assert b'<div id="flDebug"' in index.data
Expand Down

0 comments on commit ccd25b7

Please sign in to comment.