本文整理汇总了Python中flask_restful.reqparse.Argument类的典型用法代码示例。如果您正苦于以下问题:Python Argument类的具体用法?Python Argument怎么用?Python Argument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Argument类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_argument_repr
def test_argument_repr(self):
arg = Argument('foo')
try: # Python 2.6 compatibility
self.assertIn('foo', arg.__repr__())
except AttributeError:
self.assertTrue('foo' in arg.__repr__())
self.assertTrue(arg.__repr__().startswith("Argument('foo'"))
示例2: test_source
def test_source(self):
req = Mock(['args', 'headers', 'values'])
req.args = {'foo': 'bar'}
req.headers = {'baz': 'bat'}
arg = Argument('foo', location=['args'])
self.assertEquals(arg.source(req), req.args)
arg = Argument('foo', location=['headers'])
self.assertEquals(arg.source(req), req.headers)
示例3: test_source_default_location
def test_source_default_location(self):
req = Mock(['values'])
req._get_child_mock = lambda **kwargs: NonCallableMock(**kwargs)
arg = Argument('foo')
self.assertEquals(arg.source(req), req.values)
示例4: test_source_bad_location
def test_source_bad_location(self):
req = Mock(['values'])
arg = Argument('foo', location=['foo'])
self.assertTrue(len(arg.source(req)) == 0) # yes, basically you don't find it
示例5: test_default_type
def test_default_type(self, mock_six):
arg = Argument("foo")
sentinel = object()
arg.type(sentinel)
mock_six.text_type.assert_called_with(sentinel)
示例6: test_source_default_location
def test_source_default_location(self):
req = Mock(['values'])
arg = Argument('foo')
self.assertEquals(arg.source(req), req.values)
示例7: test_convert_with_null_input_when_not_nullable
def test_convert_with_null_input_when_not_nullable(self):
arg = Argument('foo', nullable=False)
self.assertRaises(ValueError, lambda: arg.convert(None, None))
示例8: test_convert_default_type_with_null_input
def test_convert_default_type_with_null_input(self):
arg = Argument('foo')
self.assertEquals(arg.convert(None, None), None)
示例9: test_convert_default_type_with_null_input
def test_convert_default_type_with_null_input(self):
"""convert() should properly handle case where input is None"""
arg = Argument('foo')
self.assertEquals(arg.convert(None, None), None)
示例10: test_source_default_location
def test_source_default_location(self):
req = Mock(["values"])
req._get_child_mock = lambda **kwargs: MultiDict()
arg = Argument("foo")
self.assertEquals(arg.source(req), req.values)