Tavern is a pytest plugin, command-line tool and Python library for automated testing of APIs, with a simple, concise and flexible YAML-based syntax.
Questions tagged [tavern]
24 questions
4
votes
3 answers
How to make the output less verbose in Pytest?
I am running pytest with tavern for a small testing API project.
Failing a test, throws me a bunch of verbose errors plus the response I am expecting to get (why it failed). How can I make pytest less verbose?
I tried
pytest --tb=short,
pytest…

Andrei B
- 57
- 2
- 4
4
votes
1 answer
ScannerError: mapping values are not allowed here
Using Tavern and trying to run tavern-ci against this yaml:
test_name: tavern poc
- name: list
request:
url: https://xxx.xxx.xxx.us/api/v3/institutions/
method: GET
response:
status_code: 200
headers:
…

pmneve
- 596
- 1
- 5
- 18
2
votes
0 answers
How can I override `_GLOBAL_DEFAULT_TIMEOUT` used by a third party library?
I am using tavern to test python flask application. Occasionally, I got http connection errors like:
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
…

Joey Yi Zhao
- 37,514
- 71
- 268
- 523
2
votes
1 answer
"ValueError: expected ':' after conversion specifier" when trying to authorise on site with x-api-key
Problem:
When I send a yaml file I have crafted from looking at my postman
request. I get the eror "ValueError: expected ':' after conversion
specifier" along with a lot of other errors. This seems to be caused
by the addition of "x-api-key" in the…

RemakingEden
- 257
- 3
- 11
2
votes
1 answer
How to save response value to an variable in Tavern?
I am using Tavern to test my web server in python3. Tavern is to test the service based on a predefined yaml file. I have a backend API when response an auto generated id value to client. How can I test the auto-generated response? And how can I…

Joey Yi Zhao
- 37,514
- 71
- 268
- 523
1
vote
1 answer
how to get code coverage when running tests written in tavern with pytest, having nodejs app running in backend?
I have an API written in node js, and integration tests for endpoints written in tavern with pytest. I want to get code coverage of those integration tests after running. For now, the setup is; first starting node app, and running tavern test suites…

grayelf
- 11
- 2
1
vote
1 answer
Error "Expected only one document in this file but found multiple" in tavern
I use common.yaml file for sharing stages but If I add more than one stage it's showing error "tavern.util.exceptions.UnexpectedDocumentsError:". Do I have to add separate yams file for each stage?
My common.yaml file
name: Test /order endpoint…

Sara
- 19
- 6
1
vote
1 answer
How to add token as env vars for tavern api testing
I am new to Tavern API Testing and I am trying to pass a token as an env var (my api is written in nodejs). Here is my code
test_name: POST /logs
marks:
- post_logs
stages:
- name: post a log entry
request:
url:…

Learner
- 1,686
- 4
- 19
- 38
1
vote
1 answer
pytest-cov always show 0 coverage for Tavern test
I have a python3 application running with flask and I am using Tavern and pytest for test cases. The test cases are executed as expected and it shows results correctly. But I always get 0% code coverage.
This is the command line for running…

Joey Yi Zhao
- 37,514
- 71
- 268
- 523
1
vote
1 answer
What does the error ( mapping values are not allowed here) about yaml schema validation mean?
I am using tavern as a test framework for my python project. The mock server for the test is defined in a yaml file:
test_name: Test phonebook service
stages:
-name: Make sure we can create new contact
request:
url:…

Joey Yi Zhao
- 37,514
- 71
- 268
- 523
1
vote
1 answer
How to test an API with the basic auth using YAML, tavern and pytest
I am implementing a Delete API which requires basic authentication before deleting any user. following is my code for basic auth and deleting a user which works perfectly fine via curl commands.
def auth_required(f):
@wraps(f)
def…

Parag Bhingre
- 830
- 2
- 11
- 20
1
vote
1 answer
Tavern authorization
I'm running a flask api and I want to write some tavern tests for it. I use a basic base64 encode for the username and password that I send in the header when making requests which works fine on the API but I can't seem to get it to work for…

Georges Lorré
- 443
- 3
- 11
1
vote
2 answers
In Tavern, how to load a common stage?
I am using https://github.com/taverntesting/tavern but the following is likely really a PyYAML question.
We would like to have a directory of tests where each file matches an API…

Sean Perry
- 3,776
- 1
- 19
- 31
0
votes
1 answer
Tavern error Structure of returned data was different than expected -
i have a test in tavern
test_name: Add products for tests
stages:
- name: Add product one
request:
url: http://localhost:5566/product
json:
title: Product One
description: Product One in our catalog
…

Andrea Mucci
- 747
- 2
- 9
- 25
0
votes
1 answer
How can Tavern `!include` template JSON request body and modify with `<<`?
I'm using tavern to make multiple similar request to a web server, but in the same stage of different tests (ie different YAML files). Each web request takes a long time, so I've split up my overall testing into different test files so that I can…

hamx0r
- 4,081
- 1
- 33
- 46