Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Basic Pytest Example

Below is a simple workflow for executing pytest tests stored on GitHub. You can paste this directly into the YAML of an existing or new test, just make sure to update the name and namespace for your environment if needed.

  • The spec.content property defines the location of the folder containing the Pytest test on GitHub
  • The spec.container property defines the workingDir and docker image used in the Workflow.
  • the spec.steps property defines a single step that runs the test.
Basic Pytest Workflow
kind: TestWorkflow
apiVersion: testworkflows.testkube.io/v1
metadata:
name: pytest
namespace: testkube
spec:
content:
git:
uri: https://github.com/kubeshop/testkube-examples.git
revision: main
paths:
- Pytest-Test-Workflow
container:
workingDir: /data/repo/Pytest-Test-Workflow
image: python:3.8.17-alpine3.18
steps:
- name: Run test
shell: pip install pipenv requests pytest && pytest test-api-endpoint.py

After execution, you can see the log output from the Pytest runner under the executions panel Log Output tab:

Pytest Log Output