pytest
No long description provided.
Installation
dagger install github.com/dagger/pytest@fe4e2f5fa4cf40ee037195b2c7d19620a4027234Entrypoint
Return Type
Pytest !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory | - | Optional: The source directory containing your Python project |
| container | Container | - | Optional: A custom container with Python and uv installed. If not provided, defaults to Alpine Linux with uv. |
Example
dagger -m github.com/dagger/pytest@fe4e2f5fa4cf40ee037195b2c7d19620a4027234 call \
func (m *MyModule) Example() *dagger.Pytest {
return dag.
Pytest()
}@function
def example() -> dagger.Pytest:
return (
dag.pytest()
)@func()
example(): Pytest {
return dag
.pytest()
}Types
Pytest 🔗
source() 🔗
Optional: The source directory containing your Python project
Return Type
Directory ! Example
dagger -m github.com/dagger/pytest@fe4e2f5fa4cf40ee037195b2c7d19620a4027234 call \
sourcefunc (m *MyModule) Example() *dagger.Directory {
return dag.
Pytest().
Source()
}@function
def example() -> dagger.Directory:
return (
dag.pytest()
.source()
)@func()
example(): Directory {
return dag
.pytest()
.source()
}container() 🔗
Optional: A custom container with Python and uv installed. If not provided, defaults to Alpine Linux with uv.
Return Type
Container Example
dagger -m github.com/dagger/pytest@fe4e2f5fa4cf40ee037195b2c7d19620a4027234 call \
containerfunc (m *MyModule) Example() *dagger.Container {
return dag.
Pytest().
Container()
}@function
def example() -> dagger.Container:
return (
dag.pytest()
.container()
)@func()
example(): Container {
return dag
.pytest()
.container()
}test() 🔗
Test a Python project with pytest and OpenTelemetry tracing.
This function automatically injects pytest_otel for test tracing visibility in Dagger TUI and Dagger Cloud. No configuration required.
The function will:
- Reuse the provided container’s Python environment, or default to Alpine
Linux with uv and provision Python for the requested version
- Inject pytest_otel for automatic test tracing
- Install your project dependencies (via uv run for pyproject, or requirements.txt)
- Run pytest with the specified Python version
Return Type
Void !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| args | [String ! ] | - | Additional arguments to pass to pytest (e.g., ["-x", "--tb=short"]) |
| version | String | - | Python version to use (e.g., "3.14", "3.13", "3.12") |
Example
dagger -m github.com/dagger/pytest@fe4e2f5fa4cf40ee037195b2c7d19620a4027234 call \
testfunc (m *MyModule) Example(ctx context.Context) {
return dag.
Pytest().
Test(ctx)
}@function
async def example() -> None:
return await (
dag.pytest()
.test()
)@func()
async example(): Promise<void> {
return dag
.pytest()
.test()
}