Revision 8e4968ca
b/lib/build/sphinx_ext.py | ||
---|---|---|
166 | 166 |
continue |
167 | 167 |
|
168 | 168 |
has_default = default is not None or default is not ht.NoDefault |
169 |
has_test = test is not None or test is not ht.NoType
|
|
169 |
has_test = test is not None |
|
170 | 170 |
|
171 | 171 |
buf = StringIO() |
172 | 172 |
buf.write("``%s``" % (rapi_name,)) |
b/lib/ht.py | ||
---|---|---|
160 | 160 |
NoDefault = object() |
161 | 161 |
|
162 | 162 |
|
163 |
#: The no-type (value too complex to check it in the type system) |
|
164 |
NoType = object() |
|
165 |
|
|
166 |
|
|
167 | 163 |
# Some basic types |
168 | 164 |
@WithDesc("Anything") |
169 | 165 |
def TAny(_): |
b/test/py/ganeti.cmdlib_unittest.py | ||
---|---|---|
102 | 102 |
|
103 | 103 |
class OpTest(opcodes.OpCode): |
104 | 104 |
OP_PARAMS = [ |
105 |
("iallocator", None, ht.NoType, None),
|
|
106 |
("node", None, ht.NoType, None),
|
|
105 |
("iallocator", None, ht.TAny, None),
|
|
106 |
("node", None, ht.TAny, None),
|
|
107 | 107 |
] |
108 | 108 |
|
109 | 109 |
default_iallocator = mocks.FakeConfig().GetDefaultIAllocator() |
b/test/py/ganeti.opcodes_unittest.py | ||
---|---|---|
197 | 197 |
# Check parameter definitions |
198 | 198 |
for attr_name, aval, test, doc in cls.GetAllParams(): |
199 | 199 |
self.assert_(attr_name) |
200 |
self.assert_(test is None or test is ht.NoType or callable(test),
|
|
200 |
self.assertTrue(callable(test),
|
|
201 | 201 |
msg=("Invalid type check for %s.%s" % |
202 | 202 |
(cls.OP_ID, attr_name))) |
203 | 203 |
self.assertTrue(doc is None or isinstance(doc, basestring)) |
... | ... | |
214 | 214 |
|
215 | 215 |
default_value = aval |
216 | 216 |
|
217 |
if aval is not ht.NoDefault and test is not ht.NoType:
|
|
217 |
if aval is not ht.NoDefault and aval is not None:
|
|
218 | 218 |
self.assertTrue(test(default_value), |
219 | 219 |
msg=("Default value of %s.%s does not verify" % |
220 | 220 |
(cls.OP_ID, attr_name))) |
... | ... | |
230 | 230 |
("nodef", ht.NoDefault, ht.TMaybeString, None), |
231 | 231 |
("wdef", "default", ht.TMaybeString, None), |
232 | 232 |
("number", 0, ht.TInt, None), |
233 |
("notype", None, ht.NoType, None),
|
|
233 |
("notype", None, ht.TAny, None),
|
|
234 | 234 |
] |
235 | 235 |
|
236 | 236 |
# Missing required parameter "nodef" |
Also available in: Unified diff