Skip to content

Commit

Permalink
Fixed test_environment_vars_in_config_file
Browse files Browse the repository at this point in the history
Some small changes to get this test to work. Unfortunately
diffenigne.config is a global in the diffengine module, and
changing it doesn't play nicely with the tests. I added a
return value for diffengine.load_config that makes this easier.

refs #67
  • Loading branch information
edsu committed Apr 26, 2020
1 parent 564b26e commit baaa945
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ diffengine.egg-info
build
Pip*
.venv
.env
1 change: 1 addition & 0 deletions diffengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def load_config(prompt=True):
if prompt:
config = get_initial_config()
yaml.dump(config, open(config_file, "w"), default_flow_style=False)
return config

def get_initial_config():
config = {"feeds": []}
Expand Down
11 changes: 5 additions & 6 deletions test_diffengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,12 @@ def test_environment_vars_in_config_file():
"public_value": public_value
}
}
config_file = home_path(test_home, "config.yaml");
config_file = home_path("config.yaml");
yaml.dump(test_config, open(config_file, "w"), default_flow_style=False)

# Test!
init("test")
config = get_initial_config()
assert config['example']['public_value'] == public_value
assert config['example']['private_value'] != private_yaml_key
assert config['example']['private_value'] == private_value
new_config = load_config()
assert new_config['example']['public_value'] == public_value
assert new_config['example']['private_value'] != private_yaml_key
assert new_config['example']['private_value'] == private_value

0 comments on commit baaa945

Please sign in to comment.