繁体   English   中英

如何在Tavern测试中将超时设置为变量?

[英]How to set timeout as variable in Tavern test?

我有两个用于测试的yaml文件common.yamltest.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM