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

2024-04-19 08:47:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我有两个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'>)

似乎酒馆不认识timeout的类型。我已经指定了最后的类型是d,但是为什么它没有出现。你知道吗


Tags: 文件nametesturlyaml类型databy