Unit Testing Pulumi programs in Python
An example that applies unit testing to Python and AWS resources.
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set testing-unit-pycd pulumi-examples/testing-unit-pyAn example of writing mock-based unit tests with both infrastructure definition and tests written in Python. The example uses the unittest test framework to define and run the tests.
Running the tests#
-
Create a Python virtualenv, activate it, and install dependencies:
Terminal window python3 -m venv venvsource venv/bin/activatepython -m pip install --upgrade pippython -m pip install -r requirements.txt -
Run the tests:
python -m unittest -vFurther steps#
Learn more about testing Pulumi programs: