diff --git a/geopandas/tests/test_dissolve.py b/geopandas/tests/test_dissolve.py index d957bdf..dd0eafc 100644 --- a/geopandas/tests/test_dissolve.py +++ b/geopandas/tests/test_dissolve.py @@ -1,3 +1,5 @@ +import warnings + import numpy as np import pandas as pd @@ -289,7 +291,7 @@ def test_dissolve_dropna(): ) def test_dissolve_dropna_warn(nybb_polydf): # No warning with default params - with pytest.warns(None) as record: + with warnings.catch_warnings(record=True) as record: nybb_polydf.dissolve() for r in record: @@ -308,7 +310,7 @@ def test_dissolve_multi_agg(nybb_polydf, merged_shapes): merged_shapes[("BoroCode", "max")] = [5, 2] merged_shapes[("BoroName", "count")] = [3, 2] - with pytest.warns(None) as record: + with warnings.catch_warnings(record=True) as record: test = nybb_polydf.dissolve( by="manhattan_bronx", aggfunc={ diff --git a/geopandas/tests/test_geom_methods.py b/geopandas/tests/test_geom_methods.py index d94928a..d29932d 100644 --- a/geopandas/tests/test_geom_methods.py +++ b/geopandas/tests/test_geom_methods.py @@ -1,4 +1,5 @@ import string +import warnings import numpy as np from numpy.testing import assert_array_equal @@ -867,7 +868,7 @@ class TestGeomMethods: with pytest.warns(UserWarning, match="Geometry is in a geographic CRS"): self.g4.buffer(1) - with pytest.warns(None) as record: + with warnings.catch_warnings(record=True) as record: # do not warn for 0 self.g4.buffer(0) diff --git a/geopandas/tests/test_geoseries.py b/geopandas/tests/test_geoseries.py index c5a3ee5..d4b1425 100644 --- a/geopandas/tests/test_geoseries.py +++ b/geopandas/tests/test_geoseries.py @@ -3,6 +3,7 @@ import os import random import shutil import tempfile +import warnings import numpy as np from numpy.testing import assert_array_equal @@ -122,13 +123,13 @@ class TestSeries: # Test that warning is not issued when operating on aligned series a1, a2 = self.a1.align(self.a2) - with pytest.warns(None) as warnings: + with warnings.catch_warnings(record=True) as record: a1.contains(a2) # _series_op, explicitly aligned self.g1.intersects(self.g2) # _series_op, implicitly aligned a2.union(a1) # _geo_op, explicitly aligned self.g2.intersection(self.g1) # _geo_op, implicitly aligned - user_warnings = [w for w in warnings if w.category is UserWarning] + user_warnings = [w for w in record if w.category is UserWarning] assert not user_warnings, user_warnings[0].message def test_geom_equals(self): @@ -510,7 +511,7 @@ class TestConstructor: np.array([], dtype="float64"), np.array([], dtype="str"), ]: - with pytest.warns(None) as record: + with warnings.catch_warnings(record=True) as record: s = GeoSeries(arr) assert not record assert isinstance(s, GeoSeries) diff --git a/geopandas/tests/test_pandas_methods.py b/geopandas/tests/test_pandas_methods.py index 90a4aa9..b29ce85 100644 --- a/geopandas/tests/test_pandas_methods.py +++ b/geopandas/tests/test_pandas_methods.py @@ -302,8 +302,10 @@ def test_to_csv(df): assert df.to_csv(index=False) == exp +@pytest.mark.filterwarnings( + "ignore:Dropping of nuisance columns in DataFrame reductions" +) def test_numerical_operations(s, df): - # df methods ignore the geometry column exp = pd.Series([3, 4], index=["value1", "value2"]) assert_series_equal(df.sum(), exp) diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py index 95138ce..771eac8 100644 --- a/geopandas/tests/test_plotting.py +++ b/geopandas/tests/test_plotting.py @@ -620,7 +620,7 @@ class TestPolygonPlotting: t3 = Polygon([(2, 0), (3, 0), (3, 1)]) df_nan = GeoDataFrame({"geometry": t3, "values": [np.nan]}) - self.df3 = self.df.append(df_nan) + self.df3 = pd.concat([self.df, df_nan]) def test_single_color(self): diff --git a/geopandas/tests/test_sindex.py b/geopandas/tests/test_sindex.py index eaa2122..75bfe05 100644 --- a/geopandas/tests/test_sindex.py +++ b/geopandas/tests/test_sindex.py @@ -75,6 +75,7 @@ class TestSeriesSindex: s = GeoSeries([t1, t2, sq]) assert s.sindex.size == 3 + @pytest.mark.filterwarnings("ignore:The series.append method is deprecated") def test_polygons_append(self): t1 = Polygon([(0, 0), (1, 0), (1, 1)]) t2 = Polygon([(0, 0), (1, 1), (0, 1)]) diff --git a/geopandas/tests/test_testing.py b/geopandas/tests/test_testing.py index f85286d..1783dd2 100644 --- a/geopandas/tests/test_testing.py +++ b/geopandas/tests/test_testing.py @@ -1,3 +1,5 @@ +import warnings + import numpy as np from shapely.geometry import Point, Polygon @@ -125,7 +127,7 @@ def test_ignore_crs_mismatch(): # assert that with `check_crs=False` the assert passes, and also does not # generate any warning from comparing both geometries with different crs - with pytest.warns(None) as record: + with warnings.catch_warnings(record=True) as record: assert_geodataframe_equal(df1, df2, check_crs=False) assert len(record) == 0 diff --git a/geopandas/tools/tests/test_sjoin.py b/geopandas/tools/tests/test_sjoin.py index d518571..313a5a6 100644 --- a/geopandas/tools/tests/test_sjoin.py +++ b/geopandas/tools/tests/test_sjoin.py @@ -531,9 +531,9 @@ class TestSpatialJoinNYBB: def test_sjoin_empty_geometries(self): # https://github.com/geopandas/geopandas/issues/944 empty = GeoDataFrame(geometry=[GeometryCollection()] * 3) - df = sjoin(self.pointdf.append(empty), self.polydf, how="left") + df = sjoin(pd.concat([self.pointdf, empty]), self.polydf, how="left") assert df.shape == (24, 8) - df2 = sjoin(self.pointdf, self.polydf.append(empty), how="left") + df2 = sjoin(self.pointdf, pd.concat([self.polydf, empty]), how="left") assert df2.shape == (21, 8) @pytest.mark.parametrize("predicate", ["intersects", "within", "contains"])