blob: 6b482a0ef398e3b727e4b702cff230802ebb31fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
from unittest import TestSuite, TestCase, makeSuite
def compare_generic_iter(make_it,match):
"""Utility to compare a generic 2.1/2.2+ iterator with an iterable
If running under Python 2.2+, this tests the iterator using iter()/next(),
as well as __getitem__. 'make_it' must be a function returning a fresh
iterator to be tested (since this may test the iterator twice)."""
it = make_it()
n = 0
for item in match:
assert it[n]==item
n+=1
try:
it[n]
except IndexError:
pass
else:
raise AssertionError("Too many items from __getitem__",it)
try:
iter, StopIteration
except NameError:
pass
else:
# Only test iter mode under 2.2+
it = make_it()
assert iter(it) is it
for item in match:
assert it.next()==item
try:
it.next()
except StopIteration:
pass
else:
raise AssertionError("Too many items from .next()",it)
def test_suite():
from wsgiref.tests import test_util
from wsgiref.tests import test_headers
from wsgiref.tests import test_handlers
tests = [
test_util.test_suite(),
test_headers.test_suite(),
test_handlers.test_suite(),
]
return TestSuite(tests)
|