-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
027f84b
commit 083879a
Showing
1 changed file
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Test testing utils.""" | ||
|
||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
from pymatgen.core import Element, Structure | ||
from pymatgen.io.vasp.inputs import Kpoints | ||
from pymatgen.util.testing import PymatgenTest | ||
|
||
|
||
class TestPymatgenTest(PymatgenTest): | ||
def test_deprecated(self): | ||
pass | ||
|
||
def test_tmp_dir(self): | ||
current_dir = Path.cwd() | ||
assert current_dir == self.tmp_path | ||
|
||
assert self.tmp_path.is_dir() | ||
|
||
test_file = self.tmp_path / "test_file.txt" | ||
test_file.write_text("Hello, pytest!") | ||
|
||
assert test_file.exists() | ||
assert test_file.read_text() == "Hello, pytest!" | ||
|
||
def test_get_structure(self): | ||
assert isinstance(self.get_structure("LiFePO4"), Structure) | ||
|
||
def test_assert_str_content_equal(self): | ||
# TODO: see PR 4205, assert_str_content_equal has a minor bug | ||
# and would not raise AssertError but return a boolean only | ||
assert self.assert_str_content_equal("hi", " hi") | ||
assert not self.assert_str_content_equal("hi", "world") | ||
|
||
def test_serialize_with_pickle(self): | ||
result = self.serialize_with_pickle(Element.from_Z(1)) | ||
assert isinstance(result, list) | ||
assert result[0] is Element.H | ||
|
||
def test_assert_msonable(self): | ||
kpoints = Kpoints.gamma_automatic((3, 3, 3), [0, 0, 0]) | ||
kp_str = self.assert_msonable(kpoints) | ||
assert "Automatic kpoint scheme" in kp_str |