forked from davidwaroquiers/atomate2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request materialsproject#522 from materialsproject/warn-on…
…-empty-config Warn on empty config
- Loading branch information
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
|
||
def test_empty_and_invalid_config_file(clean_dir): | ||
import os | ||
from pathlib import Path | ||
|
||
from atomate2.settings import Atomate2Settings | ||
|
||
# set path to load settings from though ATOMATE2_CONFIG_FILE env variable | ||
config_file_path = Path.cwd() / "test-atomate2-config.yaml" | ||
os.environ["ATOMATE2_CONFIG_FILE"] = str(config_file_path) | ||
|
||
# test warning if config file is empty | ||
config_file_path.touch() | ||
with pytest.warns( | ||
UserWarning, match="Using atomate2 config file at .+ but it's empty" | ||
): | ||
Atomate2Settings() | ||
|
||
# test error if the file exists and contains invalid YAML | ||
with open(config_file_path, "w") as file: | ||
file.write("invalid yaml") | ||
|
||
with pytest.raises(SyntaxError, match="atomate2 config file at"): | ||
Atomate2Settings() |