Skip to content

Commit

Permalink
Fix unit test and lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed Nov 16, 2023
1 parent e1c8704 commit 74198f4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
8 changes: 3 additions & 5 deletions example/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
db = SQLAlchemy(app)
toolbar = DebugToolbarExtension(app)

with app.app_context():
db.create_all()


class ExampleModel(db.Model):
__tablename__ = 'examples'
value = db.Column(db.String(100), primary_key=True)


@app.before_first_request
def setup():
db.create_all()


@app.route('/')
def index():
app.logger.info("Hello there")
Expand Down
4 changes: 2 additions & 2 deletions src/flask_debugtoolbar/panels/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def process_response(self, request, response):
def title(self):
if not self.is_active:
return "Profiler not active"
return 'View: %.2fms' % (float(self.stats.total_tt)*1000,)
return 'View: %.2fms' % (float(self.stats.total_tt) * 1000,)

def nav_title(self):
return 'Profiler'

def nav_subtitle(self):
if not self.is_active:
return "in-active"
return 'View: %.2fms' % (float(self.stats.total_tt)*1000,)
return 'View: %.2fms' % (float(self.stats.total_tt) * 1000,)

def url(self):
return ''
Expand Down
1 change: 1 addition & 0 deletions src/flask_debugtoolbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def format_sql(query, args):
SqlLexer(),
HtmlFormatter(noclasses=True, style=PYGMENT_STYLE)))


def gzip_compress(data, compresslevel=6):
buff = io.BytesIO()
with gzip.GzipFile(fileobj=buff, mode='wb', compresslevel=compresslevel) as f:
Expand Down
12 changes: 6 additions & 6 deletions test/basic_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
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:////tmp/test.db'
# This is no longer needed for Flask-SQLAlchemy 3.0+, if you're using 2.X you'll want to define this:
# This is no longer needed for Flask-SQLAlchemy 3.0+,
# if you're using 2.X you'll want to define this:
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

# make sure these are printable in the config panel
Expand All @@ -17,17 +19,15 @@
toolbar = DebugToolbarExtension(app)
db = SQLAlchemy(app)

with app.app_context():
db.create_all()


class Foo(db.Model):
__tablename__ = 'foo'
id = db.Column(db.Integer, primary_key=True)


@app.before_first_request
def setup():
db.create_all()


@app.route('/')
def index():
Foo.query.filter_by(id=1).all()
Expand Down
1 change: 0 additions & 1 deletion test/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

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


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ commands =
deps =
pycodestyle
commands =
pycodestyle flask_debugtoolbar test
pycodestyle src/flask_debugtoolbar test --ignore=E731,W503,W504

[pycodestyle]
max-line-length = 100

0 comments on commit 74198f4

Please sign in to comment.