|
24 | 24 | preformat_peaks_response, |
25 | 25 | what_sites, |
26 | 26 | ) |
| 27 | +from tests.conftest import flaky_api |
27 | 28 |
|
28 | 29 | START_DATE = "2018-01-24" |
29 | 30 | END_DATE = "2018-01-25" |
30 | 31 |
|
31 | 32 | DATETIME_COL = "datetime" |
32 | 33 | SITENO_COL = "site_no" |
33 | 34 |
|
| 35 | +# Several tests in this module hit the live NWIS services, so retry a transient |
| 36 | +# upstream failure rather than failing CI (see ``conftest.flaky_api``). |
| 37 | +pytestmark = flaky_api |
| 38 | + |
34 | 39 |
|
35 | 40 | def _load_mock_json(file_name): |
36 | 41 | """Helper to load mock JSON from tests/data.""" |
@@ -254,21 +259,27 @@ def test_get_record_defunct_service_water_use(self): |
254 | 259 | class TestTZ: |
255 | 260 | """Tests relating to GitHub Issue #60.""" |
256 | 261 |
|
257 | | - sites, _ = what_sites(stateCd="MD") |
| 262 | + @pytest.fixture(scope="class") |
| 263 | + def sites(self): |
| 264 | + # Fetch once per class, at test time (not at collection) so a transient |
| 265 | + # upstream failure is retried by the module ``flaky`` marker instead of |
| 266 | + # aborting collection — a class-body call cannot be reran. |
| 267 | + sites, _ = what_sites(stateCd="MD") |
| 268 | + return sites |
258 | 269 |
|
259 | | - def test_multiple_tz_01(self): |
| 270 | + def test_multiple_tz_01(self, sites): |
260 | 271 | """Test based on GitHub Issue #60 - error merging different time zones.""" |
261 | 272 | # this test fails before issue #60 is fixed |
262 | | - iv, _ = get_iv(sites=self.sites.site_no.values[:25].tolist()) |
| 273 | + iv, _ = get_iv(sites=sites.site_no.values[:25].tolist()) |
263 | 274 | # assert that the datetime column exists |
264 | 275 | assert "datetime" in iv.index.names |
265 | 276 | # assert that it is a datetime type |
266 | 277 | assert isinstance(iv.index[0][1], datetime.datetime) |
267 | 278 |
|
268 | | - def test_multiple_tz_02(self): |
| 279 | + def test_multiple_tz_02(self, sites): |
269 | 280 | """Test based on GitHub Issue #60 - confirm behavior for same tz.""" |
270 | 281 | # this test passes before issue #60 is fixed |
271 | | - iv, _ = get_iv(sites=self.sites.site_no.values[:20].tolist()) |
| 282 | + iv, _ = get_iv(sites=sites.site_no.values[:20].tolist()) |
272 | 283 | # assert that the datetime column exists |
273 | 284 | assert "datetime" in iv.index.names |
274 | 285 | # assert that it is a datetime type |
|
0 commit comments