From 8eb4e0b477323c0c502dcb4495bb309b1639bb83 Mon Sep 17 00:00:00 2001 From: John Kristensen Date: Thu, 20 Aug 2015 16:30:50 +1000 Subject: [PATCH 2/5] 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. --- test/test_actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_actions.py b/test/test_actions.py index 196458f83c..61f32fc7a0 100644 --- a/test/test_actions.py +++ b/test/test_actions.py @@ -14,7 +14,7 @@ def true(*args, **kwargs): class ActionTestCase(unittest.TestCase): def setUp(self): - self.form = FieldStorage() + self.form = FieldStorage(environ={'QUERY_STRING': ''}) self.client = MockNull() self.client._ok_message = [] self.client._error_message = [] -- 2.5.0