Skip to content

Commit 8ba815d

Browse files
author
Stevenray Janke
committed
Move _gdf_matches_json_alt func to init
1 parent 1856c71 commit 8ba815d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tests/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import h5py
22
from geopandas import GeoDataFrame
3-
3+
import json
44
import hashlib
55
from pathlib import Path
66

@@ -20,3 +20,8 @@ def _gdf_matches_json(gdf: GeoDataFrame, json_file: Path) -> bool:
2020
def get_sha1_hash(path: Path) -> str:
2121
with open(path, "rb") as f:
2222
return hashlib.sha1(f.read()).hexdigest()
23+
24+
25+
def _gdf_matches_json_alt(gdf: GeoDataFrame, json_file: Path) -> bool:
26+
with open(json_file) as j:
27+
return json.loads(gdf.to_json()) == json.load(j)

tests/test_geom.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from src.rashdf import RasGeomHdf
99

10-
from . import _create_hdf_with_group_attrs, _gdf_matches_json
10+
from . import _create_hdf_with_group_attrs, _gdf_matches_json, _gdf_matches_json_alt
1111

1212
TEST_DATA = Path("./tests/data")
1313
MUNCIE_G05 = TEST_DATA / "ras/Muncie.g05.hdf"
@@ -29,11 +29,6 @@ def test_projection(tmp_path):
2929
assert ras_hdf.projection() == CRS.from_wkt(wkt)
3030

3131

32-
def _gdf_matches_json_alt(gdf: GeoDataFrame, json_file: Path) -> bool:
33-
with open(json_file) as j:
34-
return json.loads(gdf.to_json()) == json.load(j)
35-
36-
3732
def test_mesh_area_names():
3833
with RasGeomHdf(MUNCIE_G05) as ghdf:
3934
assert ghdf.mesh_area_names() == ["2D Interior Area", "Perimeter_NW"]
@@ -206,6 +201,6 @@ def test_cross_sections_velocity():
206201
assert _gdf_matches_json_alt(ghdf.cross_sections_velocity(), xs_velocity_json)
207202

208203

209-
def ttest_cross_sections_velocity_not_found():
204+
def test_cross_sections_velocity_not_found():
210205
with RasGeomHdf(COAL_G01) as ghdf:
211206
assert (ghdf.cross_sections_velocity(), None)

0 commit comments

Comments
 (0)