Skip to content

Commit 2c95aff

Browse files
author
Yuan Chiang
committed
force _download_and_unzip_atomic_densities to be called in pytest
1 parent aba55c7 commit 2c95aff

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/command_line/test_chargemol_caller.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_parse_chargemol(monkeypatch, mock_xyz):
9393

9494

9595
def fake_download(self, version: str = "latest", verbose: bool = True) -> None:
96+
print("fake download")
9697
extraction_path = "~/.cache/pymatgen/ddec"
9798
os.makedirs(os.path.expanduser(extraction_path), exist_ok=True)
9899

@@ -129,18 +130,17 @@ def test_fake_download_and_modify_path(monkeypatch):
129130
monkeypatch.setattr(
130131
ChargemolAnalysis,
131132
"_download_and_unzip_atomic_densities",
132-
lambda self, version, verbose: fake_download(self),
133+
lambda self: fake_download(self),
133134
)
134135

135136
# Create an instance of ChargemolAnalysis
136137
test_dir = f"{TEST_FILES_DIR}/chargemol/spin_unpolarized"
138+
137139
ca = ChargemolAnalysis(
138140
path=test_dir,
139-
# atomic_densities_path=os.path.expanduser("~/.cache/pymatgen/ddec"),
141+
atomic_densities_path="fake_path", # force _download_and_unzip_atomic_densities to be called
140142
run_chargemol=False,
141143
)
142144

143145
# Your assertions
144-
assert ca._atomic_densities_path == os.getcwd()
145-
# assert ca._atomic_densities_path == os.path.expanduser("~/.cache/pymatgen/ddec")
146-
# TODO: Add more tests to ensure Chargemol was run correctly
146+
assert ca._atomic_densities_path == os.path.expanduser("~/.cache/pymatgen/ddec")

0 commit comments

Comments
 (0)