本文整理汇总了Python中urlobject.query_string.QueryString.add_params方法的典型用法代码示例。如果您正苦于以下问题:Python QueryString.add_params方法的具体用法?Python QueryString.add_params怎么用?Python QueryString.add_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urlobject.query_string.QueryString
的用法示例。
在下文中一共展示了QueryString.add_params方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_params_accepts_the_same_args_as_dict
# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import add_params [as 别名]
def test_add_params_accepts_the_same_args_as_dict(self):
s = QueryString("")
added = s.add_params({"abc": "123"}, foo="bar", xyz="456")
assert added.dict == {"abc": "123", "foo": "bar", "xyz": "456"}
added2 = s.add_params([("abc", "123")], foo="bar", xyz="456")
assert added2.dict == {"abc": "123", "foo": "bar", "xyz": "456"}
# It also has to fail in the same way as `dict`. If you pass more than
# one positional argument it should raise a TypeError.
self.assertRaises(TypeError, s.add_params, {"abc": "123"}, {"foo": "bar"})
示例2: test_add_params_accepts_the_same_args_as_dict
# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import add_params [as 别名]
def test_add_params_accepts_the_same_args_as_dict(self):
s = QueryString(u'')
added = s.add_params({u'abc': u'123'}, foo=u'bar', xyz='456')
assert added.dict == {u'abc': u'123', u'foo': u'bar', u'xyz': u'456'}
added2 = s.add_params([(u'abc', u'123')], foo=u'bar', xyz='456')
assert added2.dict == {u'abc': u'123', u'foo': u'bar', u'xyz': u'456'}
# It also has to fail in the same way as `dict`. If you pass more than
# one positional argument it should raise a TypeError.
self.assertRaises(TypeError,
s.add_params, {'abc': '123'}, {'foo': 'bar'})
示例3: test_add_params_with_multiple_values_adds_the_same_parameter_multiple_times
# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import add_params [as 别名]
def test_add_params_with_multiple_values_adds_the_same_parameter_multiple_times(self):
s = QueryString(u'')
assert (s.add_params({u'foo': [u'bar', u'baz']}) ==
s.add_param(u'foo', u'bar').add_param(u'foo', u'baz'))
示例4: test_add_params_is_equivalent_to_calling_add_param_multiple_times
# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import add_params [as 别名]
def test_add_params_is_equivalent_to_calling_add_param_multiple_times(self):
s = QueryString(u'')
assert (s.add_params([(u'abc', u'123'), (u'def', u'456')]) ==
s.add_param(u'abc', u'123').add_param(u'def', u'456'))
示例5: test_add_params_with_multiple_values_adds_the_same_parameter_multiple_times
# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import add_params [as 别名]
def test_add_params_with_multiple_values_adds_the_same_parameter_multiple_times(self):
s = QueryString("")
assert s.add_params({"foo": ["bar", "baz"]}) == s.add_param("foo", "bar").add_param("foo", "baz")
示例6: test_add_params_is_equivalent_to_calling_add_param_multiple_times
# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import add_params [as 别名]
def test_add_params_is_equivalent_to_calling_add_param_multiple_times(self):
s = QueryString("")
assert s.add_params([("abc", "123"), ("def", "456")]) == s.add_param("abc", "123").add_param("def", "456")