Dagger
Search

pytest

A toolchain for testing Python applications with automatic OpenTelemetry tracing

Installation

dagger install github.com/dagger/pytest@9b75a311bb746ad05a79aa16fc799b61149f7ee4

Entrypoint

Return Type
Pytest !
Arguments
NameTypeDefault ValueDescription
sourceDirectory -No description provided
containerContainer -No description provided
Example
dagger -m github.com/dagger/pytest@9b75a311bb746ad05a79aa16fc799b61149f7ee4 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@9b75a311bb746ad05a79aa16fc799b61149f7ee4 call \
 source
func (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 Wolfi Linux with uv.

Return Type
Container 
Example
dagger -m github.com/dagger/pytest@9b75a311bb746ad05a79aa16fc799b61149f7ee4 call \
 container
func (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: - Use the provided container or default to Wolfi Linux with uv - Install your project dependencies using uv sync - Inject pytest_otel for automatic test tracing - Run pytest with the specified Python version

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
args[String ! ] -No description provided
versionString -No description provided
Example
dagger -m github.com/dagger/pytest@9b75a311bb746ad05a79aa16fc799b61149f7ee4 call \
 test
func (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()
}