Skip to content

Commit

Permalink
I-26 - move test environment variables to setup/teardown methods
Browse files Browse the repository at this point in the history
  • Loading branch information
furiousassault committed Aug 28, 2018
1 parent 860b443 commit 1af0a8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ class TestContextGeneration(unittest.TestCase):
def setUp(self):
settings.CONFIG_FILE = 'tests/fixtures/config.yaml'
settings.TEMPLATES_DIR = 'templates/tests'
os.environ['CUSTOM_ENV'] = 'My value'
os.environ['K8S_CONFIG_DIR'] = '/tmp/kube/'

def tearDown(self):
if os.path.exists(settings.TEMP_DIR):
shutil.rmtree(settings.TEMP_DIR)

os.environ.pop('CUSTOM_ENV')
os.environ.pop('K8S_CONFIG_DIR')

def test_config_not_exist(self):
settings.CONFIG_FILE = 'tests/config.yaml'
with self.assertRaises(Exception) as context:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ class TestTemplating(unittest.TestCase):
def setUp(self):
settings.CONFIG_FILE = 'tests/fixtures/config.yaml'
settings.TEMPLATES_DIR = 'templates/tests'
os.environ['CUSTOM_ENV'] = 'My value'
os.environ['K8S_CONFIG_DIR'] = '/tmp/kube/'

def tearDown(self):
if os.path.exists(settings.TEMP_DIR):
shutil.rmtree(settings.TEMP_DIR)

os.environ.pop('CUSTOM_ENV')
os.environ.pop('K8S_CONFIG_DIR')

def test_renderer_init(self):
r = templating.Renderer()
expected = os.path.join(os.path.dirname(__file__), '../templates')
Expand Down
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ deps = -r {toxinidir}/requirements.txt
coveralls

setenv = LOG_LEVEL=DEBUG
CUSTOM_ENV=My value
K8S_CONFIG_DIR=/tmp/kube/

commands = flake8
coverage erase
Expand Down

0 comments on commit 1af0a8d

Please sign in to comment.