diff --git a/docs/api.rst b/docs/api.rst index 881f8bf1..1a65bc74 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -28,37 +28,6 @@ Forms and Fields .. autoclass:: FileRequired -.. module:: flask_wtf.html5 - -.. autoclass:: SearchInput - -.. autoclass:: SearchField - -.. autoclass:: URLInput - -.. autoclass:: URLField - -.. autoclass:: EmailInput - -.. autoclass:: EmailField - -.. autoclass:: TelInput - -.. autoclass:: TelField - -.. autoclass:: NumberInput - -.. autoclass:: IntegerField - -.. autoclass:: DecimalField - -.. autoclass:: RangeInput - -.. autoclass:: IntegerRangeField - -.. autoclass:: DecimalRangeField - - CSRF Protection --------------- diff --git a/docs/form.rst b/docs/form.rst index 0b3c6262..eb32aac0 100644 --- a/docs/form.rst +++ b/docs/form.rst @@ -92,24 +92,6 @@ to :class:`FileAllowed`:: FileAllowed(['jpg', 'png'], 'Images only!') ]) -HTML5 Widgets -------------- - -.. note:: - - HTML5 widgets and fields are builtin of wtforms since 1.0.5. You - should consider import them from wtforms if possible. - - We will drop html5 module in next release 0.9.3. - -You can import a number of HTML5 widgets from ``wtforms``:: - - from wtforms.fields.html5 import URLField - from wtforms.validators import url - - class LinkForm(Form): - url = URLField(validators=[url()]) - .. _recaptcha: diff --git a/flask_wtf/html5.py b/flask_wtf/html5.py index 83de5a64..23e79278 100644 --- a/flask_wtf/html5.py +++ b/flask_wtf/html5.py @@ -1,4 +1,13 @@ # coding: utf-8 # flake8: noqa +import warnings +from flask_wtf._compat import FlaskWTFDeprecationWarning + +warnings.warn(FlaskWTFDeprecationWarning( + '"flask_wtf.html5" will be removed in 1.0. ' + 'Import directly from "wtforms.fields.html5" ' + 'and "wtforms.widgets.html5".' +), stacklevel=2) + from wtforms.widgets.html5 import * from wtforms.fields.html5 import * diff --git a/tests/test_form.py b/tests/test_form.py index e98b32ac..671c25c1 100644 --- a/tests/test_form.py +++ b/tests/test_form.py @@ -6,10 +6,11 @@ class TestForm(TestCase): def test_deprecated_form(self): - def define_deprecated_form(): - class F(Form): - pass + with warnings.catch_warnings(): + warnings.simplefilter('error', FlaskWTFDeprecationWarning) + self.assertRaises(FlaskWTFDeprecationWarning, type, 'F', (Form,), {}) + def test_deprecated_html5(self): with warnings.catch_warnings(): warnings.simplefilter('error', FlaskWTFDeprecationWarning) - self.assertRaises(FlaskWTFDeprecationWarning, define_deprecated_form) + self.assertRaises(FlaskWTFDeprecationWarning, __import__, 'flask_wtf.html5') diff --git a/tests/test_html5.py b/tests/test_html5.py deleted file mode 100644 index afac5352..00000000 --- a/tests/test_html5.py +++ /dev/null @@ -1,53 +0,0 @@ -from .base import TestCase -from flask_wtf import html5 - - -class DummyField(object): - def __init__(self, data, name='f', label='', id='', type='TextField'): - self.data = data - self.name = name - self.label = label - self.id = id - self.type = type - - _value = lambda x: x.data - __unicode__ = lambda x: x.data - __call__ = lambda x, **k: x.data - __iter__ = lambda x: iter(x.data) - iter_choices = lambda x: iter(x.data) - - -class HTML5Tests(TestCase): - - field = DummyField("name", id="name", name="name") - - def test_url_input(self): - - self.assertEqual(html5.URLInput()(self.field), - '') - - def test_search_input(self): - - self.assertEqual(html5.SearchInput()(self.field), - '') - - def test_date_input(self): - - self.assertEqual(html5.DateInput()(self.field), - '') - - def test_email_input(self): - - self.assertEqual(html5.EmailInput()(self.field), - '') - - def test_number_input(self): - - self.assertEqual(html5.NumberInput()(self.field, min=0, max=10), - '') - - def test_range_input(self): - - self.assertEqual(html5.RangeInput()(self.field, min=0, max=10), - '') -