1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 __docformat__ = 'reStructuredText'
20
22 """A matcher that always returns true
23 """
24 return True
25
27 """A matcher that matches values which are instances of any of given types
28 types: -- collection of types
29 """
30 def matcher(value):
31 for type_ in types:
32 if isinstance(value, type_):
33 return True
34
35 return False
36
37 return matcher
38
40 """A matcher that matches values which match all given matchers
41 matchers: -- collection of matcher functions
42 """
43 def matcher(value):
44 for matcher in matchers:
45 if not matcher(value):
46 return False
47
48 return True
49
50 return matcher
51
53 """A matcher that matches values which are instances of any of given types
54 matchers: -- ordered sequence of matcher functions
55 """
56 def matcher(value):
57 for matcher in matchers:
58 if matcher(value):
59 return True
60
61 return False
62
63 return matcher
64
66 """A matcher that matches values which are instances of any of given types
67 matchers: -- collection of matcher functions
68 """
69 def matcher(value):
70 for matcher in matchers:
71 if matcher(value):
72 return False
73
74 return True
75
76 return matcher
77