Skip to content

Commit

Permalink
Skip the thermo tests rather than crash if MP API is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed May 30, 2023
1 parent e8c54ee commit 607210a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions matminer/featurizers/composition/tests/test_thermo.py
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 607210a

Please sign in to comment.