Skip to content

Commit

Permalink
switch to monkey patch for setting env vars for test
Browse files Browse the repository at this point in the history
  • Loading branch information
briangrahamww committed May 8, 2020
1 parent bf82516 commit 06cfde0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from primrose.writers.abstract_file_writer import AbstractFileWriter
from primrose.node_factory import NodeFactory

@pytest.fixture
def mock_env(monkeypatch):
monkeypatch.setenv("PRIMROSE_EXT_NODE_PACKAGE", "test")

def test_init_error0():
config = {}
with pytest.raises(Exception) as e:
Expand Down Expand Up @@ -463,7 +467,7 @@ def test_yaml_perform_any_config_fragment_substitution():
"""
assert final_str == expected

def test_class_prefix():
def test_class_prefix(mock_env):
config_path = {
"implementation_config": {
"reader_config": {
Expand Down Expand Up @@ -493,7 +497,7 @@ def test_class_prefix():
NodeFactory().unregister('TestExtNode')


def test_class_package():
def test_class_package(mock_env):
config_path = {
"metadata": {
"class_package": "test"
Expand Down Expand Up @@ -534,15 +538,14 @@ def test_class_package():
}
}
}
os.environ['PRIMROSE_EXT_NODE_PACKAGE'] = 'test'
for config in [config_full_path, config_path, config_full_dot]:
config = Configuration(config_location=None, is_dict_config=True, dict_config=config)
assert config.config_string
assert config.config_hash
NodeFactory().unregister('TestExtNode')


def test_env_override_class_package():
def test_env_override_class_package(mock_env):
config = {
"metadata": {
"class_package": "junk"
Expand All @@ -556,12 +559,10 @@ def test_env_override_class_package():
}
}
}
os.environ['PRIMROSE_EXT_NODE_PACKAGE'] = 'test'
config = Configuration(config_location=None, is_dict_config=True, dict_config=config)
assert config.config_string
assert config.config_hash
NodeFactory().unregister('TestExtNode')
os.environ.pop('PRIMROSE_EXT_NODE_PACKAGE')


def test_incorrect_class_package():
Expand Down

0 comments on commit 06cfde0

Please sign in to comment.