Skip to content

Commit

Permalink
test ValidationError on Atomate2Settings with invalid VASP_CMD and BA…
Browse files Browse the repository at this point in the history
…NDGAP_TOL
  • Loading branch information
janosh committed Oct 14, 2023
1 parent ead2dbc commit fd0109b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/common/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from pydantic import ValidationError


def test_empty_and_invalid_config_file(clean_dir):
Expand All @@ -24,3 +25,24 @@ def test_empty_and_invalid_config_file(clean_dir):

with pytest.raises(SyntaxError, match="atomate2 config file at"):
Atomate2Settings()

# test error if the file exists and contains invalid settings
with open(config_file_path, "w") as file:
file.write("VASP_CMD: 42")

with pytest.raises(
ValidationError,
match="1 validation error for Atomate2Settings\nVASP_CMD\n "
"Input should be a valid string ",
):
Atomate2Settings()

with open(config_file_path, "w") as file:
file.write("BANDGAP_TOL: invalid")

with pytest.raises(
ValidationError,
match="1 validation error for Atomate2Settings\nBANDGAP_TOL\n "
"Input should be a valid number",
):
Atomate2Settings()

0 comments on commit fd0109b

Please sign in to comment.