Skip to content

Commit

Permalink
Merge pull request #905 from hackingmaterials/ml-evs/fix-mp-test
Browse files Browse the repository at this point in the history
Skip the thermo tests rather than crash if MP API is missing
  • Loading branch information
ml-evs authored May 30, 2023
2 parents e8c54ee + 607210a commit 29f13fd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions matminer/featurizers/composition/tests/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@

class ThermoFeaturesTest(CompositionFeaturesTest):
def test_cohesive_energy(self):
mpr = MPRester()
try:
mpr = MPRester()
except ValueError:
raise SkipTest("Materials Project API key not set; Skipping cohesive energy test")

if not mpr.api_key:
raise SkipTest("Materials Project API key not set; Skipping cohesive energy test")

df_cohesive_energy = CohesiveEnergy().featurize_dataframe(self.df, col_id="composition")
self.assertAlmostEqual(df_cohesive_energy["cohesive energy"][0], 5.179358342, 2)

def test_cohesive_energy_mp(self):
mpr = MPRester()
try:
mpr = MPRester()
except ValueError:
raise SkipTest("Materials Project API key not set; Skipping cohesive energy test")

if not mpr.api_key:
raise SkipTest("Materials Project API key not set; Skipping cohesive energy test")
ce = CohesiveEnergyMP()
Expand Down

0 comments on commit 29f13fd

Please sign in to comment.