[英]How to set timeout as variable in Tavern test?
我有两个用于测试的yaml文件common.yaml
和test.yaml
。 在common.yaml
定义了一些变量:
name: Common test information
description: Common data used by test cases
variables:
url: http://localhost:8080/v2
timeout: 30
在测试文件中:
includes:
- !include common.yaml
stages:
- name: test
request:
url: "{url:s}/test"
method: GET
timeout: "{timeout:d}"
response:
status_code: 200
它使用在common
文件上定义的timeout
。 运行测试时出现此错误:
tavern.util.exceptions.BadSchemaError: 'timeout' must be either a float/int or a 2-tuple of floats/ints - got '{timeout:d}' (type <class 'str'>)
Tavern似乎无法识别timeout
类型。 我最后指定类型为d
,但是为什么它没有显示。
使用超时:!int“ {timeout:d}”
或超时:!float“ {timeout:f}”
从字符串转换类型
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.