fix teardown
This commit is contained in:
parent
839b30d72a
commit
df78cfe9be
1 changed files with 15 additions and 3 deletions
|
@ -3,6 +3,7 @@ import pytest
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
current_path = os.path.dirname(os.path.realpath(__file__))
|
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):
|
class TestTerraform(object):
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
|
@ -86,13 +100,11 @@ class TestTerraform(object):
|
||||||
('fmt', ['bad_fmt'], {'list': False, 'diff': False})
|
('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)
|
tf = Terraform(working_dir=current_path)
|
||||||
ret, out, err = getattr(tf, cmd)(*args, **options)
|
ret, out, err = getattr(tf, cmd)(*args, **options)
|
||||||
assert ret == 0
|
assert ret == 0
|
||||||
assert out == ''
|
assert out == ''
|
||||||
# todo revert the test file
|
|
||||||
|
|
||||||
|
|
||||||
def test_state_data(self):
|
def test_state_data(self):
|
||||||
cwd = os.path.join(current_path, 'test_tfstate_file')
|
cwd = os.path.join(current_path, 'test_tfstate_file')
|
||||||
|
|
Loading…
Reference in a new issue