fix teardown

merge-requests/1/head
Freddy Tan 8 years ago
parent 839b30d72a
commit df78cfe9be

@ -3,6 +3,7 @@ import pytest
import os
import logging
import re
import shutil
logging.basicConfig(level=logging.DEBUG)
current_path = os.path.dirname(os.path.realpath(__file__))
@ -31,6 +32,19 @@ CMD_CASES = [
]
]
@pytest.fixture()
def fmt_test_file(request):
target = os.path.join(current_path, 'bad_fmt', 'test.backup')
orgin = os.path.join(current_path, 'bad_fmt', 'test.tf')
shutil.copy(orgin,
target)
def td():
shutil.move(target, orgin)
request.addfinalizer(td)
return
class TestTerraform(object):
def teardown_method(self, method):
@ -86,13 +100,11 @@ class TestTerraform(object):
('fmt', ['bad_fmt'], {'list': False, 'diff': False})
]
)
def test_options(self, cmd, args, options):
def test_options(self, cmd, args, options, fmt_test_file):
tf = Terraform(working_dir=current_path)
ret, out, err = getattr(tf, cmd)(*args, **options)
assert ret == 0
assert out == ''
# todo revert the test file
def test_state_data(self):
cwd = os.path.join(current_path, 'test_tfstate_file')

Loading…
Cancel
Save