From 831705d3c259e1d67c1ba2650abcb65b7a773277 Mon Sep 17 00:00:00 2001 From: Nick Johnstone Date: Tue, 18 Feb 2014 18:27:27 +1300 Subject: [PATCH] Webtests now correctly follow responses `maybe_follow` does not fail the test if the response isn't a redirect. The webtests were changed to use `follow` instead, which correctly fails the test if the response can't be followed. This meant that the login test didn't fail if the form failed to validate or submit. --- .../{{cookiecutter.app_name}}/tests/webtest_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/tests/webtest_tests.py b/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/tests/webtest_tests.py index 55cf4df..a199bc9 100644 --- a/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/tests/webtest_tests.py +++ b/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/tests/webtest_tests.py @@ -27,7 +27,7 @@ class TestLoggingIn(DbTestCase): form['username'] = self.user.username form['password'] = 'myprecious' # Submits - res = form.submit().maybe_follow() + res = form.submit().follow() assert_equal(res.status_code, 200) def _login(self, username, password): @@ -37,12 +37,12 @@ class TestLoggingIn(DbTestCase): form['username'] = username form['password'] = password # Submits - res = form.submit().maybe_follow() + res = form.submit().follow() return res def test_sees_alert_on_log_out(self): res = self._login(self.user.username, 'myprecious') - res = self.w.get(url_for('public.logout')).maybe_follow() + res = self.w.get(url_for('public.logout')).follow() # sees alert assert_in('You are logged out.', res) @@ -88,7 +88,7 @@ class TestRegistering(DbTestCase): form['password'] = 'secret' form['confirm'] = 'secret' # Submits - res = form.submit().maybe_follow() + res = form.submit().follow() assert_equal(res.status_code, 200) # A new user was created assert_equal(len(User.query.all()), 1)