Skip to content

Commit

Permalink
Merge pull request #277 from PanderMusubi/codecov
Browse files Browse the repository at this point in the history
Improved test code coverage
  • Loading branch information
greyli authored Apr 4, 2023
2 parents c49674c + 7bf1fc6 commit 2414daa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions flask_bootstrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def is_hidden_field_filter(field):
return isinstance(field, HiddenField)


def raise_helper(message): # pragma: no cover
def raise_helper(message):
raise RuntimeError(message)


Expand All @@ -23,7 +23,7 @@ def get_table_titles(data, primary_key, primary_key_title):
return []
titles = []
for k in data[0].__table__.columns.keys():
if not k.startswith('_'):
if not k.startswith('_'): # pragma: no branch
titles.append((k, k.replace('_', ' ').title()))
titles[0] = (primary_key, primary_key_title)
return titles
Expand All @@ -50,13 +50,13 @@ class _Bootstrap:
popper_filename = 'popper.min.js'

def __init__(self, app=None):
if app is not None:
if app is not None: # pragma: no branch
self.init_app(app)

def init_app(self, app):

if not hasattr(app, 'extensions'):
app.extensions = {}
app.extensions = {} # pragma: no cover
app.extensions['bootstrap'] = self

blueprint = Blueprint('bootstrap', __name__, static_folder=f'static/{self.static_folder}',
Expand Down
6 changes: 5 additions & 1 deletion tests/test_bootstrap4/test_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import pytest
from flask import current_app, render_template_string
from flask_bootstrap import CDN_BASE
from flask_bootstrap import CDN_BASE, raise_helper


@pytest.mark.usefixtures('client')
class TestBootstrap:
def test_raise_helper(self):
with pytest.raises(RuntimeError, match='Test message'):
raise_helper('Test message')

def test_deprecate_bootstrap_class(self):
from flask_bootstrap import Bootstrap
from flask import Flask
Expand Down
1 change: 0 additions & 1 deletion tests/test_bootstrap4/test_render_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def test():
assert '<table class="table">' in data
assert '<th scope="col">#</th>' in data
assert '<th scope="col">Text</th>' in data
assert '<th scope="col">Text</th>' in data
assert '<th scope="row">1</th>' in data
assert '<td>Test message 1</td>' in data

Expand Down

0 comments on commit 2414daa

Please sign in to comment.