Skip to content

Commit

Permalink
TST: skip postgis duplicate column test for pandas 2.0.x (#2891)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Richards <mrichards7@outlook.com.au>
  • Loading branch information
jorisvandenbossche and m-richards committed May 6, 2023
1 parent 2c8a649 commit 8416ee7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions ci/envs/311-latest-conda-forge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- python=3.11
# required
# - pandas
- pandas
- shapely
- fiona
- pyproj
Expand Down Expand Up @@ -34,6 +34,3 @@ dependencies:
- pyarrow
# doctest testing
- pytest-doctestplus
- pip
- pip:
- pandas==2.0.0rc1
3 changes: 2 additions & 1 deletion geopandas/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
PANDAS_GE_13 = Version(pd.__version__) >= Version("1.3.0")
PANDAS_GE_14 = Version(pd.__version__) >= Version("1.4.0rc0")
PANDAS_GE_15 = Version(pd.__version__) >= Version("1.5.0")
PANDAS_GE_20 = Version(pd.__version__) >= Version("2.0.0.dev0")
PANDAS_GE_20 = Version(pd.__version__) >= Version("2.0.0")
PANDAS_GE_21 = Version(pd.__version__) >= Version("2.1.0.dev0")


# -----------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions geopandas/io/tests/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import geopandas
from geopandas import GeoDataFrame, read_file, read_postgis

import geopandas._compat as compat
from geopandas.io.sql import _get_conn as get_conn, _write_postgis as write_postgis
from geopandas.tests.util import create_postgis, create_spatialite, validate_boro_df
import pytest
Expand Down Expand Up @@ -735,6 +736,10 @@ def test_append_with_different_crs(self, engine_postgis, df_nybb):
with pytest.raises(ValueError, match="CRS of the target table"):
write_postgis(df_nybb2, con=engine, name=table, if_exists="append")

@pytest.mark.xfail(
compat.PANDAS_GE_20 and not compat.PANDAS_GE_21,
reason="Duplicate columns are dropped in read_sql with pandas 2.0.x",
)
def test_duplicate_geometry_column_fails(self, engine_postgis):
"""
Tests that a ValueError is raised if an SQL query returns two geometry columns.
Expand Down

0 comments on commit 8416ee7

Please sign in to comment.