Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[py3] Fixed formtools tests.

Python 3 adds a new pickle protocol. The tests were updated in a way
that makes it easy to add another pickle protocol, should Python gain
one.

Thanks Thomas Pelletier for providing an initial version of this patch.
  • Loading branch information...
commit 527f967ec1e8d463d8f950549d7f5c9b4a4ffc7b 1 parent 0d16533
Aymeric Augustin authored August 18, 2012
36  django/contrib/formtools/tests/__init__.py
@@ -3,6 +3,7 @@
3 3
 
4 4
 import datetime
5 5
 import os
  6
+import pickle
6 7
 import re
7 8
 import warnings
8 9
 
@@ -273,7 +274,10 @@ def test_good_hash(self):
273 274
         """
274 275
         data = {"0-field": "test",
275 276
                 "1-field": "test2",
276  
-                "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  277
+                "hash_0": {
  278
+                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  279
+                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
  280
+                }[pickle.HIGHEST_PROTOCOL],
277 281
                 "wizard_step": "1"}
278 282
         response = self.client.post('/wizard1/', data)
279 283
         self.assertEqual(2, response.context['step0'])
@@ -298,15 +302,24 @@ def process_step(self, request, form, step):
298 302
         wizard = WizardWithProcessStep([WizardPageOneForm])
299 303
         data = {"0-field": "test",
300 304
                 "1-field": "test2",
301  
-                "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  305
+                "hash_0": {
  306
+                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  307
+                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
  308
+                }[pickle.HIGHEST_PROTOCOL],
302 309
                 "wizard_step": "1"}
303 310
         wizard(DummyRequest(POST=data))
304 311
         self.assertTrue(reached[0])
305 312
 
306 313
         data = {"0-field": "test",
307 314
                 "1-field": "test2",
308  
-                "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
309  
-                "hash_1": "1e6f6315da42e62f33a30640ec7e007ad3fbf1a1",
  315
+                "hash_0": {
  316
+                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  317
+                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
  318
+                }[pickle.HIGHEST_PROTOCOL],
  319
+                "hash_1": {
  320
+                    2: "1e6f6315da42e62f33a30640ec7e007ad3fbf1a1",
  321
+                    3: "c33142ef9d01b1beae238adf22c3c6c57328f51a",
  322
+                }[pickle.HIGHEST_PROTOCOL],
310 323
                 "wizard_step": "2"}
311 324
         self.assertRaises(http.Http404, wizard, DummyRequest(POST=data))
312 325
 
@@ -328,7 +341,10 @@ def process_step(self, request, form, step):
328 341
                                         WizardPageThreeForm])
329 342
         data = {"0-field": "test",
330 343
                 "1-field": "test2",
331  
-                "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  344
+                "hash_0": {
  345
+                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  346
+                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
  347
+                }[pickle.HIGHEST_PROTOCOL],
332 348
                 "wizard_step": "1"}
333 349
         wizard(DummyRequest(POST=data))
334 350
         self.assertTrue(reached[0])
@@ -352,7 +368,10 @@ def done(self, request, form_list):
352 368
 
353 369
         data = {"0-field": "test",
354 370
                 "1-field": "test2",
355  
-                "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  371
+                "hash_0": {
  372
+                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  373
+                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
  374
+                }[pickle.HIGHEST_PROTOCOL],
356 375
                 "wizard_step": "1"}
357 376
         wizard(DummyRequest(POST=data))
358 377
         self.assertTrue(reached[0])
@@ -378,7 +397,10 @@ def process_step(self, request, form, step):
378 397
                                         WizardPageThreeForm])
379 398
         data = {"0-field": "test",
380 399
                 "1-field": "test2",
381  
-                "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  400
+                "hash_0": {
  401
+                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
  402
+                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
  403
+                }[pickle.HIGHEST_PROTOCOL],
382 404
                 "wizard_step": "1"}
383 405
         wizard(DummyRequest(POST=data))
384 406
         self.assertTrue(reached[0])

0 notes on commit 527f967

Please sign in to comment.
Something went wrong with that request. Please try again.