diff --git a/examples/bootstrap4/app.py b/examples/bootstrap4/app.py index 4a0b633..483eca8 100644 --- a/examples/bootstrap4/app.py +++ b/examples/bootstrap4/app.py @@ -5,8 +5,8 @@ from flask_wtf import FlaskForm, CSRFProtect from wtforms.validators import DataRequired, Length, Regexp from wtforms.fields import * -from flask_bootstrap import Bootstrap4, SwitchField from flask_sqlalchemy import SQLAlchemy +from flask_bootstrap import Bootstrap4, SwitchField app = Flask(__name__) app.secret_key = 'dev' @@ -34,6 +34,7 @@ class ExampleForm(FlaskForm): """An example form that contains all the supported bootstrap style form fields.""" + date = DateField(description="We'll never share your email with anyone else.") # add help text with `description` datetime = DateTimeField(render_kw={'placeholder': 'this is a placeholder'}) # add HTML attribute with `render_kw` datetime_local = DateTimeLocalField() @@ -52,8 +53,8 @@ class ExampleForm(FlaskForm): select = SelectField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')]) select_multiple = SelectMultipleField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')]) bio = TextAreaField() - search = SearchField() # will autocapitalize on mobile - title = StringField() # will not autocapitalize on mobile + search = SearchField() # will autocapitalize on mobile + title = StringField() # will not autocapitalize on mobile secret = PasswordField() remember = BooleanField('Remember me') submit = SubmitField() @@ -96,7 +97,8 @@ class ContactForm(FlaskForm): class BootswatchForm(FlaskForm): """Form to test Bootswatch.""" - #DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below. + + # DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below. theme_name = RadioField( default='default', choices=[ @@ -208,7 +210,7 @@ def test_bootswatch(): app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = form.theme_name.data flash(f'Render style has been set to {form.theme_name.data}.') else: - if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] != None: + if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] is not None: form.theme_name.data = app.config['BOOTSTRAP_BOOTSWATCH_THEME'] return render_template('bootswatch.html', form=form) diff --git a/examples/bootstrap5/app.py b/examples/bootstrap5/app.py index b7a797f..4614ccf 100644 --- a/examples/bootstrap5/app.py +++ b/examples/bootstrap5/app.py @@ -5,8 +5,8 @@ from flask_wtf import FlaskForm, CSRFProtect from wtforms.validators import DataRequired, Length, Regexp from wtforms.fields import * -from flask_bootstrap import Bootstrap5, SwitchField from flask_sqlalchemy import SQLAlchemy +from flask_bootstrap import Bootstrap5, SwitchField app = Flask(__name__) app.secret_key = 'dev' @@ -34,6 +34,7 @@ class ExampleForm(FlaskForm): """An example form that contains all the supported bootstrap style form fields.""" + date = DateField(description="We'll never share your email with anyone else.") # add help text with `description` datetime = DateTimeField(render_kw={'placeholder': 'this is a placeholder'}) # add HTML attribute with `render_kw` datetime_local = DateTimeLocalField() @@ -52,8 +53,8 @@ class ExampleForm(FlaskForm): select = SelectField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')]) select_multiple = SelectMultipleField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')]) bio = TextAreaField() - search = SearchField() # will autocapitalize on mobile - title = StringField() # will not autocapitalize on mobile + search = SearchField() # will autocapitalize on mobile + title = StringField() # will not autocapitalize on mobile secret = PasswordField() remember = BooleanField('Remember me') submit = SubmitField() @@ -96,7 +97,8 @@ class ContactForm(FlaskForm): class BootswatchForm(FlaskForm): """Form to test Bootswatch.""" - #DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below. + + # DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below. theme_name = RadioField( default='default', choices=[ @@ -212,7 +214,7 @@ def test_bootswatch(): app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = form.theme_name.data flash(f'Render style has been set to {form.theme_name.data}.') else: - if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] != None: + if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] is not None: form.theme_name.data = app.config['BOOTSTRAP_BOOTSWATCH_THEME'] return render_template('bootswatch.html', form=form) diff --git a/flask_bootstrap/__init__.py b/flask_bootstrap/__init__.py index 0f5816d..4d46bd1 100644 --- a/flask_bootstrap/__init__.py +++ b/flask_bootstrap/__init__.py @@ -239,6 +239,7 @@ def create_app(): .. versionchanged:: 2.0.0 Move common logic to base class ``_Bootstrap``. """ + bootstrap_version = '4.6.1' jquery_version = '3.5.1' popper_version = '1.16.1' @@ -276,6 +277,7 @@ def create_app(): .. versionadded:: 2.0.0 """ + bootstrap_version = '5.3.2' popper_version = '2.11.8' icons_version = '1.11.3' diff --git a/tests/test_bootstrap4/test_bootstrap.py b/tests/test_bootstrap4/test_bootstrap.py index bcbe3d6..9d47731 100644 --- a/tests/test_bootstrap4/test_bootstrap.py +++ b/tests/test_bootstrap4/test_bootstrap.py @@ -15,11 +15,11 @@ def test_deprecate_bootstrap_class(self): app = Flask(__name__) with pytest.warns(UserWarning): - bootstrap = Bootstrap(app) # noqa: F841 + _ = Bootstrap(app) def test_deprecate_bootstrap_template_path(self, app, client): @app.route('/test') - def foo(): + def test_render_template_string(): return render_template_string(''' {% from 'bootstrap/utils.html' import render_icon %} {{ render_icon('heart') }} diff --git a/tests/test_bootstrap4/test_render_breadcrumb_item.py b/tests/test_bootstrap4/test_render_breadcrumb_item.py index 2e23c22..1d9b186 100644 --- a/tests/test_bootstrap4/test_render_breadcrumb_item.py +++ b/tests/test_bootstrap4/test_render_breadcrumb_item.py @@ -3,17 +3,17 @@ def test_render_breadcrumb_item_active(app, client): @app.route('/not_active_item') - def foo(): + def item_foo(): return render_template_string(''' {% from 'bootstrap4/nav.html' import render_breadcrumb_item %} - {{ render_breadcrumb_item('bar', 'Bar') }} + {{ render_breadcrumb_item('item_bar', 'Bar') }} ''') @app.route('/active_item') - def bar(): + def item_bar(): return render_template_string(''' {% from 'bootstrap4/nav.html' import render_breadcrumb_item %} - {{ render_breadcrumb_item('bar', 'Bar') }} + {{ render_breadcrumb_item('item_bar', 'Bar') }} ''') response = client.get('/not_active_item') diff --git a/tests/test_bootstrap4/test_render_icon.py b/tests/test_bootstrap4/test_render_icon.py index 40303c0..b91c9c9 100644 --- a/tests/test_bootstrap4/test_render_icon.py +++ b/tests/test_bootstrap4/test_render_icon.py @@ -154,6 +154,7 @@ def test_render_icon_font_config(app, client): def icon(): return render_template_string(''' {% from 'bootstrap4/utils.html' import render_icon %} + {{ bootstrap.load_icon_font_css() }} {{ render_icon('heart', font=True) }} ''') @@ -161,3 +162,10 @@ def icon(): data = response.get_data(as_text=True) assert 'size: 100;' in data assert 'text-success' in data + + # complete test coverage for bootstrap.load_icon_font_css() + app.config['BOOTSTRAP_SERVE_LOCAL'] = not app.config['BOOTSTRAP_SERVE_LOCAL'] + response = client.get('/icon') + data = response.get_data(as_text=True) + assert 'size: 100;' in data + assert 'text-success' in data diff --git a/tests/test_bootstrap4/test_render_nav_item.py b/tests/test_bootstrap4/test_render_nav_item.py index 39d9312..aeb70bd 100644 --- a/tests/test_bootstrap4/test_render_nav_item.py +++ b/tests/test_bootstrap4/test_render_nav_item.py @@ -3,17 +3,17 @@ def test_render_nav_item_active(app, client): @app.route('/active') - def foo(): + def item_foo(): return render_template_string(''' {% from 'bootstrap4/nav.html' import render_nav_item %} - {{ render_nav_item('foo', 'Foo') }} + {{ render_nav_item('item_foo', 'Foo') }} ''') @app.route('/not_active') - def bar(): + def item_bar(): return render_template_string(''' {% from 'bootstrap4/nav.html' import render_nav_item %} - {{ render_nav_item('foo', 'Foo') }} + {{ render_nav_item('item_foo', 'Foo') }} ''') response = client.get('/active') diff --git a/tests/test_bootstrap4/test_render_pager.py b/tests/test_bootstrap4/test_render_pager.py index fefa6fb..cc8d6a5 100644 --- a/tests/test_bootstrap4/test_render_pager.py +++ b/tests/test_bootstrap4/test_render_pager.py @@ -12,7 +12,7 @@ class Message(db.Model): def test(): db.drop_all() db.create_all() - for i in range(100): + for _ in range(100): msg = Message() db.session.add(msg) db.session.commit() diff --git a/tests/test_bootstrap4/test_render_pagination.py b/tests/test_bootstrap4/test_render_pagination.py index 8ad8ccb..e853584 100644 --- a/tests/test_bootstrap4/test_render_pagination.py +++ b/tests/test_bootstrap4/test_render_pagination.py @@ -12,7 +12,7 @@ class Message(db.Model): def test(): db.drop_all() db.create_all() - for i in range(100): # noqa: F841 + for _ in range(100): msg = Message() db.session.add(msg) db.session.commit() diff --git a/tests/test_bootstrap5/test_pagination.py b/tests/test_bootstrap5/test_pagination.py index 891026e..2df3bae 100644 --- a/tests/test_bootstrap5/test_pagination.py +++ b/tests/test_bootstrap5/test_pagination.py @@ -12,7 +12,7 @@ class Message(db.Model): def test(): db.drop_all() db.create_all() - for i in range(100): # noqa: F841 + for _ in range(100): msg = Message() db.session.add(msg) db.session.commit()