summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2016-12-10 17:23:33 +0100
committerMarcel Hellkamp <marc@gsites.de>2016-12-10 17:23:33 +0100
commit860d5867cd2c1752bfdf4734e0c00ce564dd966f (patch)
tree9a7d7f8bf6a1801b68c6738a4ce078f0f287a81f
parent9405bbc5dc34c8b83699411ef6cb017f8b6ff11a (diff)
downloadbottle-860d5867cd2c1752bfdf4734e0c00ce564dd966f.tar.gz
Fix tests for Python 2.5 (itertools.product missing)
-rwxr-xr-xtest/test_environ.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/test_environ.py b/test/test_environ.py
index 7f441fc..e9062ae 100755
--- a/test/test_environ.py
+++ b/test/test_environ.py
@@ -4,8 +4,6 @@
import unittest
import sys
-import itertools
-
import bottle
from bottle import request, tob, touni, tonat, json_dumps, _e, HTTPError, parse_date
import tools
@@ -14,6 +12,18 @@ import base64
from bottle import BaseRequest, BaseResponse, LocalRequest
+
+try:
+ from itertools import product
+except ImportError:
+ def product(*args):
+ pools = map(tuple, args)
+ result = [[]]
+ for pool in pools:
+ result = [x + [y] for x in result for y in pool]
+ for prod in result:
+ yield tuple(prod)
+
class TestRequest(unittest.TestCase):
def test_app_property(self):
@@ -662,7 +672,7 @@ class TestResponse(unittest.TestCase):
apis = 'append', 'replace', '__setitem__', 'setdefault'
masks = '{}test', 'test{}', 'te{}st'
tests = '\n', '\r', '\n\r', '\0'
- for api, mask, test in itertools.product(apis, masks, tests):
+ for api, mask, test in product(apis, masks, tests):
hd = bottle.HeaderDict()
func = getattr(hd, api)
value = mask.replace("{}", test)