|
6 | 6 | from tempfile import TemporaryDirectory |
7 | 7 |
|
8 | 8 | import geopandas as gpd |
| 9 | +import pandas as pd |
9 | 10 |
|
10 | 11 |
|
11 | 12 | def test_kaitak_ags3_notebook_runs_and_creates_gpkg(examples_dir): |
@@ -117,12 +118,17 @@ def test_kaitak_ags3_notebook_runs_and_creates_gpkg(examples_dir): |
117 | 118 | gdf_original = gpd.read_file( |
118 | 119 | temp_original_gpkg_path, layer=table["table_name"] |
119 | 120 | ) |
120 | | - gdf_diff = gdf_original.compare(gdf_output) |
121 | | - assert gdf_diff.empty, ( |
122 | | - f"The original GeoPackage {temp_original_gpkg_path.name} and the output " |
123 | | - f"GeoPackage {gpkg_output_path.name} have a different {table['table_name']} table.\n" |
124 | | - f"{gdf_diff}" |
| 121 | + pd.testing.assert_frame_equal( |
| 122 | + gdf_original, gdf_output, check_exact=False, rtol=1e-5 |
125 | 123 | ) |
| 124 | + # It's also possible to assert that GIS geometries are not exactly equal. |
| 125 | + # However, when testing the equality of GeoDataFrames with pandas, the GIS |
| 126 | + # geometry are compared precisely, because the geometry is converted to a |
| 127 | + # WKT string and compared as strings. Therefore, if a less precise comparison |
| 128 | + # of GIS geometries is necessary, the assertion above needs changing too. |
| 129 | + # gpd.testing.assert_geoseries_equal( |
| 130 | + # gdf_original, gdf_output, check_less_precise=False |
| 131 | + # ) |
126 | 132 |
|
127 | 133 | # Remove the newly generated kaitak_gi.gpkg |
128 | 134 | os.remove(gpkg_output_path) |
|
0 commit comments