Skip to content

Commit 1afdf97

Browse files
committed
Update test/test_actions.py to work with py.test
The test_actions tests use a FieldStorage object to mock form submissions. FieldStorage would usually use the 'QUERY_STRING' environment variable to populate the initial list of MiniFieldStorage values stored within the FieldStorage object, but because there is no 'QUERY_STRING' environment variable when running the test from the commandline it tries to parse sys.argv instead. If any py.test options are used (ie. '--tb=short') then they may end up in the MiniFieldStorage list causing some tests to fail because they were not expecting the extra MiniFieldStorage values. To fix this we explicitly pass an dict with an empty 'QUERY_STRING' value as the FieldStorage environ argument to ensure that the initial MiniFieldStorage list is empty.
1 parent df3893a commit 1afdf97

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/test_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def true(*args, **kwargs):
1414

1515
class ActionTestCase(unittest.TestCase):
1616
def setUp(self):
17-
self.form = FieldStorage()
17+
self.form = FieldStorage(environ={'QUERY_STRING': ''})
1818
self.client = MockNull()
1919
self.client._ok_message = []
2020
self.client._error_message = []

0 commit comments

Comments
 (0)