async def test_request_parse_copy_including_settings(self): parser = RequestParser(trim=True, store_missing=False, bundle_errors=True) parser_copy = parser.copy() assert parser.trim == parser_copy.trim assert parser.store_missing == parser_copy.store_missing assert parser.bundle_errors == parser_copy.bundle_errors
async def test_request_parser_remove_argument(self, app): async with app.test_request_context('/bubble?foo=baz') as ctx: req = ctx.request parser = RequestParser() parser.add_argument('foo', type=int) parser_copy = parser.copy() parser_copy.remove_argument('foo') args = await parser_copy.parse_args(req) assert args == {}
async def test_request_parser_copy(self, app): async with app.test_request_context('/bubble?foo=101&bar=baz') as ctx: req = ctx.request parser = RequestParser() foo_arg = Argument('foo', type=int) parser.args[foo_arg.name] = foo_arg parser_copy = parser.copy() # Deepcopy should create a clone of the argument object instead of # copying a reference to the new args list assert foo_arg not in parser_copy.args.values() # Args added to new parser should not be added to the original bar_arg = Argument('bar') parser_copy.args[bar_arg.name] = bar_arg assert bar_arg not in parser.args.values() args = await parser_copy.parse_args(req) assert args['foo'] == 101 assert args['bar'] == 'baz'