pytest-terraform
pytest-terraform copied to clipboard
TEARDOWN_OFF does not seem to work with scopes other than function
The following snippet produces an apply and destroy despite the teardown option. Other scopes such as module produce the same result.
@terraform('network', scope='session', teardown=terraform.TEARDOWN_OFF)
def test_network(network):
assert network['aws_vpc.main.cidr_block'] == '10.0.0.0/16'
When removing the scope
argument and letting it default to function, the terraform is applied but not destroyed, as expected. Is there anything I am doing incorrectly?
hmm, thanks for the bug report.
+1
I have a use case for retaining the output of a local file resource to help with automated documentation. The output from my test is added to the README.md to illustrate features to the user.
A workaround for my use case is to copy the file within a test case. Terraform will still destroy the file it created, but the copied one remains in-tact.