Skip to content

Commit 1464cee

Browse files
mhuckapavoljuhas
andauthored
Robustify the Pubchem live api pytest test (#1276)
The Pubchem server often returns a "server busy" error. The code in pubchem_test.py would retry the test in those situations (as desired), but it turned out that the error still got propagated up and cause pytest to report a failure. This PR tries to make the test more robust against server busy errors. --------- Co-authored-by: Pavol Juhas <pavol.juhas@gmail.com>
1 parent bdd19ef commit 1464cee

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/openfermion/chem/pubchem_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
"""Tests for pubchem.py."""
1414

15-
import time
1615
import unittest
1716
from unittest.mock import patch
1817

1918
import numpy
2019
import pytest
20+
import pubchempy
2121

2222
from openfermion.chem.pubchem import geometry_from_pubchem
2323
from openfermion.testing.testing_utils import module_importable
@@ -152,7 +152,7 @@ def test_water_2d(self):
152152
with pytest.raises(ValueError, match='Incorrect value for the argument structure'):
153153
_ = geometry_from_pubchem('water', structure='foo')
154154

155-
@pytest.mark.flaky(retries=3, delay=2)
155+
@pytest.mark.flaky(retries=3, delay=2, only_on=[pubchempy.ServerBusyError])
156156
def test_geometry_from_pubchem_live_api(self):
157-
water_geometry = geometry_from_pubchem('water') # pragma: no cover
158-
self.assertEqual(len(water_geometry), 3) # pragma: no cover
157+
water_geometry = geometry_from_pubchem('water')
158+
self.assertEqual(len(water_geometry), 3)

0 commit comments

Comments
 (0)