如果请求只包含字符串类型,如何正确测试查询参数?

时间:2017-05-25 16:24:41

标签: python exception

我有以下方法:

def validate_find_videos(request):
   radius = request.query['radius']
   if not isinstance(radius, int) and not isinstance(radius, float):
      raise WrongRequestData(
        "Please, specify the correct type of radius value. "
        "It must be a numeric value")

   address = request.query['address']
   if (not isinstance(address, str)):
       raise WrongRequestData(
        "Please, specify the correct type of address value. "
        "It must be a string")

如果始终返回curl request,如何正确测试string参数,那么radius将是string而我总是会抛出WrongRequestData

0 个答案:

没有答案