Browse files

added test cases

  • Loading branch information...
brutus committed Nov 12, 2012
1 parent 6f9dbe4 commit 6e7905b504e26e721f777af29a423aac4329469b
Showing with 387 additions and 10 deletions.
  1. +1 −0 CHANGES.txt
  2. +1 −1
  3. +36 −8 README.rst
  4. +1 −1
  5. +332 −0
  6. +16 −0
@@ -1,2 +1,3 @@
+v0.1.2, 2012-11-12 -- Added test cases.
v0.1.1, 2012-11-11 -- Fixed some spelling errors in the documentation.
v0.1, 2012-11-10 -- Initial release.
@@ -1,4 +1,4 @@
include README.rst LICENSE.txt CHANGES.txt
include requirements.txt
@@ -8,31 +8,42 @@ It supports the new INPUT **types** for fields and also sets some of the
new INPUT **attributes** automatically (based on widget type and what kind of
validators are set for the field).
+There are **widgets** for all the new INPUT types, that you can use in your
+own fields and also **field** classes ready to use. Along with some
+**validators** that take advantage of the new attributes.
+Use it just like WTForms_. The only difference is, that you import the
+**fields** from ``wtforms_html5`` instead.
-1st import the needed stuff...
+First import the needed modules...
>>> from wtforms import Form
->>> from wtforms.validators import Length, NumberRange, Required
+>>> from wtforms.validators import Length, NumberRange, DataRequired
>>> from wtforms_html5 import TextField, IntegerField, DateField
>>> from wtforms_html5 import DateRange
+And some extra stuff for our examples (nomally not needed)
>>> from datetime import date
->>> # and one just for the tests (it is nomally not needed)
>>> from werkzeug.utils import MultiDict
-Then comes the main part: declare your form...
+Then comes the main part: declare your form. This works just like vanilla
+WTForms, just use the **fields** you imported from ``wtforms_html5``
>>> class TestForm(Form):
-... name = TextField('Name', validators=[Required(), Length(5, 25)])
+... name = TextField('Name', validators=[DataRequired(), Length(5, 25)])
... number = IntegerField('Number', validators=[NumberRange(1000, 9999)], description='Some stuff...')
... date = DateField('Date:', validators=[DateRange(date(2000,1,1), date(2012,4,20))])
Now let's see, how the generated input fields look like... the ``min``,
-``max``, ``required`` and ``title`` attributes where auto-generated from
-the declaration.
+``max``, ``required`` and ``title`` attributes where auto-generated from the
>>> f = TestForm()
@@ -42,7 +53,8 @@ u'<input id="number" max="9999" min="1000" name="number" title="Some stuff..." t
u'<input id="date" max="2012-04-20" min="2000-01-01" name="date" type="date" value="">'
-And finally some quick tests for ``DateRange`` and the setting of the ``invalid`` class on error
+And finally some quick tests for ``DateRange`` and the setting of the
+``invalid`` class on error...
>>> d = MultiDict({'name':'Testor', 'date':'1995-05-01'})
>>> f.process(d) # enter the data to the form
@@ -154,10 +166,26 @@ Testing and Contribution
If you find any bugs, issues or anything, please use the `issue tracker`_.
+There are some **doctest** in the module. You can either run them from the
+*source directory* like this ``python -v`` or, if you got
+this modul already installed, like this ``python -m doctest -v
+If you want to run the **test cases**, see that you got nose_ installed. You
+can install it like this: ``pip install nose``. Now either run ``nosetests``
+from the *source directory* or, if you got this modul already installed, run
+them like this: ``nosetest test_wtforms_html5``.
+If something fails, please get in touch.
.. _home:
.. _sourceball:
.. _`issue tracker`:
.. _WTForms:
.. _pip:
.. _`pip install instructions`:
+.. _nose:
@@ -22,5 +22,5 @@
'Natural Language :: English',
'Topic :: Internet :: WWW/HTTP'
- py_modules=['wtforms_html5'],
+ py_modules=['wtforms_html5', 'test_wtforms_html5'],
Oops, something went wrong.

0 comments on commit 6e7905b

Please sign in to comment.