Skip to main content

astro dev pytest

Run unit tests for your data pipelines on Astro with pytest, a testing framework for Python. When you run this command, the Astro CLI creates a local Python environment that includes your DAG code, dependencies, and Astro Runtime Docker image. The CLI then runs any pytests in the tests directory of your Astro project and shows you the results of those tests in your terminal.

For more information on this functionality, see Test and troubleshoot locally.

info

This command requires Astro Runtime version 4.1.0+. For more information, see Astro Runtime Release Notes.

Usage

astro dev pytest

Options

OptionDescriptionPossible Values
<pytest-filepath>The filepath to an alternative pytest file or directory. Must be within the tests directoryAny valid filepath within the tests directory
-e, --envThe filepath to your environment variables. The default is .env)Any valid filepath within your Astro project
-i, --image-nameThe name of a pre-built custom Docker image to use with your project. The image must be available from a Docker registry hosted on your local machineA valid name for a pre-built Docker image based on Astro Runtime

Examples

$ astro dev pytest --env=myAlternativeEnvFile.env
# Specify env file at root of Astro project