summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Vuillard <arthur.vuillard@gmail.com>2013-02-21 15:35:30 +0100
committerArthur Vuillard <arthur.vuillard@gmail.com>2013-02-21 15:35:30 +0100
commit7986de0a27488e489eae8ec47319dc6672fd8bdb (patch)
treeaebbcf74905a631a16e5eb5c3316ed12c9ee0394 /tests
parent8fb0a2bea6a59a203d39793ee75bc1ef9b40cc41 (diff)
downloadwebtest-7986de0a27488e489eae8ec47319dc6672fd8bdb.tar.gz
Little cleaning in test_forms.py
Diffstat (limited to 'tests')
-rw-r--r--tests/test_forms.py32
1 files changed, 12 insertions, 20 deletions
diff --git a/tests/test_forms.py b/tests/test_forms.py
index b40c64b..287d8c7 100644
--- a/tests/test_forms.py
+++ b/tests/test_forms.py
@@ -5,18 +5,25 @@ from tests.compat import unittest
import webtest
from webtest.forms import NoValue
-class TestForms(unittest.TestCase):
- def test_set_submit_field(self):
- form = webtest.Form(None, '''
+PAGE_CONTENT = '''
<html>
<head><title>Page without form</title></head>
<body>
<form method="POST" id="second_form">
+ <select name="select">
+ <option value="value1">Value 1</option>
+ <option value="value2" selected>Value 2</option>
+ <option value="value3">Value 3</option>
+ </select>
<input type="submit" name="submit" />
</form>
</body>
</html>
-''')
+'''
+
+class TestForms(unittest.TestCase):
+ def test_set_submit_field(self):
+ form = webtest.Form(None, PAGE_CONTENT)
self.assertRaises(
AttributeError,
form['submit'].value__set,
@@ -24,25 +31,10 @@ class TestForms(unittest.TestCase):
)
def test_force_select(self):
- form = webtest.Form(None, '''
-<html>
- <head><title>Page without form</title></head>
- <body>
- <form method="POST" id="second_form">
- <select name="select">
- <option value="value1">Value 1</option>
- <option value="value2" selected>Value 2</option>
- <option value="value3">Value 3</option>
- </select>
- </form>
- </body>
-</html>
-''')
+ form = webtest.Form(None, PAGE_CONTENT)
form['select'].force_value('notavalue')
form['select'].value__set('value3')
assert form['select']._forced_value is NoValue
assert form['select'].value == 'value3'
assert form['select'].selectedIndex == 2
-
-