diff --git a/tests/alchemy/test_filters.py b/tests/alchemy/test_filters.py index 16737ae67fa..8810ca30551 100644 --- a/tests/alchemy/test_filters.py +++ b/tests/alchemy/test_filters.py @@ -14,10 +14,10 @@ from pymatgen.alchemy.transmuters import StandardTransmuter from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import Lattice, Species, Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR -class TestContainsSpecieFilter(PymatgenTest): +class TestContainsSpecieFilter: def test_filtering(self): coords = [[0, 0, 0], [0.75, 0.75, 0.75], [0.5, 0.5, 0.5], [0.25, 0.25, 0.25]] lattice = Lattice([[3.0, 0.0, 0.0], [1.0, 3.0, 0], [0, -2.0, 3.0]]) @@ -52,7 +52,7 @@ def test_as_from_dict(self): assert isinstance(ContainsSpecieFilter.from_dict(dct), ContainsSpecieFilter) -class TestSpecieProximityFilter(PymatgenTest): +class TestSpecieProximityFilter: def test_filter(self): struct = self.get_structure("Li10GeP2S12") sf = SpecieProximityFilter({"Li": 1}) diff --git a/tests/alchemy/test_materials.py b/tests/alchemy/test_materials.py index 25b8cc74ad2..2569b7ec46c 100644 --- a/tests/alchemy/test_materials.py +++ b/tests/alchemy/test_materials.py @@ -21,7 +21,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/alchemy" -class TestTransformedStructure(PymatgenTest): +class TestTransformedStructure: def setUp(self): structure = PymatgenTest.get_structure("LiFePO4") self.structure = structure diff --git a/tests/alchemy/test_transmuters.py b/tests/alchemy/test_transmuters.py index 653a98c5326..17cabc9d930 100644 --- a/tests/alchemy/test_transmuters.py +++ b/tests/alchemy/test_transmuters.py @@ -8,10 +8,10 @@ RemoveSpeciesTransformation, SubstitutionTransformation, ) -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR -class TestCifTransmuter(PymatgenTest): +class TestCifTransmuter: def test_init(self): trafos = [SubstitutionTransformation({"Fe": "Mn", "Fe2+": "Mn2+"})] tsc = CifTransmuter.from_filenames([f"{TEST_FILES_DIR}/cif/MultiStructure.cif"], trafos) @@ -22,7 +22,7 @@ def test_init(self): assert expected == els -class TestPoscarTransmuter(PymatgenTest): +class TestPoscarTransmuter: def test_init(self): trafos = [SubstitutionTransformation({"Fe": "Mn"})] tsc = PoscarTransmuter.from_filenames([f"{VASP_IN_DIR}/POSCAR", f"{VASP_IN_DIR}/POSCAR"], trafos) diff --git a/tests/analysis/chemenv/connectivity/test_connected_components.py b/tests/analysis/chemenv/connectivity/test_connected_components.py index fc9e561c57e..311f60381fa 100644 --- a/tests/analysis/chemenv/connectivity/test_connected_components.py +++ b/tests/analysis/chemenv/connectivity/test_connected_components.py @@ -20,12 +20,12 @@ from pymatgen.core.lattice import Lattice from pymatgen.core.sites import PeriodicSite from pymatgen.core.structure import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" -class TestConnectedComponent(PymatgenTest): +class TestConnectedComponent: def test_init(self): # Generic connected component not using EnvironmentNodes # (as_dict won't work on such a ConnectedComponent instance) diff --git a/tests/analysis/chemenv/connectivity/test_environment_nodes.py b/tests/analysis/chemenv/connectivity/test_environment_nodes.py index 60af01acff7..c009a735c81 100644 --- a/tests/analysis/chemenv/connectivity/test_environment_nodes.py +++ b/tests/analysis/chemenv/connectivity/test_environment_nodes.py @@ -3,7 +3,6 @@ import json from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode -from pymatgen.util.testing import PymatgenTest try: import bson @@ -13,7 +12,7 @@ __author__ = "waroquiers" -class TestEnvironmentNodes(PymatgenTest): +class TestEnvironmentNodes: def test_equal(self): struct = self.get_structure("SiO2") en = EnvironmentNode(central_site=struct[0], i_central_site=0, ce_symbol="T:4") diff --git a/tests/analysis/chemenv/connectivity/test_structure_connectivity.py b/tests/analysis/chemenv/connectivity/test_structure_connectivity.py index 37f8da4b98a..bb0452bb747 100644 --- a/tests/analysis/chemenv/connectivity/test_structure_connectivity.py +++ b/tests/analysis/chemenv/connectivity/test_structure_connectivity.py @@ -9,12 +9,12 @@ LightStructureEnvironments, StructureEnvironments, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" -class TestStructureConnectivity(PymatgenTest): +class TestStructureConnectivity: def test_serialization(self): BaTiO3_se_fpath = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments/se_mp-5020.json" with open(BaTiO3_se_fpath) as file: diff --git a/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py b/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py index 64516b22c41..7c83da588b8 100644 --- a/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py +++ b/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py @@ -10,12 +10,11 @@ DistanceCutoffFloat, SimplestChemenvStrategy, ) -from pymatgen.util.testing import PymatgenTest __author__ = "waroquiers" -class TestStrategyOptions(PymatgenTest): +class TestStrategyOptions: def test_options(self): # DistanceCutoffFloat with pytest.raises(ValueError, match=r"Distance cutoff should be between 1 and \+infinity"): diff --git a/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py b/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py index 18fc1675835..30d54b9657b 100644 --- a/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py +++ b/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py @@ -11,7 +11,6 @@ ExplicitPermutationsAlgorithm, SeparationPlane, ) -from pymatgen.util.testing import PymatgenTest __author__ = "waroquiers" @@ -23,7 +22,7 @@ def __init__(self, coords): self.coords = coords -class TestCoordinationGeometries(PymatgenTest): +class TestCoordinationGeometries: def test_algorithms(self): expl_algo = ExplicitPermutationsAlgorithm(permutations=[[0, 1, 2], [1, 2, 3]]) expl_algo2 = ExplicitPermutationsAlgorithm.from_dict(expl_algo.as_dict()) diff --git a/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py b/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py index 01aedf2d245..f780d439cf7 100644 --- a/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py +++ b/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py @@ -19,14 +19,14 @@ symmetry_measure, ) from pymatgen.core.structure import Lattice, Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" json_dir = f"{TEST_FILES_DIR}/analysis/chemenv/json" -class TestCoordinationGeometryFinder(PymatgenTest): +class TestCoordinationGeometryFinder: def setUp(self): self.lgf = LocalGeometryFinder() self.lgf.setup_parameters( diff --git a/tests/analysis/chemenv/coordination_environments/test_read_write.py b/tests/analysis/chemenv/coordination_environments/test_read_write.py index 640770fccad..c120b333953 100644 --- a/tests/analysis/chemenv/coordination_environments/test_read_write.py +++ b/tests/analysis/chemenv/coordination_environments/test_read_write.py @@ -22,7 +22,7 @@ ) from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer from pymatgen.core.structure import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" @@ -30,7 +30,7 @@ struct_env_dir = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments" -class TestReadWriteChemenv(PymatgenTest): +class TestReadWriteChemenv: @classmethod def setUpClass(cls): cls.lgf = LocalGeometryFinder() diff --git a/tests/analysis/chemenv/coordination_environments/test_structure_environments.py b/tests/analysis/chemenv/coordination_environments/test_structure_environments.py index 3f8bde41636..4128b3e0265 100644 --- a/tests/analysis/chemenv/coordination_environments/test_structure_environments.py +++ b/tests/analysis/chemenv/coordination_environments/test_structure_environments.py @@ -17,14 +17,14 @@ StructureEnvironments, ) from pymatgen.core import Species, Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" TEST_DIR = f"{TEST_FILES_DIR}/analysis/chemenv/structure_environments" -class TestStructureEnvironments(PymatgenTest): +class TestStructureEnvironments: def test_structure_environments(self): with open(f"{TEST_DIR}/se_mp-7000.json") as file: dct = json.load(file) diff --git a/tests/analysis/chemenv/coordination_environments/test_voronoi.py b/tests/analysis/chemenv/coordination_environments/test_voronoi.py index 492cc00df36..6e5a2f10779 100644 --- a/tests/analysis/chemenv/coordination_environments/test_voronoi.py +++ b/tests/analysis/chemenv/coordination_environments/test_voronoi.py @@ -5,14 +5,14 @@ from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" img_files_dir = f"{TEST_FILES_DIR}/analysis/chemenv/images" -class TestVoronoiContainer(PymatgenTest): +class TestVoronoiContainer: def test_voronoi(self): # Define a cubic lattice and a list of species (to be used for the fake structures) cubic_lattice = Lattice.cubic(10) diff --git a/tests/analysis/chemenv/coordination_environments/test_weights.py b/tests/analysis/chemenv/coordination_environments/test_weights.py index 6a5b2ffe50a..56cffa85a00 100644 --- a/tests/analysis/chemenv/coordination_environments/test_weights.py +++ b/tests/analysis/chemenv/coordination_environments/test_weights.py @@ -16,7 +16,7 @@ SelfCSMNbSetWeight, ) from pymatgen.analysis.chemenv.coordination_environments.structure_environments import StructureEnvironments -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" @@ -39,7 +39,7 @@ class DummyVoronoiContainer: pass -class StrategyWeights(PymatgenTest): +class StrategyWeights: def test_angle_weight(self): fake_nb_set = FakeNbSet() dummy_se = DummyStructureEnvironments() diff --git a/tests/analysis/chemenv/utils/test_chemenv_config.py b/tests/analysis/chemenv/utils/test_chemenv_config.py index bea8a66770f..3d495f2467f 100644 --- a/tests/analysis/chemenv/utils/test_chemenv_config.py +++ b/tests/analysis/chemenv/utils/test_chemenv_config.py @@ -2,14 +2,14 @@ from pymatgen.analysis.chemenv.utils.chemenv_config import ChemEnvConfig from pymatgen.core import SETTINGS -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "waroquiers" config_file_dir = f"{TEST_FILES_DIR}/analysis/chemenv/config" -class TestChemenvConfig(PymatgenTest): +class TestChemenvConfig: def test_chemenv_config(self): config = ChemEnvConfig() diff --git a/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py b/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py index d7cbc5b7f19..2439885c09d 100644 --- a/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py +++ b/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py @@ -7,12 +7,11 @@ from pytest import approx from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import Plane -from pymatgen.util.testing import PymatgenTest __author__ = "David Waroquiers" -class TestPlanesUtils(PymatgenTest): +class TestPlanesUtils: def setUp(self): # Test of plane 4x + 2y - 4z + 3 = 0 (used in most test cases) self.expected_coefficients = np.array([4, 2, -4, 3], float) diff --git a/tests/analysis/chemenv/utils/test_graph_utils.py b/tests/analysis/chemenv/utils/test_graph_utils.py index b5f32fe7e94..a936a7a5d26 100644 --- a/tests/analysis/chemenv/utils/test_graph_utils.py +++ b/tests/analysis/chemenv/utils/test_graph_utils.py @@ -5,7 +5,6 @@ from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode from pymatgen.analysis.chemenv.utils.graph_utils import MultiGraphCycle, SimpleGraphCycle, get_delta -from pymatgen.util.testing import PymatgenTest __author__ = "waroquiers" @@ -68,7 +67,7 @@ def __lt__(self, other): return self.isite % 2 < other.isite % 2 -class TestGraphUtils(PymatgenTest): +class TestGraphUtils: def test_get_delta(self): n1 = FakeNode(3) n2 = FakeNode(7) @@ -664,7 +663,7 @@ def test_multigraph_cycle(self): assert mgc.edge_indices == edges_ref, f"Edges not equal for inodes = ({str_nodes})" -class TestEnvironmentNodesGraphUtils(PymatgenTest): +class TestEnvironmentNodesGraphUtils: def test_cycle(self): e1 = EnvironmentNode(central_site="Si", i_central_site=0, ce_symbol="T:4") e2 = EnvironmentNode(central_site="Si", i_central_site=3, ce_symbol="T:4") diff --git a/tests/analysis/chemenv/utils/test_math_utils.py b/tests/analysis/chemenv/utils/test_math_utils.py index d3583a24851..90e09e38d09 100644 --- a/tests/analysis/chemenv/utils/test_math_utils.py +++ b/tests/analysis/chemenv/utils/test_math_utils.py @@ -16,12 +16,11 @@ smootherstep, smoothstep, ) -from pymatgen.util.testing import PymatgenTest __author__ = "waroquiers" -class TestMathUtils(PymatgenTest): +class TestMathUtils: def test_list_cartesian_product(self): list_of_lists = [[0, 1], [2, 5, 4], [5]] assert _cartesian_product(lists=list_of_lists) == [ diff --git a/tests/analysis/diffraction/test_neutron.py b/tests/analysis/diffraction/test_neutron.py index 4de897d85d6..0e7ced4628d 100644 --- a/tests/analysis/diffraction/test_neutron.py +++ b/tests/analysis/diffraction/test_neutron.py @@ -6,7 +6,6 @@ from pymatgen.analysis.diffraction.neutron import NDCalculator from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure -from pymatgen.util.testing import PymatgenTest """ These calculated values were verified with VESTA and FullProf. @@ -20,7 +19,7 @@ __date__ = "4/19/18" -class TestNDCalculator(PymatgenTest): +class TestNDCalculator: def test_get_pattern(self): struct = self.get_structure("CsCl") c = NDCalculator(wavelength=1.54184) # CuKa radiation diff --git a/tests/analysis/diffraction/test_tem.py b/tests/analysis/diffraction/test_tem.py index c8cfee3b1d5..e8dee624399 100644 --- a/tests/analysis/diffraction/test_tem.py +++ b/tests/analysis/diffraction/test_tem.py @@ -11,7 +11,6 @@ from pymatgen.analysis.diffraction.tem import TEMCalculator from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure -from pymatgen.util.testing import PymatgenTest __author__ = "Frank Wan, Jason Liang" __copyright__ = "Copyright 2019, The Materials Project" @@ -21,7 +20,7 @@ __date__ = "2/20/20" -class TestTEMCalculator(PymatgenTest): +class TestTEMCalculator: def test_wavelength_rel(self): # Test that the relativistic wavelength formula (for 200 kV electron beam) is correct tem_calc = TEMCalculator() diff --git a/tests/analysis/diffraction/test_xrd.py b/tests/analysis/diffraction/test_xrd.py index 997c43de42b..4a40a24577e 100644 --- a/tests/analysis/diffraction/test_xrd.py +++ b/tests/analysis/diffraction/test_xrd.py @@ -6,7 +6,6 @@ from pymatgen.analysis.diffraction.xrd import XRDCalculator from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure -from pymatgen.util.testing import PymatgenTest __author__ = "Shyue Ping Ong" __copyright__ = "Copyright 2012, The Materials Project" @@ -16,7 +15,7 @@ __date__ = "5/22/14" -class TestXRDCalculator(PymatgenTest): +class TestXRDCalculator: def test_type_wavelength(self): """Test TypeError is raised if wavelength is unaccepted type.""" wavelength = [1.78, 2.78] # just a list diff --git a/tests/analysis/elasticity/test_elastic.py b/tests/analysis/elasticity/test_elastic.py index 699f97d4061..7c6c39b11d0 100644 --- a/tests/analysis/elasticity/test_elastic.py +++ b/tests/analysis/elasticity/test_elastic.py @@ -27,12 +27,12 @@ from pymatgen.core.structure import Structure from pymatgen.core.tensors import Tensor from pymatgen.core.units import FloatWithUnit -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/elasticity" -class TestElasticTensor(PymatgenTest): +class TestElasticTensor: def setUp(self): self.voigt_1 = [ [59.33, 28.08, 28.08, 0, 0, 0], @@ -263,7 +263,7 @@ def test_energy_density(self): ) -class TestElasticTensorExpansion(PymatgenTest): +class TestElasticTensorExpansion: def setUp(self): with open(f"{TEST_DIR}/test_toec_data.json") as file: self.data_dict = json.load(file) @@ -364,7 +364,7 @@ def test_get_yield_stress(self): self.exp_cu_4.get_yield_stress([1, 0, 0]) -class TestNthOrderElasticTensor(PymatgenTest): +class TestNthOrderElasticTensor: def setUp(self): with open(f"{TEST_DIR}/test_toec_data.json") as file: self.data_dict = json.load(file) @@ -401,7 +401,7 @@ def test_energy_density(self): self.c3.energy_density(self.strains[0]) -class TestDiffFit(PymatgenTest): +class TestDiffFit: """Test various functions related to diff fitting.""" def setUp(self): diff --git a/tests/analysis/elasticity/test_strain.py b/tests/analysis/elasticity/test_strain.py index 9679fb367cd..53c33a5192a 100644 --- a/tests/analysis/elasticity/test_strain.py +++ b/tests/analysis/elasticity/test_strain.py @@ -7,10 +7,9 @@ from pymatgen.analysis.elasticity.strain import Deformation, DeformedStructureSet, Strain, convert_strain_to_deformation from pymatgen.core.structure import Structure from pymatgen.core.tensors import Tensor -from pymatgen.util.testing import PymatgenTest -class TestDeformation(PymatgenTest): +class TestDeformation: def setUp(self): self.norm_defo = Deformation.from_index_amount((0, 0), 0.02) self.ind_defo = Deformation.from_index_amount((0, 1), 0.02) @@ -81,7 +80,7 @@ def test_apply_to_structure(self): assert_allclose(new_coord, defo_coord) -class TestStrain(PymatgenTest): +class TestStrain: def setUp(self): self.norm_str = Strain.from_deformation([[1.02, 0, 0], [0, 1, 0], [0, 0, 1]]) self.ind_str = Strain.from_deformation([[1, 0.02, 0], [0, 1, 0], [0, 0, 1]]) @@ -142,7 +141,7 @@ def test_convert_strain_to_deformation(self): assert_allclose(defo.green_lagrange_strain, strain) -class TestDeformedStructureSet(PymatgenTest): +class TestDeformedStructureSet: def setUp(self): self.structure = self.get_structure("Sn") self.default_dss = DeformedStructureSet(self.structure) diff --git a/tests/analysis/elasticity/test_stress.py b/tests/analysis/elasticity/test_stress.py index 9d1dc98ad33..58e0bf1507c 100644 --- a/tests/analysis/elasticity/test_stress.py +++ b/tests/analysis/elasticity/test_stress.py @@ -7,10 +7,9 @@ from pymatgen.analysis.elasticity.strain import Deformation from pymatgen.analysis.elasticity.stress import Stress -from pymatgen.util.testing import PymatgenTest -class TestStress(PymatgenTest): +class TestStress: def setUp(self): self.rand_stress = Stress(np.random.default_rng().standard_normal((3, 3))) self.symm_stress = Stress([[0.51, 2.29, 2.42], [2.29, 5.14, 5.07], [2.42, 5.07, 5.33]]) diff --git a/tests/analysis/ferroelectricity/test_polarization.py b/tests/analysis/ferroelectricity/test_polarization.py index 57236ff98c4..71bb13d45e3 100644 --- a/tests/analysis/ferroelectricity/test_polarization.py +++ b/tests/analysis/ferroelectricity/test_polarization.py @@ -13,7 +13,7 @@ from pymatgen.core.structure import Structure from pymatgen.io.vasp.inputs import Potcar from pymatgen.io.vasp.outputs import Outcar -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/vasp/fixtures/BTO_221_99_polarization" bto_folders = ["nonpolar_polarization"] @@ -38,7 +38,7 @@ ) -class TestUtils(PymatgenTest): +class TestUtils: def setUp(self): self.potcar = Potcar.from_file(f"{TEST_DIR}/POTCAR") self.zval_dict = {"Ba": 10, "Ti": 10, "O": 6} @@ -54,7 +54,7 @@ def test_get_total_ionic_dipole(self): assert_allclose(p_ion, self.ions[-1].ravel().tolist()) -class TestPolarization(PymatgenTest): +class TestPolarization: def setUp(self): self.p_ions = ions self.p_ions_outcar = np.array( @@ -258,7 +258,7 @@ def test_smoothness(self): assert_allclose(self.smoothness_all_in_polar, smoothness) -class TestEnergyTrend(PymatgenTest): +class TestEnergyTrend: def setUp(self): self.energies = [ -7.97738049, diff --git a/tests/analysis/interfaces/test_coherent_interface.py b/tests/analysis/interfaces/test_coherent_interface.py index e2a19a73915..2e6bc1ba1bc 100644 --- a/tests/analysis/interfaces/test_coherent_interface.py +++ b/tests/analysis/interfaces/test_coherent_interface.py @@ -1,6 +1,6 @@ from __future__ import annotations -import unittest +from unittest import TestCase from numpy.testing import assert_allclose @@ -14,10 +14,9 @@ from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from pymatgen.util.testing import PymatgenTest -class TestInterfaceBuilder(PymatgenTest): +class TestInterfaceBuilder: @classmethod def setUpClass(cls): si_struct = cls.get_structure("Si") @@ -51,7 +50,7 @@ def test_coherent_interface_builder(self): assert len(list(builder.get_interfaces(termination=("O2_Pmmm_1", "Si_R-3m_1")))) >= 6 -class TestCoherentInterfaceBuilder(unittest.TestCase): +class TestCoherentInterfaceBuilder(TestCase): def setUp(self): # build substrate & film structure basis = [[0, 0, 0], [0.25, 0.25, 0.25]] diff --git a/tests/analysis/interfaces/test_zsl.py b/tests/analysis/interfaces/test_zsl.py index 25ab77950e1..cc7c8657403 100644 --- a/tests/analysis/interfaces/test_zsl.py +++ b/tests/analysis/interfaces/test_zsl.py @@ -13,7 +13,6 @@ vec_area, ) from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from pymatgen.util.testing import PymatgenTest __author__ = "Shyam Dwaraknath" __copyright__ = "Copyright 2016, The Materials Project" @@ -23,7 +22,7 @@ __date__ = "2/5/16" -class TestZSLGen(PymatgenTest): +class TestZSLGen: def setUp(self): # Film VO2 self.film = SpacegroupAnalyzer(self.get_structure("VO2"), symprec=0.1).get_conventional_standard_structure() diff --git a/tests/analysis/solar/test_slme.py b/tests/analysis/solar/test_slme.py index 3ccf3256d11..334e7d63a4c 100644 --- a/tests/analysis/solar/test_slme.py +++ b/tests/analysis/solar/test_slme.py @@ -3,12 +3,12 @@ from pytest import approx from pymatgen.analysis.solar.slme import optics, slme -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/solar" -class TestSolar(PymatgenTest): +class TestSolar: def test_slme_from_vasprun(self): en, abz, dir_gap, indir_gap = optics(f"{TEST_DIR}/vasprun.xml") abz *= 100.0 diff --git a/tests/analysis/structure_prediction/test_substitutor.py b/tests/analysis/structure_prediction/test_substitutor.py index 6965408afcc..be05f0bc60d 100644 --- a/tests/analysis/structure_prediction/test_substitutor.py +++ b/tests/analysis/structure_prediction/test_substitutor.py @@ -20,7 +20,7 @@ def get_table(): return json.load(file) -class TestSubstitutor(PymatgenTest): +class TestSubstitutor: def setUp(self): self.substitutor = Substitutor(threshold=1e-3, lambda_table=get_table(), alpha=-5.0) diff --git a/tests/analysis/structure_prediction/test_volume_predictor.py b/tests/analysis/structure_prediction/test_volume_predictor.py index 20ecf2bd24b..f75df75cf3a 100644 --- a/tests/analysis/structure_prediction/test_volume_predictor.py +++ b/tests/analysis/structure_prediction/test_volume_predictor.py @@ -10,7 +10,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/analysis/structure_prediction" -class TestRLSVolumePredictor(PymatgenTest): +class TestRLSVolumePredictor: def test_predict(self): struct = PymatgenTest.get_structure("CsCl") nacl = PymatgenTest.get_structure("CsCl") @@ -77,7 +77,7 @@ def test_modes(self): assert vol_pred.predict(cs_cl, na_cl) == approx(342.84905395082535) -class TestDLSVolumePredictor(PymatgenTest): +class TestDLSVolumePredictor: def test_predict(self): vol_pred = DLSVolumePredictor() p_fast = DLSVolumePredictor(cutoff=0.0) # for speed on compressed cells diff --git a/tests/analysis/test_adsorption.py b/tests/analysis/test_adsorption.py index ced3948a366..6a9dd3b070d 100644 --- a/tests/analysis/test_adsorption.py +++ b/tests/analysis/test_adsorption.py @@ -8,10 +8,9 @@ from pymatgen.core.structure import Molecule, Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.coord import in_coord_list -from pymatgen.util.testing import PymatgenTest -class TestAdsorbateSiteFinder(PymatgenTest): +class TestAdsorbateSiteFinder: def setUp(self): self.structure = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3.5), ["Ni"], [[0, 0, 0]]) lattice = Lattice.cubic(3.010) diff --git a/tests/analysis/test_bond_valence.py b/tests/analysis/test_bond_valence.py index a2e0db2ce0c..06c0fef3dc3 100644 --- a/tests/analysis/test_bond_valence.py +++ b/tests/analysis/test_bond_valence.py @@ -5,12 +5,12 @@ from pymatgen.analysis.bond_valence import BVAnalyzer, calculate_bv_sum, calculate_bv_sum_unordered from pymatgen.core import Composition, Species, Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/bond_valence" -class TestBVAnalyzer(PymatgenTest): +class TestBVAnalyzer: def setUp(self): self.analyzer = BVAnalyzer() @@ -44,7 +44,7 @@ def test_get_oxi_state_structure(self): assert Species("Mn4+") in oxi_struct.composition.elements -class TestBondValenceSum(PymatgenTest): +class TestBondValenceSum: def test_calculate_bv_sum(self): struct = Structure.from_file(f"{TEST_DIR}/LiMn2O4.json") neighbors = struct.get_neighbors(struct[0], 3.0) diff --git a/tests/analysis/test_chempot_diagram.py b/tests/analysis/test_chempot_diagram.py index 43dfd957b0d..192e4aaf9de 100644 --- a/tests/analysis/test_chempot_diagram.py +++ b/tests/analysis/test_chempot_diagram.py @@ -12,12 +12,12 @@ ) from pymatgen.core.composition import Element from pymatgen.entries.entry_tools import EntrySet -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis" -class TestChemicalPotentialDiagram(PymatgenTest): +class TestChemicalPotentialDiagram: def setUp(self): self.entries = EntrySet.from_csv(f"{TEST_DIR}/pd_entries_test.csv") self.cpd_ternary, self.cpd_ternary_formal = ( diff --git a/tests/analysis/test_dimensionality.py b/tests/analysis/test_dimensionality.py index 8b99c6fd5e2..0f1139e7072 100644 --- a/tests/analysis/test_dimensionality.py +++ b/tests/analysis/test_dimensionality.py @@ -15,10 +15,10 @@ from pymatgen.analysis.graphs import StructureGraph from pymatgen.analysis.local_env import CrystalNN from pymatgen.core.structure import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR -class TestLarsenDimensionality(PymatgenTest): +class TestLarsenDimensionality: def setUp(self): cnn = CrystalNN() self.lifepo = cnn.get_bonded_structure(self.get_structure("LiFePO4")) @@ -114,7 +114,7 @@ def test_zero_d_to_molecule_graph(self): assert len(mol_graph.molecule) == 12 -class TestCheonDimensionality(PymatgenTest): +class TestCheonDimensionality: def test_get_dimensionality(self): struct = self.get_structure("LiFePO4") assert get_dimensionality_cheon(struct) == "intercalated ion" @@ -152,7 +152,7 @@ def test_tricky_structure(self): assert get_dimensionality_cheon(tricky_structure, larger_cell=True) == "3D" -class TestGoraiDimensionality(PymatgenTest): +class TestGoraiDimensionality: def test_get_dimensionality(self): struct = self.get_structure("LiFePO4") assert get_dimensionality_gorai(struct) == 3 diff --git a/tests/analysis/test_disorder.py b/tests/analysis/test_disorder.py index f1fbd2f58d5..a00de0a8035 100644 --- a/tests/analysis/test_disorder.py +++ b/tests/analysis/test_disorder.py @@ -4,10 +4,9 @@ from pymatgen.analysis.disorder import get_warren_cowley_parameters from pymatgen.core import Element, Structure -from pymatgen.util.testing import PymatgenTest -class TestOrderParameter(PymatgenTest): +class TestOrderParameter: def test_compute_warren_cowley_parameters(self): struct = Structure.from_prototype("CsCl", ["Mo", "W"], a=4) aij = get_warren_cowley_parameters(struct, r=3.4, dr=0.3) diff --git a/tests/analysis/test_eos.py b/tests/analysis/test_eos.py index 9a839f8279b..da507c32035 100644 --- a/tests/analysis/test_eos.py +++ b/tests/analysis/test_eos.py @@ -5,10 +5,9 @@ from pytest import approx from pymatgen.analysis.eos import EOS, NumericalEOS -from pymatgen.util.testing import PymatgenTest -class TestEOS(PymatgenTest): +class TestEOS: def setUp(self): # Si data from Cormac self.volumes = [ diff --git a/tests/analysis/test_fragmenter.py b/tests/analysis/test_fragmenter.py index 211d7e3b7d1..c1efc2e69d6 100644 --- a/tests/analysis/test_fragmenter.py +++ b/tests/analysis/test_fragmenter.py @@ -8,7 +8,7 @@ from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.local_env import OpenBabelNN from pymatgen.core.structure import Molecule -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Samuel Blau" __email__ = "samblau1@gmail.com" @@ -17,7 +17,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/analysis/local_env/fragmenter_files" -class TestFragmentMolecule(PymatgenTest): +class TestFragmentMolecule: @classmethod def setUpClass(cls): cls.pc = Molecule.from_file(f"{TEST_DIR}/PC.xyz") diff --git a/tests/analysis/test_graphs.py b/tests/analysis/test_graphs.py index ad42533435c..9e0c9f9f83c 100644 --- a/tests/analysis/test_graphs.py +++ b/tests/analysis/test_graphs.py @@ -24,7 +24,7 @@ from pymatgen.command_line.critic2_caller import Critic2Analysis from pymatgen.core import Lattice, Molecule, Site, Structure from pymatgen.core.structure import FunctionalGroups -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR try: from openbabel import openbabel @@ -46,7 +46,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/analysis/graphs" -class TestStructureGraph(PymatgenTest): +class TestStructureGraph: def setUp(self): # trivial example, simple square lattice for testing structure = Structure(Lattice.tetragonal(5, 50), ["H"], [[0, 0, 0]]) diff --git a/tests/analysis/test_local_env.py b/tests/analysis/test_local_env.py index ac2ab8b099d..a6214fe1311 100644 --- a/tests/analysis/test_local_env.py +++ b/tests/analysis/test_local_env.py @@ -40,7 +40,7 @@ solid_angle, ) from pymatgen.core import Element, Lattice, Molecule, Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/local_env/fragmenter_files" @@ -54,7 +54,7 @@ def test_opt_params(): assert cn_opt_params == CN_OPT_PARAMS -class TestValenceIonicRadiusEvaluator(PymatgenTest): +class TestValenceIonicRadiusEvaluator: def setUp(self): """Setup MgO rocksalt structure for testing Vacancy.""" mgo_latt = np.eye(3) * 4.212 @@ -89,7 +89,7 @@ def test_radii_ionic_structure(self): assert rad in {0.86, 1.26} -class TestVoronoiNN(PymatgenTest): +class TestVoronoiNN: def setUp(self): self.struct = self.get_structure("LiFePO4") self.nn = VoronoiNN(targets=[Element("O")]) @@ -260,7 +260,7 @@ def test_filtered(self): assert [len(x) for x in all_nns] == [8] * 16 -class TestJmolNN(PymatgenTest): +class TestJmolNN: def setUp(self): self.jmol = JmolNN() self.jmol_update = JmolNN(el_radius_updates={"Li": 1}) @@ -290,7 +290,7 @@ def test_get_nn(self): assert len(self.jmol_update.get_nn(struct, 0)) == 2 -class TestIsayevNN(PymatgenTest): +class TestIsayevNN: def test_get_nn(self): inn = IsayevNN() struct = self.get_structure("LiFePO4") @@ -301,7 +301,7 @@ def test_get_nn(self): assert len(inn.get_nn(struct, 0)) == 2 -class TestOpenBabelNN(PymatgenTest): +class TestOpenBabelNN: def setUp(self): pytest.importorskip("openbabel") self.benzene = Molecule.from_file(f"{TEST_DIR}/../benzene.xyz") @@ -333,7 +333,7 @@ def test_nn_length(self): assert strategy.get_nn_info(self.acetylene, 0)[0]["weight"] == approx(1.19, abs=1e-2) -class TestCovalentBondNN(PymatgenTest): +class TestCovalentBondNN: def setUp(self): self.benzene = Molecule.from_file(f"{TEST_DIR}/../benzene.xyz") self.acetylene = Molecule.from_file(f"{TEST_FILES_DIR}/io/xyz/acetylene.xyz") @@ -372,7 +372,7 @@ def test_bonded_structure(self): assert len(acetylene.graph.nodes) == 4 -class TestMiniDistNN(PymatgenTest): +class TestMiniDistNN: def setUp(self): self.diamond = Structure( Lattice([[2.189, 0, 1.264], [0.73, 2.064, 1.264], [0, 0, 2.528]]), @@ -485,7 +485,7 @@ def test_get_local_order_params(self): assert ops["octahedral"] == approx(0.9999995266669) -class TestMotifIdentification(PymatgenTest): +class TestMotifIdentification: def setUp(self): self.silicon = Structure( Lattice.cubic(5.47), @@ -583,7 +583,7 @@ def test_get_neighbors_of_site_with_index(self): assert len(get_neighbors_of_site_with_index(self.diamond, 0, approach="min_VIRE")) == 4 -class TestNearNeighbor(PymatgenTest): +class TestNearNeighbor: def setUp(self): self.diamond = Structure( Lattice([[2.189, 0, 1.264], [0.73, 2.064, 1.264], [0, 0, 2.528]]), @@ -617,7 +617,7 @@ def test_on_disorder_options(self): ) -class TestLocalStructOrderParams(PymatgenTest): +class TestLocalStructOrderParams: def setUp(self): self.single_bond = Structure( Lattice.cubic(10), @@ -1182,7 +1182,7 @@ def test_get_order_parameters(self): ops_101.get_order_parameters(self.bcc, 0, indices_neighs=[2]) -class TestCrystalNN(PymatgenTest): +class TestCrystalNN: def setUp(self): self.lifepo4 = self.get_structure("LiFePO4") self.lifepo4.add_oxidation_state_by_guess() @@ -1329,7 +1329,7 @@ def test_get_bonded_structure(self): cnn.get_bonded_structure(self.disordered_struct, 0, on_disorder="error") -class TestCutOffDictNN(PymatgenTest): +class TestCutOffDictNN: def setUp(self): self.diamond = Structure( Lattice([[2.189, 0, 1.264], [0.73, 2.064, 1.264], [0, 0, 2.528]]), @@ -1355,7 +1355,7 @@ def test_from_preset(self): @pytest.mark.skipif(not which("critic2"), reason="critic2 executable not present") -class TestCritic2NN(PymatgenTest): +class TestCritic2NN: def setUp(self): self.diamond = Structure( Lattice([[2.189, 0, 1.264], [0.73, 2.064, 1.264], [0, 0, 2.528]]), @@ -1369,7 +1369,7 @@ def test_cn(self): # assert nn.get_cn(self.diamond, 0) == 4 -class TestMetalEdgeExtender(PymatgenTest): +class TestMetalEdgeExtender: def setUp(self): self.LiEC = Molecule.from_file(f"{TEST_DIR}/LiEC.xyz") self.phsh = Molecule.from_file(f"{TEST_DIR}/phsh.xyz") diff --git a/tests/analysis/test_nmr.py b/tests/analysis/test_nmr.py index 14490ec7a0c..e90dfddc6ca 100644 --- a/tests/analysis/test_nmr.py +++ b/tests/analysis/test_nmr.py @@ -5,10 +5,9 @@ from pytest import approx from pymatgen.analysis.nmr import ChemicalShielding, ElectricFieldGradient -from pymatgen.util.testing import PymatgenTest -class TestChemicalShieldingNotation(PymatgenTest): +class TestChemicalShieldingNotation: def test_construction(self): cs = ChemicalShielding(np.arange(9).reshape((3, 3))) assert cs.shape == (3, 3) @@ -46,7 +45,7 @@ def test_notations(self): assert mary1.kappa == approx(0.8337, abs=1e-5) -class TestElectricFieldGradient(PymatgenTest): +class TestElectricFieldGradient: def test_construction(self): efg = ElectricFieldGradient(np.arange(9).reshape((3, 3))) assert efg.shape == (3, 3) diff --git a/tests/analysis/test_phase_diagram.py b/tests/analysis/test_phase_diagram.py index 934ba59fa9d..b534aba8ddc 100644 --- a/tests/analysis/test_phase_diagram.py +++ b/tests/analysis/test_phase_diagram.py @@ -32,7 +32,7 @@ from pymatgen.core import Composition, DummySpecies, Element from pymatgen.entries.computed_entries import ComputedEntry from pymatgen.entries.entry_tools import EntrySet -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis" @@ -179,7 +179,7 @@ def test_normalize(self): assert norm_entry.composition == expected_comp -class TestPhaseDiagram(PymatgenTest): +class TestPhaseDiagram: def setUp(self): self.entries = EntrySet.from_csv(f"{TEST_DIR}/pd_entries_test.csv") self.pd = PhaseDiagram(self.entries) diff --git a/tests/analysis/test_piezo.py b/tests/analysis/test_piezo.py index bf3eb7534c2..0621591b44c 100644 --- a/tests/analysis/test_piezo.py +++ b/tests/analysis/test_piezo.py @@ -7,7 +7,6 @@ from numpy.testing import assert_allclose, assert_array_equal from pymatgen.analysis.piezo import PiezoTensor -from pymatgen.util.testing import PymatgenTest __author__ = "Shyam Dwaraknath" __version__ = "0.1" @@ -17,7 +16,7 @@ __date__ = "4/1/16" -class TestPiezo(PymatgenTest): +class TestPiezo: def setUp(self): self.piezo_struct = self.get_structure("BaNiO3") self.voigt_matrix = np.array( diff --git a/tests/analysis/test_piezo_sensitivity.py b/tests/analysis/test_piezo_sensitivity.py index 757215a30e4..b14e90e0250 100644 --- a/tests/analysis/test_piezo_sensitivity.py +++ b/tests/analysis/test_piezo_sensitivity.py @@ -17,7 +17,7 @@ rand_piezo, ) from pymatgen.io.phonopy import get_phonopy_structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR try: from phonopy import Phonopy @@ -34,7 +34,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/analysis/piezo_sensitivity" -class TestPiezoSensitivity(PymatgenTest): +class TestPiezoSensitivity: def setUp(self): self.piezo_struct = self.get_structure("Pb2TiZrO6") self.IST = np.load(f"{TEST_DIR}/pztist.npy", allow_pickle=True) diff --git a/tests/analysis/test_pourbaix_diagram.py b/tests/analysis/test_pourbaix_diagram.py index 22066499257..98f2dacc9cc 100644 --- a/tests/analysis/test_pourbaix_diagram.py +++ b/tests/analysis/test_pourbaix_diagram.py @@ -12,12 +12,12 @@ from pymatgen.core.composition import Composition from pymatgen.core.ion import Ion from pymatgen.entries.computed_entries import ComputedEntry -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/pourbaix_diagram" -class TestPourbaixEntry(PymatgenTest): +class TestPourbaixEntry: """Test all functions using a fictitious entry""" def setUp(self): diff --git a/tests/analysis/test_prototypes.py b/tests/analysis/test_prototypes.py index d2a16258d03..49f42675ea5 100644 --- a/tests/analysis/test_prototypes.py +++ b/tests/analysis/test_prototypes.py @@ -1,10 +1,9 @@ from __future__ import annotations from pymatgen.analysis.prototypes import AflowPrototypeMatcher -from pymatgen.util.testing import PymatgenTest -class TestAflowPrototypeMatcher(PymatgenTest): +class TestAflowPrototypeMatcher: def test_prototype_matching(self): af = AflowPrototypeMatcher() diff --git a/tests/analysis/test_structure_analyzer.py b/tests/analysis/test_structure_analyzer.py index a7da910eff0..1b01946b217 100644 --- a/tests/analysis/test_structure_analyzer.py +++ b/tests/analysis/test_structure_analyzer.py @@ -18,10 +18,10 @@ ) from pymatgen.core import Element, Lattice, Structure from pymatgen.io.vasp.outputs import Xdatcar -from pymatgen.util.testing import VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import VASP_IN_DIR, VASP_OUT_DIR -class TestVoronoiAnalyzer(PymatgenTest): +class TestVoronoiAnalyzer: def setUp(self): self.structs = Xdatcar(f"{VASP_OUT_DIR}/XDATCAR.MD").structures self.struct = self.structs[1] @@ -62,7 +62,7 @@ def test_get_percentage_bond_dist_changes(self): assert approx(v2) == -0.009204092115527862 -class TestVoronoiConnectivity(PymatgenTest): +class TestVoronoiConnectivity: def test_connectivity_array(self): vc = VoronoiConnectivity(self.get_structure("LiFePO4")) ca = vc.connectivity_array @@ -78,7 +78,7 @@ def test_connectivity_array(self): assert_allclose(site.frac_coords, expected) -class TestMiscFunction(PymatgenTest): +class TestMiscFunction: def test_average_coordination_number(self): xdatcar = Xdatcar(f"{VASP_OUT_DIR}/XDATCAR.MD") coordination_numbers = average_coordination_number(xdatcar.structures, freq=1) diff --git a/tests/analysis/test_structure_matcher.py b/tests/analysis/test_structure_matcher.py index 5a71019ebe2..c47da09efab 100644 --- a/tests/analysis/test_structure_matcher.py +++ b/tests/analysis/test_structure_matcher.py @@ -17,12 +17,12 @@ ) from pymatgen.core import Element, Lattice, Structure, SymmOp from pymatgen.util.coord import find_in_coord_list_pbc -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/structure_matcher" -class TestStructureMatcher(PymatgenTest): +class TestStructureMatcher: def setUp(self): with open(f"{TEST_FILES_DIR}/entries/TiO2_entries.json") as file: entries = json.load(file, cls=MontyDecoder) diff --git a/tests/analysis/test_surface_analysis.py b/tests/analysis/test_surface_analysis.py index 5492d9aefa6..cc0aaa6f0e3 100644 --- a/tests/analysis/test_surface_analysis.py +++ b/tests/analysis/test_surface_analysis.py @@ -9,7 +9,7 @@ from pymatgen.analysis.surface_analysis import NanoscaleStability, SlabEntry, SurfaceEnergyPlotter, WorkFunctionAnalyzer from pymatgen.entries.computed_entries import ComputedStructureEntry -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Richard Tran" __copyright__ = "Copyright 2012, The Materials Project" @@ -22,7 +22,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/surfaces" -class TestSlabEntry(PymatgenTest): +class TestSlabEntry: def setUp(self): with open(f"{TEST_DIR}/ucell_entries.txt") as file: ucell_entries = json.loads(file.read()) @@ -118,7 +118,7 @@ def test_cleaned_up_slab(self): assert slab_clean.composition.reduced_composition == clean.composition.reduced_composition -class TestSurfaceEnergyPlotter(PymatgenTest): +class TestSurfaceEnergyPlotter: def setUp(self): entry_dict = get_entry_dict(f"{TEST_DIR}/Cu_entries.txt") self.Cu_entry_dict = entry_dict @@ -292,7 +292,7 @@ def test_surface_chempot_range_map(self): analyzer.chempot_vs_gamma_facet(hkl) -class TestWorkFunctionAnalyzer(PymatgenTest): +class TestWorkFunctionAnalyzer: def setUp(self): self.kwargs = { "poscar_filename": f"{TEST_DIR}/CONTCAR.relax1.gz", @@ -309,7 +309,7 @@ def test_is_converged(self): assert self.wf_analyzer.is_converged() -class TestNanoscaleStability(PymatgenTest): +class TestNanoscaleStability: def setUp(self): # Load all entries La_hcp_entry_dict = get_entry_dict(f"{TEST_DIR}/La_hcp_entries.txt") diff --git a/tests/analysis/test_transition_state.py b/tests/analysis/test_transition_state.py index 96841bc482a..4ca1cf08339 100644 --- a/tests/analysis/test_transition_state.py +++ b/tests/analysis/test_transition_state.py @@ -6,7 +6,7 @@ from numpy.testing import assert_allclose from pymatgen.analysis.transition_state import NEBAnalysis, combine_neb_plots -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR """ TODO: Modify unittest doc. @@ -23,7 +23,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/io/vasp/fixtures/neb_analysis" -class TestNEBAnalysis(PymatgenTest): +class TestNEBAnalysis: def test_run(self): neb_analysis1 = NEBAnalysis.from_dir(f"{TEST_DIR}/neb1/neb") neb_analysis1_from_dict = NEBAnalysis.from_dict(neb_analysis1.as_dict()) diff --git a/tests/analysis/test_wulff.py b/tests/analysis/test_wulff.py index 768d079e2da..527a24fb4a7 100644 --- a/tests/analysis/test_wulff.py +++ b/tests/analysis/test_wulff.py @@ -9,7 +9,7 @@ from pymatgen.core.structure import Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.coord import in_coord_list -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Zihan Xu, Richard Tran, Balachandran Radhakrishnan" __copyright__ = "Copyright 2013, The Materials Virtual Lab" @@ -21,7 +21,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/analysis/wulff" -class TestWulffShape(PymatgenTest): +class TestWulffShape: def setUp(self): with open(f"{TEST_DIR}/surface_samples.json") as data_file: surface_properties = json.load(data_file) diff --git a/tests/analysis/test_xps.py b/tests/analysis/test_xps.py index 45b250e3100..f2260c82717 100644 --- a/tests/analysis/test_xps.py +++ b/tests/analysis/test_xps.py @@ -2,10 +2,10 @@ from pymatgen.analysis.xps import XPS from pymatgen.io.vasp import Vasprun -from pymatgen.util.testing import VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import VASP_OUT_DIR -class TestXPS(PymatgenTest): +class TestXPS: def test_from_dos(self): vasp_run = Vasprun(f"{VASP_OUT_DIR}/vasprun.LiF.xml.gz") dos = vasp_run.complete_dos diff --git a/tests/analysis/topological/test_spillage.py b/tests/analysis/topological/test_spillage.py index 39224cdfc52..254b6002dc3 100644 --- a/tests/analysis/topological/test_spillage.py +++ b/tests/analysis/topological/test_spillage.py @@ -3,12 +3,12 @@ from pytest import approx from pymatgen.analysis.topological.spillage import SOCSpillage -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/topological" -class TestSolar(PymatgenTest): +class TestSolar: def test_spillage_from_vasprun(self): wf_noso = f"{TEST_DIR}/WAVECAR-NonSOC" wf_so = f"{TEST_DIR}/WAVECAR-SOC" diff --git a/tests/analysis/xas/test_spectrum.py b/tests/analysis/xas/test_spectrum.py index 92a04879dc3..16553553e84 100644 --- a/tests/analysis/xas/test_spectrum.py +++ b/tests/analysis/xas/test_spectrum.py @@ -10,7 +10,7 @@ from pymatgen.analysis.xas.spectrum import XAS, site_weighted_spectrum from pymatgen.core import Element -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/spectrum_test" @@ -28,7 +28,7 @@ site2_xanes_dict = json.load(file, cls=MontyDecoder) -class TestXAS(PymatgenTest): +class TestXAS: def setUp(self): self.k_xanes = XAS.from_dict(k_xanes_dict) self.k_exafs = XAS.from_dict(k_exafs_dict) diff --git a/tests/apps/battery/test_analyzer.py b/tests/apps/battery/test_analyzer.py index eea99df2ecb..5e3fa0cd9f0 100644 --- a/tests/apps/battery/test_analyzer.py +++ b/tests/apps/battery/test_analyzer.py @@ -5,10 +5,10 @@ from pymatgen.apps.battery.analyzer import BatteryAnalyzer from pymatgen.core.structure import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR -class TestBatteryAnalyzer(PymatgenTest): +class TestBatteryAnalyzer: def load_from_cif(self, filename, oxidations, working_ion="Li"): struct = Structure.from_file(f"{TEST_FILES_DIR}/cif/{filename}") struct.add_oxidation_state_by_element(oxidations) diff --git a/tests/command_line/test_bader_caller.py b/tests/command_line/test_bader_caller.py index ad39f8c6b61..3d0f73e58ed 100644 --- a/tests/command_line/test_bader_caller.py +++ b/tests/command_line/test_bader_caller.py @@ -10,13 +10,13 @@ from pytest import approx from pymatgen.command_line.bader_caller import BaderAnalysis, bader_analysis_from_path -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR TEST_DIR = f"{TEST_FILES_DIR}/command_line/bader" @pytest.mark.skipif(not which("bader"), reason="bader executable not present") -class TestBaderAnalysis(PymatgenTest): +class TestBaderAnalysis: def setUp(self): warnings.catch_warnings() diff --git a/tests/command_line/test_enumlib_caller.py b/tests/command_line/test_enumlib_caller.py index aa3cebff4a3..b55ff9c2fea 100644 --- a/tests/command_line/test_enumlib_caller.py +++ b/tests/command_line/test_enumlib_caller.py @@ -11,14 +11,14 @@ from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.transformations.site_transformations import RemoveSitesTransformation from pymatgen.transformations.standard_transformations import SubstitutionTransformation -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR ENUM_CMD = which("enum.x") or which("multienum.x") MAKESTR_CMD = which("makestr.x") or which("makeStr.x") or which("makeStr.py") @pytest.mark.skipif(not (ENUM_CMD and MAKESTR_CMD), reason="enumlib not present.") -class TestEnumlibAdaptor(PymatgenTest): +class TestEnumlibAdaptor: def test_init(self): struct = self.get_structure("LiFePO4") sub_trans = SubstitutionTransformation({"Li": {"Li": 0.5}}) diff --git a/tests/command_line/test_mcsqs_caller.py b/tests/command_line/test_mcsqs_caller.py index ca9f8a018d6..b214f42b262 100644 --- a/tests/command_line/test_mcsqs_caller.py +++ b/tests/command_line/test_mcsqs_caller.py @@ -7,7 +7,7 @@ from pymatgen.command_line.mcsqs_caller import run_mcsqs from pymatgen.core.structure import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Handong Ling, Rachel Woods-Robinson" __maintainer__ = "Handong Ling, Rachel Woods-Robinson" @@ -18,7 +18,7 @@ @pytest.mark.skipif(not (which("mcsqs") and which("str2cif")), reason="mcsqs executable not present") -class TestMcsqsCaller(PymatgenTest): +class TestMcsqsCaller: def setUp(self): self.pzt_structs = loadfn(f"{TEST_DIR}/pzt-structs.json") self.pzt_structs2 = loadfn(f"{TEST_DIR}/pzt-structs-2.json") diff --git a/tests/command_line/test_vampire_caller.py b/tests/command_line/test_vampire_caller.py index e2e55a18486..cc8fb7c254c 100644 --- a/tests/command_line/test_vampire_caller.py +++ b/tests/command_line/test_vampire_caller.py @@ -8,13 +8,13 @@ from pymatgen.command_line.vampire_caller import VampireCaller from pymatgen.core.structure import Structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/analysis/magnetic_orderings" @pytest.mark.skipif(not which("vampire-serial"), reason="vampire executable not present") -class TestVampireCaller(PymatgenTest): +class TestVampireCaller: @classmethod def setUpClass(cls): cls.Mn3Al = pd.read_json(f"{TEST_DIR}/Mn3Al.json") diff --git a/tests/core/test_composition.py b/tests/core/test_composition.py index 9c00c7678fd..dba2a3c67f6 100644 --- a/tests/core/test_composition.py +++ b/tests/core/test_composition.py @@ -13,10 +13,9 @@ from pymatgen.core import Composition, DummySpecies, Element, Species from pymatgen.core.composition import ChemicalPotential -from pymatgen.util.testing import PymatgenTest -class TestComposition(PymatgenTest): +class TestComposition: def setUp(self): self.comps = [ Composition("Li3Fe2(PO4)3"), diff --git a/tests/core/test_interface.py b/tests/core/test_interface.py index c2563cd2a7a..598759a40a8 100644 --- a/tests/core/test_interface.py +++ b/tests/core/test_interface.py @@ -8,12 +8,12 @@ from pymatgen.core.structure import Structure from pymatgen.core.surface import SlabGenerator from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/core/grain_boundary" -class TestGrainBoundary(PymatgenTest): +class TestGrainBoundary: def setUp(self): self.Cu_conv = Structure.from_file(f"{TEST_DIR}/Cu_mp-30_conventional_standard.cif") GB_Cu_conv = GrainBoundaryGenerator(self.Cu_conv) @@ -104,7 +104,7 @@ def test_as_dict_and_from_dict(self): assert_allclose(Cu_GB2_new.lattice.matrix, self.Cu_GB2.lattice.matrix) -class TestGrainBoundaryGenerator(PymatgenTest): +class TestGrainBoundaryGenerator: @classmethod def setUpClass(cls): cls.Cu_prim = Structure.from_file(f"{TEST_DIR}/Cu_mp-30_primitive.cif") @@ -331,7 +331,7 @@ def test_get_rotation_angle_from_sigma(self): assert_allclose(close_angle, angle) -class TestInterface(PymatgenTest): +class TestInterface: def setUp(self): self.interface: Interface = self.get_structure("Si_SiO2_Interface") diff --git a/tests/core/test_lattice.py b/tests/core/test_lattice.py index 89a79e6330c..3bd111545ce 100644 --- a/tests/core/test_lattice.py +++ b/tests/core/test_lattice.py @@ -9,10 +9,9 @@ from pymatgen.core.lattice import Lattice, get_points_in_spheres from pymatgen.core.operations import SymmOp -from pymatgen.util.testing import PymatgenTest -class TestLattice(PymatgenTest): +class TestLattice: def setUp(self): self.lattice = Lattice.cubic(10.0) self.cubic = self.lattice diff --git a/tests/core/test_libxcfunc.py b/tests/core/test_libxcfunc.py index 435b71c389e..56ab6335159 100644 --- a/tests/core/test_libxcfunc.py +++ b/tests/core/test_libxcfunc.py @@ -1,10 +1,9 @@ from __future__ import annotations from pymatgen.core.libxcfunc import LibxcFunc -from pymatgen.util.testing import PymatgenTest -class TestLibxcFunc(PymatgenTest): +class TestLibxcFunc: def test_libxcfunc_api(self): """Testing libxcfunc_api.""" # LDA correlation: Hedin & Lundqvist diff --git a/tests/core/test_molecular_orbitals.py b/tests/core/test_molecular_orbitals.py index 4476c856d17..5d193409c20 100644 --- a/tests/core/test_molecular_orbitals.py +++ b/tests/core/test_molecular_orbitals.py @@ -3,12 +3,11 @@ import pytest from pymatgen.core.molecular_orbitals import MolecularOrbitals -from pymatgen.util.testing import PymatgenTest test_case = MolecularOrbitals("NaCl") -class TestMolecularOrbital(PymatgenTest): +class TestMolecularOrbital: def test_max_electronegativity(self): test_elec_neg = 2.23 assert test_elec_neg == test_case.max_electronegativity() diff --git a/tests/core/test_operations.py b/tests/core/test_operations.py index 1d775b09b92..6ece9b27eda 100644 --- a/tests/core/test_operations.py +++ b/tests/core/test_operations.py @@ -5,10 +5,9 @@ from pymatgen.core.operations import MagSymmOp, SymmOp from pymatgen.electronic_structure.core import Magmom -from pymatgen.util.testing import PymatgenTest -class TestSymmOp(PymatgenTest): +class TestSymmOp: def setUp(self): self.op = SymmOp.from_axis_angle_and_translation([0, 0, 1], 30, translation_vec=[0, 0, 1]) @@ -236,7 +235,7 @@ def test_xyz(self): assert_allclose(symm_op.translation_vector, [0.5, 0.25, 0.75]) -class TestMagSymmOp(PymatgenTest): +class TestMagSymmOp: def test_xyzt_string(self): xyzt_strings = ["x, y, z, +1", "x, y, z, -1", "-y+1/2, x+1/2, x+1/2, +1"] diff --git a/tests/core/test_periodic_table.py b/tests/core/test_periodic_table.py index a4a696a4f56..b02a017ec45 100644 --- a/tests/core/test_periodic_table.py +++ b/tests/core/test_periodic_table.py @@ -14,10 +14,9 @@ from pymatgen.core.periodic_table import ElementBase, ElementType from pymatgen.core.units import Ha_to_eV from pymatgen.io.core import ParseError -from pymatgen.util.testing import PymatgenTest -class TestElement(PymatgenTest): +class TestElement: def test_init(self): assert Element("Fe").symbol == "Fe" @@ -392,7 +391,7 @@ def test_isotope(self): ] -class TestSpecies(PymatgenTest): +class TestSpecies: def setUp(self): self.specie1 = Species.from_str("Fe2+") self.specie2 = Species("Fe", 3) diff --git a/tests/core/test_sites.py b/tests/core/test_sites.py index 28fb7b07e4c..2e619bf40aa 100644 --- a/tests/core/test_sites.py +++ b/tests/core/test_sites.py @@ -9,10 +9,9 @@ from pymatgen.core import Composition, Element, Lattice, PeriodicSite, Site, Species from pymatgen.electronic_structure.core import Magmom -from pymatgen.util.testing import PymatgenTest -class TestSite(PymatgenTest): +class TestSite: def setUp(self): self.ordered_site = Site("Fe", [0.25, 0.35, 0.45]) self.disordered_site = Site({"Fe": 0.5, "Mn": 0.5}, [0.25, 0.35, 0.45]) @@ -79,7 +78,7 @@ def test_setters(self): self.disordered_site.species = {"Cu": 0.5, "Gd": 0.6} -class TestPeriodicSite(PymatgenTest): +class TestPeriodicSite: def setUp(self): self.lattice = Lattice.cubic(10.0) self.si = Element("Si") diff --git a/tests/core/test_spectrum.py b/tests/core/test_spectrum.py index 2f8f208c175..f14b1506107 100644 --- a/tests/core/test_spectrum.py +++ b/tests/core/test_spectrum.py @@ -6,10 +6,9 @@ from scipy import stats from pymatgen.core.spectrum import Spectrum -from pymatgen.util.testing import PymatgenTest -class TestSpectrum(PymatgenTest): +class TestSpectrum: def setUp(self): rng = np.random.default_rng() self.spec1 = Spectrum(np.arange(0, 10, 0.1), rng.standard_normal(100)) diff --git a/tests/core/test_structure.py b/tests/core/test_structure.py index 7cb4abcbaf3..4b909a71411 100644 --- a/tests/core/test_structure.py +++ b/tests/core/test_structure.py @@ -44,7 +44,7 @@ mcsqs_cmd = which("mcsqs") -class TestNeighbor(PymatgenTest): +class TestNeighbor: def test_msonable(self): struct = PymatgenTest.get_structure("Li2O") nn = struct.get_neighbors(struct[0], r=3) @@ -63,7 +63,7 @@ def test_neighbor_labels(self): assert p_neighbor.label == label if label is not None else "C" -class TestIStructure(PymatgenTest): +class TestIStructure: def setUp(self): coords = [[0, 0, 0], [0.75, 0.5, 0.75]] self.lattice = Lattice( @@ -965,7 +965,7 @@ def test_sites_setter(self): assert struct.sites == new_sites -class TestStructure(PymatgenTest): +class TestStructure: def setUp(self): coords = [[0, 0, 0], [0.75, 0.5, 0.75]] lattice = Lattice( @@ -2032,7 +2032,7 @@ def test_struct_with_isotope(self): assert "Deuterium" not in [el.long_name for el in struct.composition.elements] -class TestIMolecule(PymatgenTest): +class TestIMolecule: def setUp(self): coords = [ [0, 0, 0], @@ -2327,7 +2327,7 @@ def test_to_file_alias(self): assert os.path.isfile(out_path) -class TestMolecule(PymatgenTest): +class TestMolecule: def setUp(self): coords = [ [0, 0, 0], diff --git a/tests/core/test_surface.py b/tests/core/test_surface.py index 0527fc671b0..ccc09906bbe 100644 --- a/tests/core/test_surface.py +++ b/tests/core/test_surface.py @@ -24,12 +24,12 @@ ) from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.symmetry.groups import SpaceGroup -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR PMG_CORE_DIR = os.path.dirname(pymatgen.core.__file__) -class TestSlab(PymatgenTest): +class TestSlab: def setUp(self): zno1 = Structure.from_file(f"{TEST_FILES_DIR}/surfaces/ZnO-wz.cif", primitive=False) zno55 = SlabGenerator(zno1, [1, 0, 0], 5, 5, lll_reduce=False, center_slab=False).get_slab() @@ -346,7 +346,7 @@ def test_as_dict(self): assert slab == Slab.from_dict(d) -class TestSlabGenerator(PymatgenTest): +class TestSlabGenerator: def setUp(self): lattice = Lattice.cubic(3.010) frac_coords = [ @@ -634,7 +634,7 @@ def test_bonds_broken(self): assert slabs[1].energy, 6.0 -class ReconstructionGeneratorTests(PymatgenTest): +class ReconstructionGeneratorTests: def setUp(self): lattice = Lattice.cubic(3.51) species = ["Ni"] @@ -723,7 +723,7 @@ def test_previous_reconstructions(self): assert any(len(match.group_structures([struct, slab])) == 1 for slab in slabs) -class TestMillerIndexFinder(PymatgenTest): +class TestMillerIndexFinder: def setUp(self): self.cscl = Structure.from_spacegroup("Pm-3m", Lattice.cubic(4.2), ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]) self.Fe = Structure.from_spacegroup("Im-3m", Lattice.cubic(2.82), ["Fe"], [[0, 0, 0]]) diff --git a/tests/core/test_tensors.py b/tests/core/test_tensors.py index 1c840dcfa2b..1c78a299ed9 100644 --- a/tests/core/test_tensors.py +++ b/tests/core/test_tensors.py @@ -11,10 +11,10 @@ from pymatgen.core.operations import SymmOp from pymatgen.core.tensors import SquareTensor, Tensor, TensorCollection, TensorMapping, itertools, symmetry_reduce from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR -class TestTensor(PymatgenTest): +class TestTensor: def setUp(self): rng = np.random.default_rng() @@ -379,7 +379,7 @@ def test_round(self): assert isinstance(rounded, Tensor) -class TestTensorCollection(PymatgenTest): +class TestTensorCollection: def setUp(self): self.seq_tc = list(np.arange(4 * 3**3).reshape((4, 3, 3, 3))) self.seq_tc = TensorCollection(self.seq_tc) @@ -472,7 +472,7 @@ def test_serialization(self): assert_allclose(t, t_new) -class TestSquareTensor(PymatgenTest): +class TestSquareTensor: def setUp(self): self.rand_sqtensor = SquareTensor(np.random.default_rng().standard_normal((3, 3))) self.symm_sqtensor = SquareTensor([[0.1, 0.3, 0.4], [0.3, 0.5, 0.2], [0.4, 0.2, 0.6]]) diff --git a/tests/core/test_trajectory.py b/tests/core/test_trajectory.py index cac745a8a75..2cb7baae889 100644 --- a/tests/core/test_trajectory.py +++ b/tests/core/test_trajectory.py @@ -12,12 +12,12 @@ from pymatgen.core.trajectory import Trajectory from pymatgen.io.qchem.outputs import QCOutput from pymatgen.io.vasp.outputs import Xdatcar -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR TEST_DIR = f"{TEST_FILES_DIR}/core/trajectory" -class TestTrajectory(PymatgenTest): +class TestTrajectory: def setUp(self): xdatcar = Xdatcar(f"{VASP_OUT_DIR}/XDATCAR_traj") self.traj = Trajectory.from_file(f"{VASP_OUT_DIR}/XDATCAR_traj") diff --git a/tests/core/test_units.py b/tests/core/test_units.py index 88e06d92517..1f3c7f2ac5b 100644 --- a/tests/core/test_units.py +++ b/tests/core/test_units.py @@ -26,7 +26,6 @@ eV_to_Ha, unitized, ) -from pymatgen.util.testing import PymatgenTest def test_unit_conversions(): @@ -37,7 +36,7 @@ def test_unit_conversions(): assert amu_to_kg == approx(1.66053906660e-27) -class TestUnit(PymatgenTest): +class TestUnit: def test_init(self): u1 = Unit((("m", 1), ("s", -1))) assert str(u1) == "m s^-1" @@ -53,7 +52,7 @@ def test_init(self): assert str(newton * Unit("m")) == "N m" -class TestFloatWithUnit(PymatgenTest): +class TestFloatWithUnit: def test_energy(self): a = Energy(1.1, "eV") b = a.to("Ha") @@ -185,7 +184,7 @@ def test_neg(self): assert FloatWithUnit(-5, "MPa") == -x -class TestArrayWithUnit(PymatgenTest): +class TestArrayWithUnit: def test_energy(self): """Similar to TestFloatWithUnit.test_energy. Check whether EnergyArray and FloatWithUnit have same behavior. @@ -293,7 +292,7 @@ def test_as_base_units(self): assert_array_equal(ArrayWithUnit([5000000, 10000000], "Pa"), pressure_arr.as_base_units) -class TestDataPersistence(PymatgenTest): +class TestDataPersistence: def test_pickle(self): """Test whether FloatWithUnit and ArrayWithUnit support pickle.""" for cls in [FloatWithUnit, ArrayWithUnit]: diff --git a/tests/core/test_xcfunc.py b/tests/core/test_xcfunc.py index 94627874bab..fd4c15e0d76 100644 --- a/tests/core/test_xcfunc.py +++ b/tests/core/test_xcfunc.py @@ -3,10 +3,9 @@ import pytest from pymatgen.core.xcfunc import XcFunc -from pymatgen.util.testing import PymatgenTest -class TestLibxcFunc(PymatgenTest): +class TestLibxcFunc: def setUp(self) -> None: self.ixc_11 = XcFunc.from_abinit_ixc(11) diff --git a/tests/electronic_structure/test_bandstructure.py b/tests/electronic_structure/test_bandstructure.py index c5de50385ce..2cacd115159 100644 --- a/tests/electronic_structure/test_bandstructure.py +++ b/tests/electronic_structure/test_bandstructure.py @@ -20,7 +20,7 @@ from pymatgen.electronic_structure.core import Orbital, Spin from pymatgen.electronic_structure.plotter import BSPlotterProjected from pymatgen.io.vasp import BSVasprun -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/bandstructure" @@ -68,7 +68,7 @@ def test_from_dict(self): assert kpoint.label == "X" -class TestBandStructureSymmLine(PymatgenTest): +class TestBandStructureSymmLine: def setUp(self): self.bs: BandStructureSymmLine = loadfn(f"{TEST_DIR}/Cu2O_361_bandstructure.json") self.bs2: BandStructureSymmLine = loadfn(f"{TEST_DIR}/CaO_2605_bandstructure.json") @@ -258,7 +258,7 @@ def test_apply_scissor_spin_polarized(self): assert bs_scissored.efermi != approx(orig_efermi) -class TestReconstructBandStructure(PymatgenTest): +class TestReconstructBandStructure: def setUp(self): self.bs_cu: BandStructureSymmLine = loadfn(f"{TEST_DIR}/Cu_30_bandstructure.json") self.bs_cu2: BandStructureSymmLine = loadfn(f"{TEST_DIR}/Cu_30_bandstructure.json") @@ -277,7 +277,7 @@ def test_vasprun_bs(self): bs.get_projection_on_elements() -class TestLobsterBandStructureSymmLine(PymatgenTest): +class TestLobsterBandStructureSymmLine: def setUp(self): with open( f"{TEST_FILES_DIR}/electronic_structure/cohp/Fatband_SiO2/Test_p/lobster_band_structure_spin.json", diff --git a/tests/electronic_structure/test_cohp.py b/tests/electronic_structure/test_cohp.py index 16f0ce2ca34..1da7a34b55f 100644 --- a/tests/electronic_structure/test_cohp.py +++ b/tests/electronic_structure/test_cohp.py @@ -15,7 +15,7 @@ get_integrated_cohp_in_energy_range, ) from pymatgen.electronic_structure.core import Orbital, Spin -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/cohp" @@ -797,7 +797,7 @@ def test_extremum_icohpvalue(self): assert self.icoopcollection_Fe.extremum_icohpvalue(summed_spin_channels=False, spin=Spin.down) == -0.05756 -class TestCompleteCohp(PymatgenTest): +class TestCompleteCohp: def setUp(self): filepath = f"{TEST_DIR}/complete_cohp_lobster.json" with open(filepath) as file: diff --git a/tests/electronic_structure/test_dos.py b/tests/electronic_structure/test_dos.py index a7c8dec41b1..229738439c0 100644 --- a/tests/electronic_structure/test_dos.py +++ b/tests/electronic_structure/test_dos.py @@ -14,7 +14,7 @@ from pymatgen.core import Element, Structure from pymatgen.electronic_structure.core import Orbital, OrbitalType, Spin from pymatgen.electronic_structure.dos import DOS, CompleteDos, FermiDos, LobsterCompleteDos -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/dos" @@ -323,7 +323,7 @@ def test_dos_fp_exceptions(self): self.dos.get_dos_fp_similarity(dos_fp, dos_fp2, col=1, metric=metric, normalize=False) -class TestDOS(PymatgenTest): +class TestDOS: def setUp(self): with open(f"{TEST_DIR}/complete_dos.json") as file: dct = json.load(file) diff --git a/tests/electronic_structure/test_plotter.py b/tests/electronic_structure/test_plotter.py index 59763e9ea59..2e80564a90c 100644 --- a/tests/electronic_structure/test_plotter.py +++ b/tests/electronic_structure/test_plotter.py @@ -30,14 +30,14 @@ plot_ellipsoid, ) from pymatgen.io.vasp import Vasprun -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR BAND_TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/bandstructure" rc("text", usetex=False) # Disabling latex is needed for this test to work. -class TestDosPlotter(PymatgenTest): +class TestDosPlotter: def setUp(self): with open(f"{BAND_TEST_DIR}/../dos/complete_dos.json") as file: self.dos = CompleteDos.from_dict(json.load(file)) @@ -91,7 +91,7 @@ def get_plot_attributes(ax: plt.Axes): } -class TestBSPlotter(PymatgenTest): +class TestBSPlotter: def setUp(self): with open(f"{BAND_TEST_DIR}/CaO_2605_bandstructure.json") as file: dct = json.loads(file.read()) @@ -444,7 +444,7 @@ def test_plot_zt_temp(self): plt.close() -class TestCohpPlotter(PymatgenTest): +class TestCohpPlotter: def setUp(self): path = f"{TEST_FILES_DIR}/electronic_structure/cohp/complete_cohp_lobster.json" with open(path) as file: diff --git a/tests/entries/test_entry_tools.py b/tests/entries/test_entry_tools.py index 73d2d721d7b..3731857f98b 100644 --- a/tests/entries/test_entry_tools.py +++ b/tests/entries/test_entry_tools.py @@ -9,12 +9,12 @@ from pymatgen.core import Element from pymatgen.entries.computed_entries import ComputedEntry from pymatgen.entries.entry_tools import EntrySet, group_entries_by_composition, group_entries_by_structure -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/entries" -class TestFunc(PymatgenTest): +class TestFunc: def test_group_entries_by_structure(self): entries = loadfn(f"{TEST_DIR}/TiO2_entries.json") groups = group_entries_by_structure(entries) @@ -49,7 +49,7 @@ def test_group_entries_by_composition(self): assert group == sorted(group, key=lambda e: e.energy_per_atom) -class TestEntrySet(PymatgenTest): +class TestEntrySet: def setUp(self): entries = loadfn(f"{TEST_DIR}/Li-Fe-P-O_entries.json") self.entry_set = EntrySet(entries) diff --git a/tests/ext/test_matproj.py b/tests/ext/test_matproj.py index 18558a41525..0f0395577e0 100644 --- a/tests/ext/test_matproj.py +++ b/tests/ext/test_matproj.py @@ -23,7 +23,7 @@ from pymatgen.ext.matproj_legacy import MPRestError, TaskType, _MPResterLegacy from pymatgen.phonon.bandstructure import PhononBandStructureSymmLine from pymatgen.phonon.dos import CompletePhononDos -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR PMG_MAPI_KEY = SETTINGS.get("PMG_MAPI_KEY", "") if (10 < len(PMG_MAPI_KEY) <= 20) and "PMG_MAPI_KEY" in SETTINGS: @@ -48,7 +48,7 @@ not 10 < len(PMG_MAPI_KEY) <= 20, reason="Legacy PMG_MAPI_KEY environment variable not set.", ) -class TestMPResterOld(PymatgenTest): +class TestMPResterOld: def setUp(self): self.rester = _MPResterLegacy() @@ -528,7 +528,7 @@ def test_api_key_is_none(self): not len(PMG_MAPI_KEY) > 20, reason="PMG_MAPI_KEY environment variable not set.", ) -class TestMPResterNewBasic(PymatgenTest): +class TestMPResterNewBasic: def setUp(self): self.rester = _MPResterBasic() diff --git a/tests/ext/test_optimade.py b/tests/ext/test_optimade.py index e2710ddeaff..4a81116c5ce 100644 --- a/tests/ext/test_optimade.py +++ b/tests/ext/test_optimade.py @@ -4,7 +4,6 @@ import requests from pymatgen.ext.optimade import OptimadeRester -from pymatgen.util.testing import PymatgenTest try: # 403 is returned when server detects bot-like behavior @@ -36,7 +35,7 @@ mc2d_down = True -class TestOptimade(PymatgenTest): +class TestOptimade: @pytest.mark.skipif(mp_website_down, reason="MP OPTIMADE is down.") def test_get_structures_mp(self): with OptimadeRester("mp") as optimade: diff --git a/tests/io/abinit/test_abiobjects.py b/tests/io/abinit/test_abiobjects.py index ad38c49dafe..03b90aefe4b 100644 --- a/tests/io/abinit/test_abiobjects.py +++ b/tests/io/abinit/test_abiobjects.py @@ -19,10 +19,10 @@ species_by_znucl, structure_to_abivars, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR -class TestLatticeFromAbivars(PymatgenTest): +class TestLatticeFromAbivars: def test_rprim_acell(self): l1 = lattice_from_abivars(acell=3 * [10], rprim=np.eye(3)) assert l1.volume == approx(bohr_to_ang**3 * 1000) @@ -108,7 +108,7 @@ def test_znucl_typat(self): structure_to_abivars(gan, enforce_znucl=enforce_znucl, enforce_typat=None) -class TestSpinMode(PymatgenTest): +class TestSpinMode: def test_base(self): polarized = SpinMode.as_spinmode("polarized") other_polarized = SpinMode.as_spinmode("polarized") @@ -128,7 +128,7 @@ def test_base(self): self.assert_msonable(unpolarized) -class TestSmearing(PymatgenTest): +class TestSmearing: def test_base(self): fd1ev = Smearing.as_smearing("fermi_dirac:1 eV") fd1ev.to_abivars() @@ -156,7 +156,7 @@ def test_base(self): self.assert_msonable(fd1ev) -class TestElectronsAlgorithm(PymatgenTest): +class TestElectronsAlgorithm: def test_base(self): algo = ElectronsAlgorithm(nstep=70) _ = algo.to_abivars() @@ -168,7 +168,7 @@ def test_base(self): self.assert_msonable(algo) -class TestElectrons(PymatgenTest): +class TestElectrons: def test_base(self): default_electrons = Electrons() assert default_electrons.nsppol == 2 @@ -195,7 +195,7 @@ def test_base(self): self.assert_msonable(custom_electrons) -class TestKSampling(PymatgenTest): +class TestKSampling: def test_base(self): monkhorst = KSampling.monkhorst((3, 3, 3), (0.5, 0.5, 0.5), 0, use_symmetries=False, use_time_reversal=False) gamma_centered = KSampling.gamma_centered((3, 3, 3), use_symmetries=False, use_time_reversal=False) @@ -207,7 +207,7 @@ def test_base(self): self.assert_msonable(gamma_centered) -class TestRelaxation(PymatgenTest): +class TestRelaxation: def test_base(self): atoms_and_cell = RelaxationMethod.atoms_and_cell() atoms_only = RelaxationMethod.atoms_only() @@ -227,7 +227,7 @@ def test_base(self): self.assert_msonable(atoms_only) -class TestPPModel(PymatgenTest): +class TestPPModel: def test_base(self): godby = PPModel.as_ppmodel("godby:12 eV") godby.to_abivars() diff --git a/tests/io/abinit/test_inputs.py b/tests/io/abinit/test_inputs.py index 762ea2acad8..abcb129f4fb 100644 --- a/tests/io/abinit/test_inputs.py +++ b/tests/io/abinit/test_inputs.py @@ -18,7 +18,7 @@ ion_ioncell_relax_input, num_valence_electrons, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/abinit" @@ -33,7 +33,7 @@ def abiref_files(*filenames): return [f"{TEST_DIR}/{file}" for file in filenames] -class TestAbinitInput(PymatgenTest): +class TestAbinitInput: """Unit tests for BasicAbinitInput.""" def test_api(self): @@ -168,7 +168,7 @@ def test_helper_functions(self): assert len(inp["kptbounds"]) == 12 -class TestMultiDataset(PymatgenTest): +class TestMultiDataset: """Unit tests for BasicMultiDataset.""" def test_api(self): @@ -251,7 +251,7 @@ def test_api(self): self.serialize_with_pickle(multi, test_eq=False) -class TestShiftMode(PymatgenTest): +class TestShiftMode: def test_shiftmode(self): gamma = ShiftMode.GammaCentered assert ShiftMode.from_object("G") == gamma @@ -260,7 +260,7 @@ def test_shiftmode(self): ShiftMode.from_object({}) -class TestFactory(PymatgenTest): +class TestFactory: def setUp(self): # Si ebands self.si_structure = Structure.from_file(abiref_file("si.cif")) diff --git a/tests/io/abinit/test_netcdf.py b/tests/io/abinit/test_netcdf.py index b4b2ffa68c1..2006d5bdbb0 100644 --- a/tests/io/abinit/test_netcdf.py +++ b/tests/io/abinit/test_netcdf.py @@ -11,7 +11,7 @@ from pymatgen.core.structure import Structure from pymatgen.io.abinit import EtsfReader from pymatgen.io.abinit.netcdf import AbinitHeader -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR try: import netCDF4 @@ -21,7 +21,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/io/abinit" -class TestEtsfReader(PymatgenTest): +class TestEtsfReader: def setUp(self): formulas = ["Si2"] self.GSR_paths = dct = {} @@ -117,7 +117,7 @@ def test_read_fe(self): assert structure.site_properties["magmom"] == ref_magmom_noncollinear -class TestAbinitHeader(PymatgenTest): +class TestAbinitHeader: def test_api(self): head = AbinitHeader(foo=1, bar=2) assert head.foo == 1 diff --git a/tests/io/abinit/test_pseudos.py b/tests/io/abinit/test_pseudos.py index 8cd9bace814..7d874908c0d 100644 --- a/tests/io/abinit/test_pseudos.py +++ b/tests/io/abinit/test_pseudos.py @@ -9,12 +9,12 @@ from pytest import approx from pymatgen.io.abinit.pseudos import Pseudo, PseudoTable -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/abinit" -class TestPseudo(PymatgenTest): +class TestPseudo: def setUp(self): nc_pseudo_fnames = defaultdict(list) nc_pseudo_fnames["Si"] = [f"{TEST_DIR}/{file}" for file in ("14si.pspnc", "14si.4.hgh", "14-Si.LDA.fhi")] @@ -198,7 +198,7 @@ def test_oncvpsp_pseudo_fr(self): assert pb.supports_soc -class TestPseudoTable(PymatgenTest): +class TestPseudoTable: def test_methods(self): """Test PseudoTable methods.""" table = PseudoTable([f"{TEST_DIR}/{file}" for file in ("14si.pspnc", "14si.4.hgh", "14-Si.LDA.fhi")]) diff --git a/tests/io/cp2k/test_inputs.py b/tests/io/cp2k/test_inputs.py index ec0b772c617..7da41494b62 100644 --- a/tests/io/cp2k/test_inputs.py +++ b/tests/io/cp2k/test_inputs.py @@ -22,7 +22,7 @@ Section, SectionList, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/cp2k" @@ -41,7 +41,7 @@ """ -class TestBasis(PymatgenTest): +class TestBasis: def test_basis_info(self): # Ensure basis metadata can be read from string basis_info = BasisInfo.from_str("cc-pc-DZVP-MOLOPT-q1-SCAN") @@ -92,7 +92,7 @@ def test_basis(self): mol_opt.info.admm = False -class TestPotential(PymatgenTest): +class TestPotential: all_hydrogen_str = """ H ALLELECTRON ALL 1 0 0 @@ -144,7 +144,7 @@ def test_potentials(self): assert kw.values[0] == "ALL" -class TestCp2kInput(PymatgenTest): +class TestCp2kInput: si_struct = Structure( lattice=[ [0, 2.734364, 2.734364], @@ -268,7 +268,7 @@ def test_mongo(self): assert cp2k_input.check("global/subsec2") -class TestDataFile(PymatgenTest): +class TestDataFile: def test_data_file(self): # make temp file with BASIS_FILE_STR data_file = self.tmp_path / "data-file" diff --git a/tests/io/cp2k/test_sets.py b/tests/io/cp2k/test_sets.py index e2c74bc31a6..943facb4b87 100644 --- a/tests/io/cp2k/test_sets.py +++ b/tests/io/cp2k/test_sets.py @@ -6,7 +6,7 @@ from pymatgen.core.structure import Molecule, Structure from pymatgen.io.cp2k.sets import SETTINGS, Cp2kValidationError, DftSet, GaussianTypeOrbitalBasisSet, GthPotential -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR CP2K_TEST_DIR = f"{TEST_FILES_DIR}/io/cp2k" @@ -46,7 +46,7 @@ } -class TestDftSet(PymatgenTest): +class TestDftSet: def test_dft_set(self) -> None: """Test various DFT set configurations.""" SETTINGS["PMG_CP2K_DATA_DIR"] = CP2K_TEST_DIR diff --git a/tests/io/exciting/test_inputs.py b/tests/io/exciting/test_inputs.py index ccbac253944..e3b134f8429 100644 --- a/tests/io/exciting/test_inputs.py +++ b/tests/io/exciting/test_inputs.py @@ -6,7 +6,7 @@ from pymatgen.core import Lattice, Structure from pymatgen.io.exciting import ExcitingInput -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Christian Vorwerk" __copyright__ = "Copyright 2016" @@ -19,7 +19,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/io/exciting" -class TestExcitingInput(PymatgenTest): +class TestExcitingInput: def test_fromfile(self): # Test for the import of a structure directly from an exciting # input file diff --git a/tests/io/feff/test_sets.py b/tests/io/feff/test_sets.py index e57e560996c..8dae8b7e546 100644 --- a/tests/io/feff/test_sets.py +++ b/tests/io/feff/test_sets.py @@ -9,12 +9,12 @@ from pymatgen.core.structure import Lattice, Molecule, Structure from pymatgen.io.feff.inputs import Atoms, Header, Potential, Tags from pymatgen.io.feff.sets import FEFFDictSet, MPELNESSet, MPEXAFSSet, MPXANESSet -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR FEFF_TEST_DIR = f"{TEST_FILES_DIR}/io/feff" -class TestFeffInputSet(PymatgenTest): +class TestFeffInputSet: @classmethod def setUpClass(cls): cls.header_string = """* This FEFF.inp file generated by pymatgen diff --git a/tests/io/lammps/test_data.py b/tests/io/lammps/test_data.py index 3be78db967c..a121b7ef680 100644 --- a/tests/io/lammps/test_data.py +++ b/tests/io/lammps/test_data.py @@ -14,12 +14,12 @@ from pymatgen.core import Element, Lattice, Molecule, Structure from pymatgen.io.lammps.data import CombinedData, ForceField, LammpsBox, LammpsData, Topology, lattice_2_lmpbox -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/lammps" -class TestLammpsBox(PymatgenTest): +class TestLammpsBox: @classmethod def setUpClass(cls): cls.peptide = LammpsBox( @@ -73,7 +73,7 @@ def test_to_lattice(self): ) -class TestLammpsData(PymatgenTest): +class TestLammpsData: @classmethod def setUpClass(cls): cls.peptide = LammpsData.from_file(filename=f"{TEST_DIR}/data.peptide") @@ -665,7 +665,7 @@ def test_from_bonding(self): assert "Dihedrals" not in topo_etoh2.topologies -class TestForceField(PymatgenTest): +class TestForceField: @classmethod def setUpClass(cls): mass_info = [ diff --git a/tests/io/lammps/test_generators.py b/tests/io/lammps/test_generators.py index d19eddbf8df..3db0fae78d8 100644 --- a/tests/io/lammps/test_generators.py +++ b/tests/io/lammps/test_generators.py @@ -3,12 +3,12 @@ from pymatgen.core.structure import Structure from pymatgen.io.lammps.data import LammpsData from pymatgen.io.lammps.generators import LammpsMinimization -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/lammps" -class TestLammpsMinimization(PymatgenTest): +class TestLammpsMinimization: @classmethod def setUpClass(cls): cls.filename = f"{TEST_DIR}/lgps.in" diff --git a/tests/io/lammps/test_inputs.py b/tests/io/lammps/test_inputs.py index 15f8ef3fac4..fb25b788732 100644 --- a/tests/io/lammps/test_inputs.py +++ b/tests/io/lammps/test_inputs.py @@ -11,12 +11,12 @@ from pymatgen.core.structure import Structure from pymatgen.io.lammps.data import LammpsData from pymatgen.io.lammps.inputs import LammpsInputFile, LammpsRun, LammpsTemplateGen, write_lammps_inputs -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/lammps" -class TestLammpsInputFile(PymatgenTest): +class TestLammpsInputFile: @classmethod def setUpClass(cls): cls.filename = f"{TEST_DIR}/lgps.in" @@ -640,7 +640,7 @@ def test_add_comment(self): ] -class TestLammpsRun(PymatgenTest): +class TestLammpsRun: def test_md(self): struct = Structure.from_spacegroup(225, Lattice.cubic(3.62126), ["Cu"], [[0, 0, 0]]) ld = LammpsData.from_structure(struct, atom_style="atomic") @@ -690,7 +690,7 @@ def test_md(self): assert os.path.isfile(f"{self.tmp_path}/md/md.data") -class TestFunc(PymatgenTest): +class TestFunc: @pytest.mark.filterwarnings("ignore:write_lammps_inputs is deprecated") def test_write_lammps_inputs(self): # script template @@ -727,7 +727,7 @@ def test_write_lammps_inputs(self): pd.testing.assert_frame_equal(obj_read.atoms, obj.atoms) -class TestLammpsTemplateGen(PymatgenTest): +class TestLammpsTemplateGen: def test_write_inputs(self): # simple script without data file lis = LammpsTemplateGen().get_input_set( diff --git a/tests/io/lobster/test_inputs.py b/tests/io/lobster/test_inputs.py index 59960d5970f..72feec95f87 100644 --- a/tests/io/lobster/test_inputs.py +++ b/tests/io/lobster/test_inputs.py @@ -8,7 +8,7 @@ from pymatgen.io.lobster import Lobsterin from pymatgen.io.lobster.inputs import get_all_possible_basis_combinations from pymatgen.io.vasp.inputs import Incar, Kpoints, Potcar -from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/cohp" @@ -19,7 +19,7 @@ __date__ = "Dec 10, 2017" -class TestLobsterin(PymatgenTest): +class TestLobsterin: def setUp(self): self.Lobsterin = Lobsterin.from_file(f"{TEST_DIR}/lobsterin.1") self.Lobsterin2 = Lobsterin.from_file(f"{TEST_DIR}/lobsterin.2") @@ -579,7 +579,7 @@ def test_as_from_dict(self): new_lobsterin.to_json() -class TestUtils(PymatgenTest): +class TestUtils: def test_get_all_possible_basis_combinations(self): # this basis is just for testing (not correct) min_basis = ["Li 1s 2s ", "Na 1s 2s", "Si 1s 2s"] diff --git a/tests/io/lobster/test_outputs.py b/tests/io/lobster/test_outputs.py index 4dac8c4a01b..ac9ff882d82 100644 --- a/tests/io/lobster/test_outputs.py +++ b/tests/io/lobster/test_outputs.py @@ -31,7 +31,7 @@ Wavefunction, ) from pymatgen.io.vasp import Vasprun -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/cohp" @@ -42,7 +42,7 @@ __date__ = "Dec 10, 2017" -class TestBwdf(PymatgenTest): +class TestBwdf: def setUp(self): self.bwdf_coop = Bwdf(filename=f"{TEST_DIR}/BWDF.lobster.AlN.gz") self.bwdf_cohp = Bwdf(filename=f"{TEST_DIR}/BWDFCOHP.lobster.NaCl.gz") @@ -57,7 +57,7 @@ def test_attributes(self): assert self.bwdf_cohp.bwdf[Spin.up][103] == approx(-0.01392, abs=1e-4) -class TestCohpcar(PymatgenTest): +class TestCohpcar: def setUp(self): self.cohp_bise = Cohpcar(filename=f"{TEST_DIR}/COHPCAR.lobster.BiSe.gz") self.coop_bise = Cohpcar( @@ -637,7 +637,7 @@ def test_is_spin_polarized(self): assert not self.DOSCAR_nonspin_pol.is_spin_polarized -class TestCharge(PymatgenTest): +class TestCharge: def setUp(self): self.charge2 = Charge(filename=f"{TEST_DIR}/CHARGE.lobster.MnO") # gzipped file @@ -716,7 +716,7 @@ def test_msonable(self): assert getattr(charge_from_dict, attr_name) == attr_value -class TestLobsterout(PymatgenTest): +class TestLobsterout: def setUp(self): self.lobsterout_normal = Lobsterout(filename=f"{TEST_DIR}/lobsterout.normal") # make sure .gz files are also read correctly @@ -1245,7 +1245,7 @@ def test_msonable(self): Lobsterout(filename=None, invalid="val") -class TestFatband(PymatgenTest): +class TestFatband: def setUp(self): self.structure = Vasprun( filename=f"{TEST_DIR}/Fatband_SiO2/Test_p_x/vasprun.xml", @@ -2204,7 +2204,7 @@ def test_ncicobilist(self): ) -class TestWavefunction(PymatgenTest): +class TestWavefunction: def test_parse_file(self): grid, points, real, imaginary, distance = Wavefunction._parse_file( f"{TEST_DIR}/LCAOWaveFunctionAfterLSO1PlotOfSpin1Kpoint1band1.gz" @@ -2272,7 +2272,7 @@ def test_write_file(self): assert os.path.isfile(density_wavecar_path) -class TestSitePotentials(PymatgenTest): +class TestSitePotentials: def setUp(self) -> None: self.sitepotential = SitePotential(filename=f"{TEST_DIR}/SitePotentials.lobster.perovskite") @@ -2323,7 +2323,7 @@ def test_msonable(self): assert getattr(sitepotential_from_dict, attr_name) == attr_value -class TestMadelungEnergies(PymatgenTest): +class TestMadelungEnergies: def setUp(self) -> None: self.madelungenergies = MadelungEnergies(filename=f"{TEST_DIR}/MadelungEnergies.lobster.perovskite") @@ -2340,7 +2340,7 @@ def test_msonable(self): assert getattr(madelung_from_dict, attr_name) == attr_value -class TestLobsterMatrices(PymatgenTest): +class TestLobsterMatrices: def setUp(self) -> None: self.hamilton_matrices = LobsterMatrices( filename=f"{TEST_DIR}/Na_hamiltonMatrices.lobster.gz", e_fermi=-2.79650354 @@ -2490,7 +2490,7 @@ def test_raises(self): self.hamilton_matrices = LobsterMatrices(filename=f"{TEST_DIR}/hamiltonMatrices.lobster") -class TestPolarization(PymatgenTest): +class TestPolarization: def setUp(self) -> None: self.polarization = Polarization(filename=f"{TEST_DIR}/POLARIZATION.lobster.AlN.gz") diff --git a/tests/io/pwmat/test_inputs.py b/tests/io/pwmat/test_inputs.py index 7618e7ecdf6..8e21dc0428f 100644 --- a/tests/io/pwmat/test_inputs.py +++ b/tests/io/pwmat/test_inputs.py @@ -18,7 +18,7 @@ LineLocator, ListLocator, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/pwmat" @@ -43,7 +43,7 @@ def test_list_locator(exclusion: str, expected_idx: int): assert aim_idx == expected_idx -class TestACstrExtractor(PymatgenTest): +class TestACstrExtractor: def test_extract(self): filepath = f"{TEST_DIR}/atom.config" ac_extractor = ACExtractor(file_path=filepath) @@ -60,7 +60,7 @@ def test_extract(self): assert ac_extractor.magmoms[idx] == ac_str_extractor.get_magmoms()[idx] -class TestAtomConfig(PymatgenTest): +class TestAtomConfig: def test_init(self): filepath = f"{TEST_DIR}/atom.config" structure = Structure.from_file(filepath) @@ -82,7 +82,7 @@ def test_write_file(self): assert_allclose(atom_config.structure.lattice.abc, tmp_atom_config.structure.lattice.abc, 5) -class TestGenKpt(PymatgenTest): +class TestGenKpt: def test_from_structure(self): pytest.importorskip("seekpath") filepath = f"{TEST_DIR}/atom.config" @@ -107,7 +107,7 @@ def test_write_file(self): assert gen_kpt.get_str() == tmp_gen_kpt_str -class TestHighSymmetryPoint(PymatgenTest): +class TestHighSymmetryPoint: def test_from_structure(self): pytest.importorskip("seekpath") filepath = f"{TEST_DIR}/atom.config" diff --git a/tests/io/pwmat/test_outputs.py b/tests/io/pwmat/test_outputs.py index b2a97f891fe..ea7d0150122 100644 --- a/tests/io/pwmat/test_outputs.py +++ b/tests/io/pwmat/test_outputs.py @@ -1,12 +1,12 @@ from __future__ import annotations from pymatgen.io.pwmat.outputs import DosSpin, Movement, OutFermi, Report -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/pwmat" -class TestMovement(PymatgenTest): +class TestMovement: def test_init_and_properties(self): filepath = f"{TEST_DIR}/MOVEMENT.lzma" movement = Movement(filepath) @@ -26,14 +26,14 @@ def test_init_and_properties(self): assert movement.ionic_steps[0]["e_tot"] == -357677.2281 -class TestOutFermi(PymatgenTest): +class TestOutFermi: def test_init_and_properties(self): filepath = f"{TEST_DIR}/OUT.FERMI.lzma" out_fermi = OutFermi(filepath) assert out_fermi.e_fermi == -2.359 -class TestReport(PymatgenTest): +class TestReport: def test_init_and_properties(self): filepath = f"{TEST_DIR}/REPORT" report = Report(filepath) @@ -46,7 +46,7 @@ def test_init_and_properties(self): assert report.hsps == {} -class TestDosSpin(PymatgenTest): +class TestDosSpin: def test_init_and_properties(self): filepath = f"{TEST_DIR}/DOS.spinup_projected" dos_spin = DosSpin(filepath) diff --git a/tests/io/qchem/test_inputs.py b/tests/io/qchem/test_inputs.py index fe87a29a095..49737711af7 100644 --- a/tests/io/qchem/test_inputs.py +++ b/tests/io/qchem/test_inputs.py @@ -8,7 +8,7 @@ from pymatgen.core.structure import Molecule from pymatgen.io.qchem.inputs import QCInput from pymatgen.io.qchem.sets import OptSet -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/qchem" @@ -20,7 +20,7 @@ __credits__ = "Xiaohui Qu" -class TestQCInput(PymatgenTest): +class TestQCInput: def test_molecule_template(self): species = ["C", "O"] coords = [ diff --git a/tests/io/qchem/test_outputs.py b/tests/io/qchem/test_outputs.py index 22f681f8918..0c727a1bdce 100644 --- a/tests/io/qchem/test_outputs.py +++ b/tests/io/qchem/test_outputs.py @@ -17,7 +17,7 @@ hessian_parser, orbital_coeffs_parser, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR try: from openbabel import openbabel @@ -260,7 +260,7 @@ } -class TestQCOutput(PymatgenTest): +class TestQCOutput: @staticmethod def generate_single_job_dict(): """Used to generate test dictionary for single jobs.""" diff --git a/tests/io/qchem/test_sets.py b/tests/io/qchem/test_sets.py index 9a677b02ab8..f969e5a1c78 100644 --- a/tests/io/qchem/test_sets.py +++ b/tests/io/qchem/test_sets.py @@ -14,7 +14,7 @@ SinglePointSet, TransitionStateSet, ) -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Samuel Blau, Brandon Wood, Shyam Dwaraknath, Evan Spotte-Smith, Ryan Kingsbury" __copyright__ = "Copyright 2018-2022, The Materials Project" @@ -26,7 +26,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/io/qchem/new_qchem_files" -class TestQChemDictSet(PymatgenTest): +class TestQChemDictSet: def test_init(self): test_molecule = QCInput.from_file(f"{TEST_DIR}/pcm.qin").molecule test_dict_set = QChemDictSet( @@ -469,7 +469,7 @@ def test_solvation_warnings(self): ) -class TestSinglePointSet(PymatgenTest): +class TestSinglePointSet: def test_init(self): test_molecule = QCInput.from_file(f"{TEST_DIR}/pcm.qin").molecule test_sp_set = SinglePointSet(molecule=test_molecule) @@ -671,7 +671,7 @@ def test_plots_init(self): assert test_sp_set.molecule == test_molecule -class TestOptSet(PymatgenTest): +class TestOptSet: def test_init(self): test_molecule = QCInput.from_file(f"{TEST_DIR}/pcm.qin").molecule test_opt_set = OptSet(molecule=test_molecule) @@ -846,7 +846,7 @@ def test_v5_vs_v6(self): assert v6_opt_set_modified.geom_opt == ref_dict -class TestTransitionStateSet(PymatgenTest): +class TestTransitionStateSet: def test_init(self): test_molecule = QCInput.from_file(f"{TEST_DIR}/pcm.qin").molecule test_ts_set = TransitionStateSet(molecule=test_molecule) @@ -927,7 +927,7 @@ def test_smd_init(self): assert test_ts_set.molecule == test_molecule -class TestForceSet(PymatgenTest): +class TestForceSet: def test_init(self): test_molecule = QCInput.from_file(f"{TEST_DIR}/pcm.qin").molecule test_forceset = ForceSet(molecule=test_molecule) @@ -1004,7 +1004,7 @@ def test_smd_init(self): assert test_forceset.molecule == test_molecule -class TestPESScanSet(PymatgenTest): +class TestPESScanSet: def test_init(self): test_molecule = QCInput.from_file(f"{TEST_DIR}/pes_scan.qin").molecule @@ -1097,7 +1097,7 @@ def test_smd_init(self): assert test_pes_scan.molecule == test_molecule -class TestFreqSet(PymatgenTest): +class TestFreqSet: def test_init(self): test_molecule = QCInput.from_file(f"{TEST_DIR}/pcm.qin").molecule test_freq_set = FreqSet(molecule=test_molecule) diff --git a/tests/io/qchem/test_utils.py b/tests/io/qchem/test_utils.py index 4ad091b8242..c12dc788063 100644 --- a/tests/io/qchem/test_utils.py +++ b/tests/io/qchem/test_utils.py @@ -6,7 +6,7 @@ from monty.io import zopen from pymatgen.io.qchem.utils import lower_and_check_unique, process_parsed_hess -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Ryan Kingsbury, Samuel Blau" __copyright__ = "Copyright 2018-2022, The Materials Project" @@ -15,7 +15,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/io/qchem/new_qchem_files" -class TestUtil(PymatgenTest): +class TestUtil: """test utils.""" def test_lower_and_check_unique(self): diff --git a/tests/io/test_adf.py b/tests/io/test_adf.py index d3b6785320f..43d210e8a3e 100644 --- a/tests/io/test_adf.py +++ b/tests/io/test_adf.py @@ -4,7 +4,7 @@ from pymatgen.core.structure import Molecule from pymatgen.io.adf import AdfInput, AdfKey, AdfOutput, AdfTask -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Xin Chen, chenxin13@mails.tsinghua.edu.cn" @@ -242,7 +242,7 @@ def test_serialization(self): } -class TestAdfInput(PymatgenTest): +class TestAdfInput: def test_main(self): tmp_file = f"{self.tmp_path}/adf.temp" mol = Molecule.from_str(rhb18_xyz, "xyz") diff --git a/tests/io/test_atat.py b/tests/io/test_atat.py index a9562f92511..23c9ca9472e 100644 --- a/tests/io/test_atat.py +++ b/tests/io/test_atat.py @@ -5,12 +5,12 @@ from pymatgen.core.structure import Structure from pymatgen.io.atat import Mcsqs -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/atat/mcsqs" -class TestAtat(PymatgenTest): +class TestAtat: def test_mcsqs_import(self): test_str = """1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 diff --git a/tests/io/test_cif.py b/tests/io/test_cif.py index 690c67c302d..3dd01454bb9 100644 --- a/tests/io/test_cif.py +++ b/tests/io/test_cif.py @@ -9,7 +9,7 @@ from pymatgen.electronic_structure.core import Magmom from pymatgen.io.cif import CifBlock, CifParser, CifWriter from pymatgen.symmetry.structure import SymmetrizedStructure -from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR try: import pybtex @@ -20,7 +20,7 @@ MCIF_TEST_DIR = f"{TEST_FILES_DIR}/io/cif/mcif" -class TestCifBlock(PymatgenTest): +class TestCifBlock: def test_to_str(self): with open(f"{TEST_FILES_DIR}/cif/Graphite.cif") as file: cif_str = file.read() @@ -164,7 +164,7 @@ def test_long_loop(self): assert str(CifBlock(data, loops, "test")) == cif_str -class TestCifIO(PymatgenTest): +class TestCifIO: def test_cif_parser(self): parser = CifParser(f"{TEST_FILES_DIR}/cif/LiFePO4.cif") for struct in parser.parse_structures(): @@ -999,7 +999,7 @@ def test_cif_writer_site_properties(self): assert "O O23 1 0.95662769 0.25000000 0.29286233 1 -1.0" in cif_str -class TestMagCif(PymatgenTest): +class TestMagCif: def setUp(self): self.mcif = CifParser(f"{MCIF_TEST_DIR}/magnetic.example.NiO.mcif") self.mcif_ncl = CifParser(f"{MCIF_TEST_DIR}/magnetic.ncl.example.GdB4.mcif") diff --git a/tests/io/test_core.py b/tests/io/test_core.py index bd4ad9ea7fa..77e6b410b96 100644 --- a/tests/io/test_core.py +++ b/tests/io/test_core.py @@ -10,7 +10,7 @@ from pymatgen.core.structure import Structure from pymatgen.io.cif import CifParser, CifWriter from pymatgen.io.core import InputFile, InputSet -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR if TYPE_CHECKING: from typing_extensions import Self @@ -44,7 +44,7 @@ def __str__(self): return f"{self.a}\n{self.b}" -class TestInputFile(PymatgenTest): +class TestInputFile: def test_file_io(self): with pytest.raises(FileNotFoundError, match="No such file or directory: 'fakepath.cif'"): StructInputFile.from_file("fakepath.cif") @@ -64,7 +64,7 @@ def test_msonable(self): assert sif.structure == temp_sif.structure -class TestInputSet(PymatgenTest): +class TestInputSet: @classmethod def setUpClass(cls): cls.sif1 = StructInputFile.from_file(f"{TEST_FILES_DIR}/cif/Li.cif") diff --git a/tests/io/test_lmto.py b/tests/io/test_lmto.py index 1ddc8c2abcf..7a73dfa791b 100644 --- a/tests/io/test_lmto.py +++ b/tests/io/test_lmto.py @@ -10,7 +10,7 @@ from pymatgen.electronic_structure.core import Spin from pymatgen.io.lmto import LMTOCopl, LMTOCtrl from pymatgen.util.num import round_to_sigfigs -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Marco Esters" __copyright__ = "Copyright 2017, The Materials Project" @@ -23,7 +23,7 @@ MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) -class TestCtrl(PymatgenTest): +class TestCtrl: def setUp(self): os.chdir(TEST_DIR) self.ref_bise = LMTOCtrl.from_file(filename="CTRL.BiSe") @@ -47,7 +47,7 @@ def test_read_write(self): assert self.ref_bise.structure.matches(ctrl_file.structure) -class TestCopl(PymatgenTest): +class TestCopl: def setUp(self): os.chdir(TEST_DIR) self.copl_bise = LMTOCopl("COPL.BiSe") diff --git a/tests/io/test_packmol.py b/tests/io/test_packmol.py index c6d25953dcd..5c709436d83 100644 --- a/tests/io/test_packmol.py +++ b/tests/io/test_packmol.py @@ -10,7 +10,7 @@ from pymatgen.analysis.molecule_matcher import MoleculeMatcher from pymatgen.core import Molecule from pymatgen.io.packmol import PackmolBoxGen -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/packmol" # error message is different in CI for unknown reasons (as of 2024-04-12) @@ -48,7 +48,7 @@ water = Molecule(water_atoms, water_coords) -class TestPackmolSet(PymatgenTest): +class TestPackmolSet: def test_packmol_with_molecule(self): """Test coords input as Molecule.""" pw = PackmolBoxGen().get_input_set( diff --git a/tests/io/test_phonopy.py b/tests/io/test_phonopy.py index 802e43049e2..588a027adc3 100644 --- a/tests/io/test_phonopy.py +++ b/tests/io/test_phonopy.py @@ -42,7 +42,7 @@ PHONON_DIR = f"{TEST_FILES_DIR}/phonon" -class TestPhonopyParser(PymatgenTest): +class TestPhonopyParser: def test_get_ph_bs(self): ph_bs = get_ph_bs_symm_line(f"{TEST_DIR}/NaCl_band.yaml", has_nac=True) @@ -98,7 +98,7 @@ def test_get_complete_dos(self): @pytest.mark.skipif(Phonopy is None, reason="Phonopy not present") -class TestStructureConversion(PymatgenTest): +class TestStructureConversion: def test_structure_conversion(self): struct_pmg = PymatgenTest.get_structure("LiFePO4") # add magmoms to site_properties @@ -126,7 +126,7 @@ def test_structure_conversion(self): @pytest.mark.skipif(Phonopy is None, reason="Phonopy not present") -class TestGetDisplacedStructures(PymatgenTest): +class TestGetDisplacedStructures: def test_get_displaced_structures(self): pmg_s = Structure.from_file(f"{TEST_DIR}/POSCAR-unitcell", primitive=False) supercell_matrix = np.diag((2, 1, 2)) @@ -246,7 +246,7 @@ def test_gruneisen_parameter(self): @pytest.mark.skipif(Phonopy is None, reason="Phonopy not present") -class TestThermalDisplacementMatrices(PymatgenTest): +class TestThermalDisplacementMatrices: def test_get_thermal_displacement_matrix(self): list_matrices = get_thermal_displacement_matrices( f"{PHONON_DIR}/thermal_displacement_matrices/thermal_displacement_matrices.yaml", diff --git a/tests/io/test_pwscf.py b/tests/io/test_pwscf.py index 6e39c8b4019..15743c7a9b6 100644 --- a/tests/io/test_pwscf.py +++ b/tests/io/test_pwscf.py @@ -6,12 +6,12 @@ from pytest import approx from pymatgen.io.pwscf import PWInput, PWInputError, PWOutput -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/pwscf" -class TestPWInput(PymatgenTest): +class TestPWInput: def test_init(self): struct = self.get_structure("Li2O") with pytest.raises(PWInputError, match="Missing O2- in pseudo specification"): @@ -542,7 +542,7 @@ def test_custom_decimal_precision_write_and_read_str(self): assert pw_str.strip() == str(PWInput.from_str(pw_str)).strip() -class TestPWOutput(PymatgenTest): +class TestPWOutput: def setUp(self): self.pw_out = PWOutput(f"{TEST_DIR}/Si.pwscf.out") diff --git a/tests/io/test_shengbte.py b/tests/io/test_shengbte.py index 303c9d094aa..961792df336 100644 --- a/tests/io/test_shengbte.py +++ b/tests/io/test_shengbte.py @@ -4,13 +4,13 @@ from numpy.testing import assert_array_equal from pymatgen.io.shengbte import Control -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR f90nml = pytest.importorskip("f90nml") TEST_DIR = f"{TEST_FILES_DIR}/io/shengbte" -class TestShengBTE(PymatgenTest): +class TestShengBTE: def setUp(self): self.filename = f"{TEST_DIR}/CONTROL-CSLD_Si" self.test_dict = { diff --git a/tests/io/test_template_input.py b/tests/io/test_template_input.py index 3be8ae45374..f6ea6e84cf6 100644 --- a/tests/io/test_template_input.py +++ b/tests/io/test_template_input.py @@ -5,12 +5,12 @@ import pytest from pymatgen.io.template import TemplateInputGen -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io" -class TestTemplateInputGen(PymatgenTest): +class TestTemplateInputGen: def test_write_inputs(self): input_set = TemplateInputGen().get_input_set( template=f"{TEST_DIR}/template_input_file.txt", diff --git a/tests/io/test_wannier90.py b/tests/io/test_wannier90.py index 93ac0e256e7..8a43bf62a22 100644 --- a/tests/io/test_wannier90.py +++ b/tests/io/test_wannier90.py @@ -8,12 +8,12 @@ from pytest import approx from pymatgen.io.wannier90 import Unk -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/io/wannier90" -class TestUnk(PymatgenTest): +class TestUnk: def setUp(self): rng = np.random.default_rng() self.data_std = rng.random((10, 5, 5, 5)) diff --git a/tests/io/test_xcrysden.py b/tests/io/test_xcrysden.py index 3a13a2cf7b5..095e8f73b6a 100644 --- a/tests/io/test_xcrysden.py +++ b/tests/io/test_xcrysden.py @@ -4,10 +4,9 @@ from pymatgen.core.structure import Structure from pymatgen.io.xcrysden import XSF -from pymatgen.util.testing import PymatgenTest -class TestXSF(PymatgenTest): +class TestXSF: def setUp(self): self.coords = [[0, 0, 0], [0.75, 0.5, 0.75]] self.lattice = [ diff --git a/tests/io/vasp/test_inputs.py b/tests/io/vasp/test_inputs.py index 1616ff4e5e7..13e28f4a4eb 100644 --- a/tests/io/vasp/test_inputs.py +++ b/tests/io/vasp/test_inputs.py @@ -38,7 +38,7 @@ VaspInput, _gen_potcar_summary_stats, ) -from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR # Filter some expected warnings warnings.filterwarnings( @@ -72,7 +72,7 @@ def _mock_complete_potcar_summary_stats(monkeypatch: pytest.MonkeyPatch) -> None @pytest.mark.filterwarnings( "ignore:POTCAR data with symbol .* is not known to pymatgen:pymatgen.io.vasp.inputs.UnknownPotcarWarning" ) -class TestPoscar(PymatgenTest): +class TestPoscar: def test_init(self): comp = Structure.from_file(f"{VASP_IN_DIR}/POSCAR").composition assert comp == Composition("Fe4P4O16") @@ -649,7 +649,7 @@ def test_vasp_6_4_2_format(self): assert poscar.structure.formula == "Li4 Fe4 P4 O16" -class TestIncar(PymatgenTest): +class TestIncar: def setUp(self): self.incar = Incar.from_file(f"{VASP_IN_DIR}/INCAR") @@ -1537,7 +1537,7 @@ def test_copy(self): @pytest.mark.filterwarnings( "ignore:POTCAR data with symbol .* is not known to pymatgen:pymatgen.io.vasp.inputs.UnknownPotcarWarning" ) -class TestPotcar(PymatgenTest): +class TestPotcar: def setUp(self): SETTINGS.setdefault("PMG_VASP_PSP_DIR", str(TEST_FILES_DIR)) self.filepath = f"{FAKE_POTCAR_DIR}/POTCAR.gz" @@ -1616,7 +1616,7 @@ def test_pickle(self): @pytest.mark.filterwarnings( "ignore:POTCAR data with symbol .* is not known to pymatgen:pymatgen.io.vasp.inputs.UnknownPotcarWarning" ) -class TestVaspInput(PymatgenTest): +class TestVaspInput: def setUp(self): filepath = f"{VASP_IN_DIR}/INCAR" incar = Incar.from_file(filepath) diff --git a/tests/io/vasp/test_optics.py b/tests/io/vasp/test_optics.py index 3a2caf7a94a..a898c5fb7eb 100644 --- a/tests/io/vasp/test_optics.py +++ b/tests/io/vasp/test_optics.py @@ -7,7 +7,7 @@ from pymatgen.io.vasp.optics import DielectricFunctionCalculator, delta_func, delta_methfessel_paxton, step_func from pymatgen.io.vasp.outputs import Vasprun -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Jimmy-Xuan Shen" __copyright__ = "Copyright 2022, The Materials Project" @@ -16,7 +16,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/io/vasp" -class TestVasprun(PymatgenTest): +class TestVasprun: def test_optics(self): eps_data_path = f"{TEST_DIR}/fixtures/reproduce_eps" vrun = Vasprun(f"{eps_data_path}/vasprun.xml") diff --git a/tests/io/vasp/test_outputs.py b/tests/io/vasp/test_outputs.py index e02b9ac027a..e67c241bf8a 100644 --- a/tests/io/vasp/test_outputs.py +++ b/tests/io/vasp/test_outputs.py @@ -41,7 +41,7 @@ Xdatcar, ) from pymatgen.io.wannier90 import Unk -from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR try: import h5py @@ -53,7 +53,7 @@ kpts_opt_vrun_path = f"{TEST_DIR}/fixtures/kpoints_opt/vasprun.xml.gz" -class TestVasprun(PymatgenTest): +class TestVasprun: def test_vasprun_ml(self): # Test for ML MD simulation # The trajectory data is stored in md_data @@ -832,7 +832,7 @@ def test_parse_potcar_cwd_relative(self): assert vrun.potcar_spec[ipot]["summary_stats"] == potcar[ipot]._summary_stats -class TestOutcar(PymatgenTest): +class TestOutcar: def test_init(self): outcar = Outcar(f"{VASP_OUT_DIR}/OUTCAR.gz") expected_mag = ( @@ -1423,7 +1423,7 @@ def test_read_table_pattern(self): ) -class TestBSVasprun(PymatgenTest): +class TestBSVasprun: def test_get_band_structure(self): filepath = f"{VASP_OUT_DIR}/vasprun_Si_bands.xml.gz" vasprun = BSVasprun(filepath, parse_potcar_file=False) @@ -1477,7 +1477,7 @@ def test_kpoints_opt(self): assert {*vrun_dct["output"]} >= {"eigenvalues", "eigenvalues_kpoints_opt"} -class TestOszicar(PymatgenTest): +class TestOszicar: def test_init(self): fpath = f"{VASP_OUT_DIR}/OSZICAR" oszicar = Oszicar(fpath) @@ -1493,7 +1493,7 @@ def test_static(self): assert set(oszicar.ionic_steps[-1]) == set({"F", "E0", "dE", "mag"}) -class TestLocpot(PymatgenTest): +class TestLocpot: def test_init(self): filepath = f"{VASP_OUT_DIR}/LOCPOT.gz" locpot = Locpot.from_file(filepath) @@ -1514,7 +1514,7 @@ def test_vasp_6x_style(self): assert {str(ele) for ele in locpot.structure.composition} == {"Mg", "Si"} -class TestChgcar(PymatgenTest): +class TestChgcar: @classmethod def setUpClass(cls): filepath = f"{VASP_OUT_DIR}/CHGCAR.nospin.gz" @@ -1638,7 +1638,7 @@ def test_as_dict_and_from_dict(self): ) -class TestAeccars(PymatgenTest): +class TestAeccars: # https://github.com/materialsproject/pymatgen/pull/3343 def test_read_write_file(self): aeccar0_test = Chgcar.from_file(f"{TEST_FILES_DIR}/command_line/bader/AECCAR0.gz") @@ -1654,7 +1654,7 @@ def test_read_write_file(self): assert_allclose(aeccar2.data["total"], aeccar2_read.data["total"]) -class TestElfcar(PymatgenTest): +class TestElfcar: def test_init(self): elfcar = Elfcar.from_file(f"{VASP_OUT_DIR}/ELFCAR.gz") assert approx(np.mean(elfcar.data["total"])) == 0.19076207645194002 @@ -1674,7 +1674,7 @@ def test_interpolation(self): assert len(elfcar.linear_slice([0.0, 0.0, 0.0], [1.0, 1.0, 1.0])) == 100 -class TestProcar(PymatgenTest): +class TestProcar: def test_init(self): filepath = f"{VASP_OUT_DIR}/PROCAR.simple" procar = Procar(filepath) @@ -1817,7 +1817,7 @@ def test_init(self): # TODO: test get_phonon_frequencies once cross-checked -class TestWavecar(PymatgenTest): +class TestWavecar: def setUp(self): latt_mat = np.array(np.eye(3) * 10, dtype=float) # lattice vectors self.vol = np.dot(latt_mat[0, :], np.cross(latt_mat[1, :], latt_mat[2, :])) # unit cell volume @@ -2095,7 +2095,7 @@ def test_write_unks(self): assert unk == unk_ncl -class TestEigenval(PymatgenTest): +class TestEigenval: def test_init(self): eig = Eigenval(f"{VASP_OUT_DIR}/EIGENVAL.gz") assert eig.ispin == 1 @@ -2135,7 +2135,7 @@ def test_eigenvalue_band_properties_separate_spins(self): assert props[3][1] -class TestWaveder(PymatgenTest): +class TestWaveder: def setUp(self): wder = Waveder.from_binary(f"{VASP_OUT_DIR}/WAVEDER", "float64") assert wder.nbands == 36 @@ -2168,7 +2168,7 @@ def _check(wder): _check(wderf) -class TestWSWQ(PymatgenTest): +class TestWSWQ: def setUp(self): self.wswq = WSWQ.from_file(f"{VASP_OUT_DIR}/WSWQ.gz") diff --git a/tests/io/vasp/test_sets.py b/tests/io/vasp/test_sets.py index 6b4f9ceebdb..6dd438c052b 100644 --- a/tests/io/vasp/test_sets.py +++ b/tests/io/vasp/test_sets.py @@ -91,7 +91,7 @@ def test_yb_2_warning(input_set: VaspInputSet) -> None: assert expected in str(record[0].message) -class TestSetChangeCheck(PymatgenTest): +class TestSetChangeCheck: def test_sets_changed(self): msg = ( "WARNING! These tests will fail when you change an input set. They are included " @@ -128,7 +128,7 @@ def test_sets_changed(self): assert hash_str == known_hashes[input_set], f"{input_set=}\n{msg}" -class TestVaspInputSet(PymatgenTest): +class TestVaspInputSet: @classmethod def setUpClass(cls): filepath = f"{VASP_IN_DIR}/POSCAR" @@ -165,7 +165,7 @@ def test_as_dict(self): assert dict_set.potcar_functional == dict_set.user_potcar_functional -class TestMITMPRelaxSet(PymatgenTest): +class TestMITMPRelaxSet: @classmethod def setUpClass(cls): cls.set = MITRelaxSet @@ -718,7 +718,7 @@ def test_get_nedos(self): assert vis._get_nedos(0.1) == pytest.approx(741, abs=1) -class TestMPStaticSet(PymatgenTest): +class TestMPStaticSet: def setUp(self): self.set = MPStaticSet @@ -870,7 +870,7 @@ def test_grid_size_from_struct(self): ) -class TestMatPESStaticSet(PymatgenTest): +class TestMatPESStaticSet: def setUp(self): self.struct = Structure.from_file(f"{VASP_IN_DIR}/POSCAR") self.prev_incar = Incar.from_file(f"{VASP_IN_DIR}/INCAR") @@ -987,7 +987,7 @@ def test_from_prev_calc(self): assert vis.kpoints is None -class TestMPNonSCFSet(PymatgenTest): +class TestMPNonSCFSet: def setUp(self): self.set = MPNonSCFSet @@ -1153,7 +1153,7 @@ def test_user_kpoint_override(self): assert vis.kpoints.style == Kpoints.supported_modes.Gamma -class TestMagmomLdau(PymatgenTest): +class TestMagmomLdau: def test_structure_from_prev_run(self): vrun = Vasprun(f"{VASP_OUT_DIR}/vasprun.magmom_ldau.xml.gz") structure = vrun.final_structure @@ -1188,7 +1188,7 @@ def test_ln_magmom(self): assert vis.incar["MAGMOM"] == magmom_ans -class TestMITMDSet(PymatgenTest): +class TestMITMDSet: def setUp(self): self.set = MITMDSet filepath = f"{VASP_IN_DIR}/POSCAR" @@ -1230,7 +1230,7 @@ def test_user_heat_speed(self): @skip_if_no_psp_dir -class TestMVLNPTMDSet(PymatgenTest): +class TestMVLNPTMDSet: def setUp(self): file_path = f"{VASP_IN_DIR}/POSCAR" self.struct = Structure.from_file(file_path) @@ -1266,7 +1266,7 @@ def test_as_from_dict(self): assert input_set.incar["NSW"] == 1000 -class TestMPMDSet(PymatgenTest): +class TestMPMDSet: def setUp(self): filepath = f"{VASP_IN_DIR}/POSCAR" self.struct = Structure.from_file(filepath) @@ -1308,7 +1308,7 @@ def test_as_from_dict(self): assert v.incar["NSW"] == 1000 -class TestMITNEBSet(PymatgenTest): +class TestMITNEBSet: def setUp(self): c1 = [[0.5] * 3, [0.9] * 3] c2 = [[0.5] * 3, [0.9, 0.1, 0.1]] @@ -1356,7 +1356,7 @@ def test_write_input(self): assert not os.path.isfile("04/POSCAR") -class TestMPSOCSet(PymatgenTest): +class TestMPSOCSet: def setUp(self): self.set = MPSOCSet @@ -1393,7 +1393,7 @@ def test_override_from_prev_calc(self): assert vis.incar["SIGMA"] == 0.025 -class TestMPNMRSet(PymatgenTest): +class TestMPNMRSet: def test_incar(self): filepath = f"{TEST_FILES_DIR}/cif/Li.cif" structure = Structure.from_file(filepath) @@ -1415,7 +1415,7 @@ def test_incar(self): @skip_if_no_psp_dir -class TestMVLSlabSet(PymatgenTest): +class TestMVLSlabSet: def setUp(self): self.set = MVLSlabSet struct = self.get_structure("Li2O") @@ -1487,7 +1487,7 @@ def test_as_from_dict(self): assert "structure" not in self.vis.as_dict(verbosity=1) -class TestMVLElasticSet(PymatgenTest): +class TestMVLElasticSet: def test_incar(self): mvlparam = MVLElasticSet(self.get_structure("Graphite")) incar = mvlparam.incar @@ -1498,7 +1498,7 @@ def test_incar(self): @skip_if_no_psp_dir -class TestMVLGWSet(PymatgenTest): +class TestMVLGWSet: def setUp(self): self.set = MVLGWSet self.struct = PymatgenTest.get_structure("Li2O") @@ -1576,7 +1576,7 @@ def test_bse(self): assert mvlgwgbse1.incar["ALGO"] == "Bse" -class TestMPHSERelaxSet(PymatgenTest): +class TestMPHSERelaxSet: def setUp(self): self.structure = dummy_structure self.set = MPHSERelaxSet @@ -1643,7 +1643,7 @@ def test_override_from_prev_calc(self): assert "VDW_S8" in vis_bj.incar -class TestMPHSEBS(PymatgenTest): +class TestMPHSEBS: def setUp(self): self.set = MPHSEBSSet @@ -1699,7 +1699,7 @@ def test_override_from_prev_calc(self): assert len(vis.kpoints.kpts) == 180 -class TestMVLScanRelaxSet(PymatgenTest): +class TestMVLScanRelaxSet: def setUp(self): self.set = MVLScanRelaxSet file_path = f"{VASP_IN_DIR}/POSCAR" @@ -1777,7 +1777,7 @@ def test_as_from_dict(self): assert v.user_incar_settings["NSW"] == 500 -class TestMPScanRelaxSet(PymatgenTest): +class TestMPScanRelaxSet: def setUp(self): file_path = f"{VASP_IN_DIR}/POSCAR" self.struct = Structure.from_file(file_path) @@ -1898,7 +1898,7 @@ def test_write_input(self): assert os.path.isfile(f"{self.tmp_path}/POSCAR") -class TestMPScanStaticSet(PymatgenTest): +class TestMPScanStaticSet: def setUp(self): self.set = MPScanStaticSet self.prev_run = f"{TEST_DIR}/fixtures/scan_relaxation" @@ -1988,7 +1988,7 @@ def test_override_from_prev_calc(self): assert lepsilon_vis.incar.get("NPAR") is None -class TestFunc(PymatgenTest): +class TestFunc: @skip_if_no_psp_dir def test_batch_write_input(self): structs = list(map(PymatgenTest.get_structure, ("Li2O", "LiFePO4"))) @@ -2000,7 +2000,7 @@ def test_batch_write_input(self): @skip_if_no_psp_dir -class TestMVLGBSet(PymatgenTest): +class TestMVLGBSet: def setUp(self): filepath = f"{TEST_FILES_DIR}/cif/Li.cif" self.struct = Structure.from_file(filepath) @@ -2026,7 +2026,7 @@ def test_kpoints(self): assert kpoints.kpts == [(k_a, k_b, 1)] -class TestMVLRelax52Set(PymatgenTest): +class TestMVLRelax52Set: def setUp(self): self.set = MVLRelax52Set file_path = f"{VASP_IN_DIR}/POSCAR" @@ -2064,7 +2064,7 @@ def test_as_from_dict(self): assert vasp_input.incar["NSW"] == 500 -class TestLobsterSet(PymatgenTest): +class TestLobsterSet: def setUp(self): self.set = LobsterSet file_path = f"{VASP_IN_DIR}/POSCAR" @@ -2163,7 +2163,7 @@ def test_as_from_dict(self): @skip_if_no_psp_dir -class TestMPAbsorptionSet(PymatgenTest): +class TestMPAbsorptionSet: def setUp(self): file_path = f"{TEST_DIR}/fixtures/absorption/static/POSCAR" self.structure = Structure.from_file(file_path) diff --git a/tests/io/xtb/test_inputs.py b/tests/io/xtb/test_inputs.py index 546386c6391..16d5be8e0fe 100644 --- a/tests/io/xtb/test_inputs.py +++ b/tests/io/xtb/test_inputs.py @@ -2,7 +2,7 @@ from pymatgen.core.structure import Molecule from pymatgen.io.xtb.inputs import CRESTInput -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Alex Epstein" __copyright__ = "Copyright 2020, The Materials Project" @@ -12,7 +12,7 @@ EXPECTED_DIR = f"{TEST_FILES_DIR}/io/xtb/expected_output" -class TestCRESTInput(PymatgenTest): +class TestCRESTInput: """ Checks that all attributes of CRESTInput match the expected values for sample inputs. diff --git a/tests/io/xtb/test_outputs.py b/tests/io/xtb/test_outputs.py index c4d3fe69777..e617996b8f1 100644 --- a/tests/io/xtb/test_outputs.py +++ b/tests/io/xtb/test_outputs.py @@ -7,7 +7,7 @@ from pymatgen.core.structure import Molecule from pymatgen.io.qchem.outputs import check_for_structure_changes from pymatgen.io.xtb.outputs import CRESTOutput -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR try: from openbabel import openbabel @@ -23,7 +23,7 @@ EXPECTED_DIR = f"{TEST_FILES_DIR}/io/xtb/expected_output" -class TestCRESTOutput(PymatgenTest): +class TestCRESTOutput: """ Checks that all attributes of CRESTOutput match the expected values for a sample CREST output directory. diff --git a/tests/optimization/test_neighbors.py b/tests/optimization/test_neighbors.py index 3542acd20ff..5ddd14f638e 100644 --- a/tests/optimization/test_neighbors.py +++ b/tests/optimization/test_neighbors.py @@ -4,10 +4,9 @@ from pymatgen.core.lattice import Lattice from pymatgen.optimization.neighbors import find_points_in_spheres -from pymatgen.util.testing import PymatgenTest -class TestNeighbors(PymatgenTest): +class TestNeighbors: def setUp(self): self.lattice = Lattice.cubic(10.0) self.cubic = self.lattice diff --git a/tests/phonon/test_bandstructure.py b/tests/phonon/test_bandstructure.py index 7f449792544..6545edb1e27 100644 --- a/tests/phonon/test_bandstructure.py +++ b/tests/phonon/test_bandstructure.py @@ -8,12 +8,12 @@ from pymatgen.electronic_structure.bandstructure import Kpoint from pymatgen.phonon.bandstructure import PhononBandStructureSymmLine -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/bandstructure" -class TestPhononBandStructureSymmLine(PymatgenTest): +class TestPhononBandStructureSymmLine: def setUp(self): with open(f"{TEST_DIR}/NaCl_phonon_bandstructure.json") as file: dct = json.load(file) diff --git a/tests/phonon/test_dos.py b/tests/phonon/test_dos.py index e586604d81e..a301540e4f0 100644 --- a/tests/phonon/test_dos.py +++ b/tests/phonon/test_dos.py @@ -9,12 +9,12 @@ from pymatgen.core import Element from pymatgen.phonon.dos import CompletePhononDos, PhononDos -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/phonon/dos" -class TestPhononDos(PymatgenTest): +class TestPhononDos: def setUp(self): with open(f"{TEST_DIR}/NaCl_ph_dos.json") as file: self.dos = PhononDos.from_dict(json.load(file)) @@ -182,7 +182,7 @@ def test_dos_fp_exceptions(self): self.dos.get_dos_fp_similarity(dos_fp, dos_fp2, col=1, metric=metric, normalize=False) -class TestCompletePhononDos(PymatgenTest): +class TestCompletePhononDos: def setUp(self): with open(f"{TEST_DIR}/NaCl_complete_ph_dos.json") as file: self.cdos = CompletePhononDos.from_dict(json.load(file)) diff --git a/tests/phonon/test_gruneisen.py b/tests/phonon/test_gruneisen.py index 748fd68c8c2..164790bfc91 100644 --- a/tests/phonon/test_gruneisen.py +++ b/tests/phonon/test_gruneisen.py @@ -9,7 +9,7 @@ from pymatgen.io.phonopy import get_gruneisen_ph_bs_symm_line, get_gruneisenparameter from pymatgen.phonon.gruneisen import GruneisenParameter from pymatgen.phonon.plotter import GruneisenPhononBandStructureSymmLine, GruneisenPhononBSPlotter, GruneisenPlotter -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR try: import phonopy @@ -21,7 +21,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/phonon/gruneisen" -class TestGruneisenPhononBandStructureSymmLine(PymatgenTest): +class TestGruneisenPhononBandStructureSymmLine: def setUp(self) -> None: self.bs_symm_line = get_gruneisen_ph_bs_symm_line( gruneisen_path=f"{TEST_DIR}/gruneisen_eq_plus_minus_InP.yaml", @@ -76,7 +76,7 @@ def test_as_dict_from_dict(self): @pytest.mark.skipif(TotalDos is None, reason="Phonopy not present") -class TestGruneisenParameter(PymatgenTest): +class TestGruneisenParameter: def setUp(self) -> None: self.gruneisen_obj = get_gruneisenparameter( f"{TEST_DIR}/gruneisen_mesh_InP.yaml", diff --git a/tests/phonon/test_ir_spectra.py b/tests/phonon/test_ir_spectra.py index 7a7eb40f4ce..491bbc24e7d 100644 --- a/tests/phonon/test_ir_spectra.py +++ b/tests/phonon/test_ir_spectra.py @@ -2,10 +2,10 @@ from monty.serialization import loadfn -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR -class TestIRDielectricTensor(PymatgenTest): +class TestIRDielectricTensor: def setUp(self): self.ir_spectra = loadfn(f"{TEST_FILES_DIR}/phonon/dos/ir_spectra_mp-991652_DDB.json") diff --git a/tests/phonon/test_thermal_displacements.py b/tests/phonon/test_thermal_displacements.py index aeb26a4dffc..7f138a9012a 100644 --- a/tests/phonon/test_thermal_displacements.py +++ b/tests/phonon/test_thermal_displacements.py @@ -6,12 +6,12 @@ from pymatgen.core.structure import Structure from pymatgen.phonon.thermal_displacements import ThermalDisplacementMatrices -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/phonon/thermal_displacement_matrices" -class TestThermalDisplacement(PymatgenTest): +class TestThermalDisplacement: """Test data from J. George's matlab code https://github.com/JaGeo/MolecularToolbox.""" def setUp(self) -> None: diff --git a/tests/symmetry/test_analyzer.py b/tests/symmetry/test_analyzer.py index 7966c815ce9..759e6e64a27 100644 --- a/tests/symmetry/test_analyzer.py +++ b/tests/symmetry/test_analyzer.py @@ -24,7 +24,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/symmetry/analyzer" -class TestSpacegroupAnalyzer(PymatgenTest): +class TestSpacegroupAnalyzer: def setUp(self): self.structure = Structure.from_file(f"{VASP_IN_DIR}/POSCAR") self.sg = SpacegroupAnalyzer(self.structure, 0.001) @@ -537,7 +537,7 @@ def test_are_symmetrically_equivalent(self): ) -class TestPointGroupAnalyzer(PymatgenTest): +class TestPointGroupAnalyzer: def test_spherical(self): pg_analyzer = PointGroupAnalyzer(CH4) assert pg_analyzer.sch_symbol == "Td" diff --git a/tests/symmetry/test_kpath_hin.py b/tests/symmetry/test_kpath_hin.py index 2a7cce41712..1cadbc40f7e 100644 --- a/tests/symmetry/test_kpath_hin.py +++ b/tests/symmetry/test_kpath_hin.py @@ -6,12 +6,11 @@ from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.kpath import KPathSeek -from pymatgen.util.testing import PymatgenTest pytest.importorskip("seekpath", reason="seekpath not installed") -class TestKPathSeek(PymatgenTest): +class TestKPathSeek: def test_kpath_generation(self): triclinic = [1, 2] monoclinic = range(3, 16) diff --git a/tests/symmetry/test_kpath_lm.py b/tests/symmetry/test_kpath_lm.py index 479ffecb65d..b203ddcae72 100644 --- a/tests/symmetry/test_kpath_lm.py +++ b/tests/symmetry/test_kpath_lm.py @@ -8,10 +8,10 @@ from pymatgen.core.structure import Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.symmetry.kpath import KPathLatimerMunro -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR -class TestKPathLatimerMunro(PymatgenTest): +class TestKPathLatimerMunro: def test_kpath_generation(self): triclinic = [1, 2] monoclinic = range(3, 16) diff --git a/tests/symmetry/test_kpath_sc.py b/tests/symmetry/test_kpath_sc.py index d88c97f79dd..72b1b4eb716 100644 --- a/tests/symmetry/test_kpath_sc.py +++ b/tests/symmetry/test_kpath_sc.py @@ -6,12 +6,12 @@ from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.kpath import KPathSetyawanCurtarolo -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR TEST_DIR = f"{TEST_FILES_DIR}/symmetry/space_group_structs" -class TestBandStructureSC(PymatgenTest): +class TestBandStructureSC: def test_kpath_generation(self): triclinic = [1, 2] monoclinic = range(3, 16) diff --git a/tests/symmetry/test_kpaths.py b/tests/symmetry/test_kpaths.py index 87c8bd16480..46a0f51671b 100644 --- a/tests/symmetry/test_kpaths.py +++ b/tests/symmetry/test_kpaths.py @@ -7,7 +7,7 @@ from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.bandstructure import HighSymmKpath -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR try: from seekpath import get_path @@ -17,7 +17,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/bandstructure" -class TestHighSymmKpath(PymatgenTest): +class TestHighSymmKpath: @pytest.mark.skipif(get_path is None, reason="No seek path present.") def test_kpath_generation(self): triclinic = [1, 2] diff --git a/tests/symmetry/test_maggroups.py b/tests/symmetry/test_maggroups.py index 72f184d553f..3e664592d3b 100644 --- a/tests/symmetry/test_maggroups.py +++ b/tests/symmetry/test_maggroups.py @@ -6,7 +6,6 @@ from pymatgen.core.lattice import Lattice from pymatgen.symmetry.groups import SpaceGroup from pymatgen.symmetry.maggroups import MagneticSpaceGroup -from pymatgen.util.testing import PymatgenTest __author__ = "Matthew Horton" __copyright__ = "Copyright 2017, The Materials Project" @@ -17,7 +16,7 @@ __date__ = "Feb 2017" -class TestMagneticSpaceGroup(PymatgenTest): +class TestMagneticSpaceGroup: def setUp(self): self.msg_1 = MagneticSpaceGroup([70, 530]) self.msg_2 = MagneticSpaceGroup([62, 448]) diff --git a/tests/symmetry/test_site_symmetries.py b/tests/symmetry/test_site_symmetries.py index 1b33f3a11f0..3bdd7c5f7f9 100644 --- a/tests/symmetry/test_site_symmetries.py +++ b/tests/symmetry/test_site_symmetries.py @@ -6,7 +6,7 @@ from monty.json import MontyDecoder from pymatgen.symmetry import site_symmetries as ss -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR __author__ = "Handong Ling" __version__ = "0.1" @@ -18,7 +18,7 @@ TEST_DIR = f"{TEST_FILES_DIR}/symmetry/site_symmetries" -class TestSiteSymmetries(PymatgenTest): +class TestSiteSymmetries: def setUp(self): with gzip.open(f"{TEST_DIR}/point_ops.json.gz", mode="rt") as file: self.point_ops = MontyDecoder().process_decoded(json.load(file)) diff --git a/tests/transformations/test_advanced_transformations.py b/tests/transformations/test_advanced_transformations.py index 2f73ace7cd3..479fbde5302 100644 --- a/tests/transformations/test_advanced_transformations.py +++ b/tests/transformations/test_advanced_transformations.py @@ -276,7 +276,7 @@ def test_as_dict(self): @pytest.mark.skipif(not enumlib_present, reason="enum_lib not present.") -class TestMagOrderingTransformation(PymatgenTest): +class TestMagOrderingTransformation: def setUp(self): lattice = Lattice.cubic(4.17) species = ["Ni", "O"] @@ -488,7 +488,7 @@ def test_advanced_usage(self): @pytest.mark.skipif(not enumlib_present, reason="enum_lib not present.") -class TestDopingTransformation(PymatgenTest): +class TestDopingTransformation: def test_apply_transformation(self): structure = PymatgenTest.get_structure("LiFePO4") spga = SpacegroupAnalyzer(structure, 0.1) @@ -551,7 +551,7 @@ def test_find_codopant(self): assert find_codopant(Species("Fe", 2), 3) == Species("In", 3) -class TestSlabTransformation(PymatgenTest): +class TestSlabTransformation: def test_apply_transformation(self): struct = self.get_structure("LiFePO4") trans = SlabTransformation([0, 0, 1], 10, 10, shift=0.25) @@ -570,7 +570,7 @@ def test_apply_transformation(self): assert_allclose(slab_from_gen.cart_coords, slab_from_trans.cart_coords) -class TestGrainBoundaryTransformation(PymatgenTest): +class TestGrainBoundaryTransformation: def test_apply_transformation(self): Al_bulk = Structure.from_spacegroup("Fm-3m", Lattice.cubic(2.8575585), ["Al"], [[0, 0, 0]]) gb_gen_params_s5 = { @@ -590,7 +590,7 @@ def test_apply_transformation(self): assert_allclose(gb_from_generator.cart_coords, gb_from_trans.cart_coords) -class TestDisorderedOrderedTransformation(PymatgenTest): +class TestDisorderedOrderedTransformation: def test_apply_transformation(self): # nonsensical example just for testing purposes struct = self.get_structure("BaNiO3") @@ -603,7 +603,7 @@ def test_apply_transformation(self): @pytest.mark.skipif(not mcsqs_cmd, reason="mcsqs not present.") -class TestSQSTransformation(PymatgenTest): +class TestSQSTransformation: def test_apply_transformation(self): pzt_structs = loadfn(f"{TEST_FILES_DIR}/io/atat/mcsqs/pzt-structs.json") trans = SQSTransformation(scaling=[2, 1, 1], search_time=0.01, instances=1, wd=0) @@ -649,7 +649,7 @@ def test_spin(self): @pytest.mark.skipif(ClusterSpace is None, reason="icet not installed.") -class TestSQSTransformationIcet(PymatgenTest): +class TestSQSTransformationIcet: stored_run: dict = loadfn(f"{TEST_FILES_DIR}/transformations/icet-sqs-fcc-Mg_75-Al_25-scaling_8.json.gz") scaling: int = 8 @@ -699,7 +699,7 @@ def test_monte_carlo(self): assert isinstance(sqs_output[0][key], val) -class TestCubicSupercellTransformation(PymatgenTest): +class TestCubicSupercellTransformation: def test_apply_transformation_cubic_supercell(self): structure = self.get_structure("TlBiSe2") min_atoms = 100 @@ -848,7 +848,7 @@ def test_apply_transformation_orthorhombic_supercell(self): assert transformed_cubic.lattice.angles == transformed_orthorhombic.lattice.angles -class TestAddAdsorbateTransformation(PymatgenTest): +class TestAddAdsorbateTransformation: def test_apply_transformation(self): co = Molecule(["C", "O"], [[0, 0, 0], [0, 0, 1.23]]) trans = AddAdsorbateTransformation(co) @@ -859,7 +859,7 @@ def test_apply_transformation(self): assert out.reduced_formula == "Pt4CO" -class TestSubstituteSurfaceSiteTransformation(PymatgenTest): +class TestSubstituteSurfaceSiteTransformation: def test_apply_transformation(self): trans = SubstituteSurfaceSiteTransformation("Au") pt = Structure(Lattice.cubic(5), ["Pt"], [[0, 0, 0]]) # fictitious @@ -870,7 +870,7 @@ def test_apply_transformation(self): @pytest.mark.skipif(not hiphive, reason="hiphive not present") -class TestMonteCarloRattleTransformation(PymatgenTest): +class TestMonteCarloRattleTransformation: def test_apply_transformation(self): struct = self.get_structure("Si") mcrt = MonteCarloRattleTransformation(0.01, 2, seed=1) diff --git a/tests/transformations/test_site_transformations.py b/tests/transformations/test_site_transformations.py index 0e97aceabc0..fc778b97257 100644 --- a/tests/transformations/test_site_transformations.py +++ b/tests/transformations/test_site_transformations.py @@ -17,14 +17,13 @@ ReplaceSiteSpeciesTransformation, TranslateSitesTransformation, ) -from pymatgen.util.testing import PymatgenTest enum_cmd = which("enum.x") or which("multienum.x") makestr_cmd = which("makestr.x") or which("makeStr.x") or which("makeStr.py") enumlib_present = enum_cmd and makestr_cmd -class TestTranslateSitesTransformation(PymatgenTest): +class TestTranslateSitesTransformation: def setUp(self): coords = [ [0, 0, 0], @@ -264,7 +263,7 @@ def test_str(self): ) -class TestAddSitePropertyTransformation(PymatgenTest): +class TestAddSitePropertyTransformation: def test_apply_transformation(self): struct = self.get_structure("Li2O2") sd = [[True, True, True] for _ in struct] @@ -279,7 +278,7 @@ def test_apply_transformation(self): assert_allclose(trans_set.site_properties[prop], manually_set.site_properties[prop]) -class TestRadialSiteDistortionTransformation(PymatgenTest): +class TestRadialSiteDistortionTransformation: def setUp(self): self.molecule = Molecule( species=["C", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H"], diff --git a/tests/util/test_io.py b/tests/util/test_io.py index 09458240656..1c810ab98a3 100644 --- a/tests/util/test_io.py +++ b/tests/util/test_io.py @@ -1,10 +1,10 @@ from __future__ import annotations from pymatgen.util.io_utils import micro_pyawk -from pymatgen.util.testing import VASP_OUT_DIR, PymatgenTest +from pymatgen.util.testing import VASP_OUT_DIR -class TestFunc(PymatgenTest): +class TestFunc: def test_micro_pyawk(self): data = [] diff --git a/tests/util/test_plotting.py b/tests/util/test_plotting.py index ec68c960d88..e9771589e06 100644 --- a/tests/util/test_plotting.py +++ b/tests/util/test_plotting.py @@ -3,7 +3,6 @@ import matplotlib.pyplot as plt from pymatgen.util.plotting import periodic_table_heatmap, van_arkel_triangle -from pymatgen.util.testing import PymatgenTest try: import pymatviz @@ -12,7 +11,7 @@ pymatviz = None -class TestFunc(PymatgenTest): +class TestFunc: def test_plot_periodic_heatmap(self): random_data = {"Te": 0.11083, "Au": 0.75756, "Th": 1.24758, "Ni": -2.0354} fig = periodic_table_heatmap(random_data) diff --git a/tests/vis/test_plotters.py b/tests/vis/test_plotters.py index 87311cc4d66..7fc28013d07 100644 --- a/tests/vis/test_plotters.py +++ b/tests/vis/test_plotters.py @@ -8,14 +8,14 @@ from monty.json import MontyDecoder from pymatgen.analysis.xas.spectrum import XAS -from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest +from pymatgen.util.testing import TEST_FILES_DIR from pymatgen.vis.plotters import SpectrumPlotter with open(f"{TEST_FILES_DIR}/analysis/spectrum_test/LiCoO2_k_xanes.json") as file: spect_data_dict = json.load(file, cls=MontyDecoder) -class TestSpectrumPlotter(PymatgenTest): +class TestSpectrumPlotter: def setUp(self): self.xanes = XAS.from_dict(spect_data_dict)