Repository: googleapis/python-bigquery

Issue:
Unit tests emit quite a few warnings
It appears that recent additions resulted in several warning messages when running unit tests:
```
PytestUnknownMarkWarning: Unknown pytest.mark.enable_add_server_timeout_header - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/mark.html
    @pytest.mark.enable_add_server_timeout_header
...
FutureWarning: Assigning CRS to a GeoDataFrame without a geometry column is now deprecated and will not be supported in the future.
    return geopandas.GeoDataFrame(crs=_COORDINATE_REFERENCE_SYSTEM)
...
UserWarning: Geometry is in a geographic CRS. Results from 'area' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
```
At least those that we have control over (e.g. user warnings) should be addressed to reduce the noise.


Discussion:

Resolving patch:
diff --git a/google/cloud/bigquery/table.py b/google/cloud/bigquery/table.py
--- a/google/cloud/bigquery/table.py
+++ b/google/cloud/bigquery/table.py
@@ -2251,7 +2251,10 @@ def to_geodataframe(
         """
         if geopandas is None:
             raise ValueError(_NO_GEOPANDAS_ERROR)
-        return geopandas.GeoDataFrame(crs=_COORDINATE_REFERENCE_SYSTEM)
+
+        # Since an empty GeoDataFrame has no geometry column, we do not CRS on it,
+        # because that's deprecated.
+        return geopandas.GeoDataFrame()
 
     def to_dataframe_iterable(
         self,


Test patch:
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py
--- a/tests/unit/conftest.py
+++ b/tests/unit/conftest.py
@@ -54,3 +54,8 @@ def disable_add_server_timeout_header(request):
             noop_add_server_timeout_header,
         ):
             yield
+
+
+def pytest_configure(config):
+    # Explicitly register custom test markers to avoid warnings.
+    config.addinivalue_line("markers", "enable_add_server_timeout_header")
diff --git a/tests/unit/test_table.py b/tests/unit/test_table.py
--- a/tests/unit/test_table.py
+++ b/tests/unit/test_table.py
@@ -1866,8 +1866,7 @@ def test_to_geodataframe(self):
         df = row_iterator.to_geodataframe(create_bqstorage_client=False)
         self.assertIsInstance(df, geopandas.GeoDataFrame)
         self.assertEqual(len(df), 0)  # verify the number of rows
-        self.assertEqual(df.crs.srs, "EPSG:4326")
-        self.assertEqual(df.crs.name, "WGS 84")
+        self.assertIsNone(df.crs)
 
 
 class TestRowIterator(unittest.TestCase):
@@ -4027,8 +4026,14 @@ def test_to_geodataframe(self):
         self.assertEqual(df.name.dtype.name, "object")
         self.assertEqual(df.geog.dtype.name, "geometry")
         self.assertIsInstance(df.geog, geopandas.GeoSeries)
-        self.assertEqual(list(map(str, df.area)), ["0.0", "nan", "0.5"])
-        self.assertEqual(list(map(str, df.geog.area)), ["0.0", "nan", "0.5"])
+
+        with warnings.catch_warnings():
+            # Computing the area on a GeoDataFrame that uses a geographic Coordinate
+            # Reference System (CRS) produces a warning that we are not interested in.
+            warnings.filterwarnings("ignore", category=UserWarning)
+            self.assertEqual(list(map(str, df.area)), ["0.0", "nan", "0.5"])
+            self.assertEqual(list(map(str, df.geog.area)), ["0.0", "nan", "0.5"])
+
         self.assertEqual(df.crs.srs, "EPSG:4326")
         self.assertEqual(df.crs.name, "WGS 84")
         self.assertEqual(df.geog.crs.srs, "EPSG:4326")
@@ -4099,8 +4104,14 @@ def test_to_geodataframe_w_geography_column(self):
         self.assertEqual(df.geog.dtype.name, "geometry")
         self.assertEqual(df.geog2.dtype.name, "object")
         self.assertIsInstance(df.geog, geopandas.GeoSeries)
-        self.assertEqual(list(map(str, df.area)), ["0.0", "nan", "0.5"])
-        self.assertEqual(list(map(str, df.geog.area)), ["0.0", "nan", "0.5"])
+
+        with warnings.catch_warnings():
+            # Computing the area on a GeoDataFrame that uses a geographic Coordinate
+            # Reference System (CRS) produces a warning that we are not interested in.
+            warnings.filterwarnings("ignore", category=UserWarning)
+            self.assertEqual(list(map(str, df.area)), ["0.0", "nan", "0.5"])
+            self.assertEqual(list(map(str, df.geog.area)), ["0.0", "nan", "0.5"])
+
         self.assertEqual(
             [v.__class__.__name__ for v in df.geog], ["Point", "NoneType", "Polygon"]
         )
@@ -4110,10 +4121,14 @@ def test_to_geodataframe_w_geography_column(self):
         self.assertEqual(
             [v.__class__.__name__ for v in df.geog2], ["Point", "Point", "Point"]
         )
+
         # and can easily be converted to a GeoSeries
-        self.assertEqual(
-            list(map(str, geopandas.GeoSeries(df.geog2).area)), ["0.0", "0.0", "0.0"]
-        )
+        with warnings.catch_warnings():
+            warnings.filterwarnings("ignore", category=UserWarning)
+            self.assertEqual(
+                list(map(str, geopandas.GeoSeries(df.geog2).area)),
+                ["0.0", "0.0", "0.0"],
+            )
 
     @unittest.skipIf(geopandas is None, "Requires `geopandas`")
     @mock.patch("google.cloud.bigquery.table.RowIterator.to_dataframe")
@@ -4165,8 +4180,14 @@ def test_rowiterator_to_geodataframe_delegation(self, to_dataframe):
         self.assertEqual(df.name.dtype.name, "object")
         self.assertEqual(df.g.dtype.name, "geometry")
         self.assertIsInstance(df.g, geopandas.GeoSeries)
-        self.assertEqual(list(map(str, df.area)), ["0.0"])
-        self.assertEqual(list(map(str, df.g.area)), ["0.0"])
+
+        with warnings.catch_warnings():
+            # Computing the area on a GeoDataFrame that uses a geographic Coordinate
+            # Reference System (CRS) produces a warning that we are not interested in.
+            warnings.filterwarnings("ignore", category=UserWarning)
+            self.assertEqual(list(map(str, df.area)), ["0.0"])
+            self.assertEqual(list(map(str, df.g.area)), ["0.0"])
+
         self.assertEqual([v.__class__.__name__ for v in df.g], ["Point"])