summaryrefslogtreecommitdiff
path: root/docs/quick_tutorial/functional_testing.rst
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2016-04-17 15:11:14 -0400
committerChris McDonough <chrism@plope.com>2016-04-17 15:11:14 -0400
commit97ab509ae27ce08992ccfbad8eba91613779dee3 (patch)
treeaf4cad2d4d8c3e065ff390d1b9874c8038a623a4 /docs/quick_tutorial/functional_testing.rst
parentdf7a123a847e2243f38688c033f06200382ba139 (diff)
parent61663444a805f432638e6edf7cca76213f0d6029 (diff)
downloadpyramid-97ab509ae27ce08992ccfbad8eba91613779dee3.tar.gz
pyramid-97ab509ae27ce08992ccfbad8eba91613779dee3.tar.bz2
pyramid-97ab509ae27ce08992ccfbad8eba91613779dee3.zip
Merge branch 'master' of github.com:Pylons/pyramid
Diffstat (limited to 'docs/quick_tutorial/functional_testing.rst')
-rw-r--r--docs/quick_tutorial/functional_testing.rst56
1 files changed, 28 insertions, 28 deletions
diff --git a/docs/quick_tutorial/functional_testing.rst b/docs/quick_tutorial/functional_testing.rst
index 6f1544e79..33793578a 100644
--- a/docs/quick_tutorial/functional_testing.rst
+++ b/docs/quick_tutorial/functional_testing.rst
@@ -6,36 +6,39 @@
Write end-to-end full-stack testing using ``webtest``.
+
Background
==========
-Unit tests are a common and popular approach to test-driven development
-(TDD). In web applications, though, the templating and entire apparatus
-of a web site are important parts of the delivered quality. We'd like a
-way to test these.
+Unit tests are a common and popular approach to test-driven development (TDD).
+In web applications, though, the templating and entire apparatus of a web site
+are important parts of the delivered quality. We'd like a way to test these.
+
+`WebTest <http://docs.pylonsproject.org/projects/webtest/en/latest/>`_ is a
+Python package that does functional testing. With WebTest you can write tests
+which simulate a full HTTP request against a WSGI application, then test the
+information in the response. For speed purposes, WebTest skips the
+setup/teardown of an actual HTTP server, providing tests that run fast enough
+to be part of TDD.
-WebTest is a Python package that does functional testing. With WebTest
-you can write tests which simulate a full HTTP request against a WSGI
-application, then test the information in the response. For speed
-purposes, WebTest skips the setup/teardown of an actual HTTP server,
-providing tests that run fast enough to be part of TDD.
Objectives
==========
-- Write a test which checks the contents of the returned HTML
+- Write a test which checks the contents of the returned HTML.
+
Steps
=====
-#. First we copy the results of the previous step, as well as install
- the ``webtest`` package:
+#. First we copy the results of the previous step, as well as install the
+ ``webtest`` package:
.. code-block:: bash
$ cd ..; cp -r unit_testing functional_testing; cd functional_testing
- $ $VENV/bin/python setup.py develop
- $ $VENV/bin/easy_install webtest
+ $ $VENV/bin/pip install -e .
+ $ $VENV/bin/pip install webtest
#. Let's extend ``functional_testing/tutorial/tests.py`` to include a
functional test:
@@ -43,31 +46,28 @@ Steps
.. literalinclude:: functional_testing/tutorial/tests.py
:linenos:
- Be sure this file is not executable, or ``nosetests`` may not
- include your tests.
+ Be sure this file is not executable, or ``pytest`` may not include your
+ tests.
#. Now run the tests:
.. code-block:: bash
+ $ $VENV/bin/py.test tutorial/tests.py -q
+ ..
+ 2 passed in 0.25 seconds
- $ $VENV/bin/nosetests tutorial
- .
- ----------------------------------------------------------------------
- Ran 2 tests in 0.141s
-
- OK
Analysis
========
-We now have the end-to-end testing we were looking for. WebTest lets us
-simply extend our existing ``nose``-based test approach with functional
-tests that are reported in the same output. These new tests not only
-cover our templating, but they didn't dramatically increase the
-execution time of our tests.
+We now have the end-to-end testing we were looking for. WebTest lets us simply
+extend our existing ``pytest``-based test approach with functional tests that
+are reported in the same output. These new tests not only cover our templating,
+but they didn't dramatically increase the execution time of our tests.
+
-Extra Credit
+Extra credit
============
#. Why do our functional tests use ``b''``?