Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit e48cfcd

Browse files
committed
adds import or skip commands to accompany pyarrow import or skips
1 parent 14f51d3 commit e48cfcd

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

tests/unit/test_table.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,16 +2416,15 @@ def test_to_arrow_error_if_pyarrow_is_none(self):
24162416
row_iterator.to_arrow()
24172417

24182418
def test_to_arrow(self):
2419-
import numpy
2419+
pytest.importorskip("numpy")
24202420
pyarrow = pytest.importorskip("pyarrow")
24212421
row_iterator = self._make_one()
24222422
tbl = row_iterator.to_arrow()
24232423
self.assertIsInstance(tbl, pyarrow.Table)
24242424
self.assertEqual(tbl.num_rows, 0)
24252425

24262426
def test_to_arrow_iterable(self):
2427-
import numpy
2428-
import numpy
2427+
pytest.importorskip("numpy")
24292428
pyarrow = pytest.importorskip(
24302429
"pyarrow", minversion=self.PYARROW_MINIMUM_VERSION
24312430
)
@@ -3099,7 +3098,7 @@ def test_to_arrow_iterable_w_bqstorage(self):
30993098
bqstorage_client._transport.grpc_channel.close.assert_not_called()
31003099

31013100
def test_to_arrow(self):
3102-
import numpy
3101+
pytest.importorskip("numpy")
31033102
pyarrow = pytest.importorskip(
31043103
"pyarrow", minversion=self.PYARROW_MINIMUM_VERSION
31053104
)
@@ -3184,7 +3183,7 @@ def test_to_arrow(self):
31843183
)
31853184

31863185
def test_to_arrow_w_nulls(self):
3187-
import numpy
3186+
pytest.importorskip("numpy")
31883187
pyarrow = pytest.importorskip(
31893188
"pyarrow", minversion=self.PYARROW_MINIMUM_VERSION
31903189
)
@@ -3221,7 +3220,7 @@ def test_to_arrow_w_nulls(self):
32213220
self.assertEqual(ages, [32, 29, None, 111])
32223221

32233222
def test_to_arrow_w_unknown_type(self):
3224-
import numpy
3223+
pytest.importorskip("numpy")
32253224
pyarrow = pytest.importorskip(
32263225
"pyarrow", minversion=self.PYARROW_MINIMUM_VERSION
32273226
)
@@ -3267,7 +3266,7 @@ def test_to_arrow_w_unknown_type(self):
32673266
self.assertTrue(all("sport" in str(warning) for warning in warned))
32683267

32693268
def test_to_arrow_w_empty_table(self):
3270-
import numpy
3269+
pytest.importorskip("numpy")
32713270
pyarrow = pytest.importorskip(
32723271
"pyarrow", minversion=self.PYARROW_MINIMUM_VERSION
32733272
)
@@ -3309,7 +3308,7 @@ def test_to_arrow_w_empty_table(self):
33093308
self.assertEqual(child_field.type.value_type[1].name, "age")
33103309

33113310
def test_to_arrow_max_results_w_explicit_bqstorage_client_warning(self):
3312-
import numpy
3311+
pytest.importorskip("numpy")
33133312
pytest.importorskip("pyarrow")
33143313
pytest.importorskip("google.cloud.bigquery_storage")
33153314
from google.cloud.bigquery.schema import SchemaField
@@ -3352,7 +3351,7 @@ def test_to_arrow_max_results_w_explicit_bqstorage_client_warning(self):
33523351
mock_client._ensure_bqstorage_client.assert_not_called()
33533352

33543353
def test_to_arrow_max_results_w_create_bqstorage_client_no_warning(self):
3355-
import numpy
3354+
pytest.importorskip("numpy")
33563355
pytest.importorskip("pyarrow")
33573356
pytest.importorskip("google.cloud.bigquery_storage")
33583357
from google.cloud.bigquery.schema import SchemaField
@@ -3391,7 +3390,7 @@ def test_to_arrow_max_results_w_create_bqstorage_client_no_warning(self):
33913390
mock_client._ensure_bqstorage_client.assert_not_called()
33923391

33933392
def test_to_arrow_w_bqstorage(self):
3394-
import numpy
3393+
pytest.importorskip("numpy")
33953394
pyarrow = pytest.importorskip("pyarrow")
33963395
pytest.importorskip("google.cloud.bigquery_storage")
33973396
from google.cloud.bigquery import schema
@@ -3475,7 +3474,7 @@ def test_to_arrow_w_bqstorage(self):
34753474
bqstorage_client._transport.grpc_channel.close.assert_not_called()
34763475

34773476
def test_to_arrow_w_bqstorage_creates_client(self):
3478-
import numpy
3477+
pytest.importorskip("numpy")
34793478
pytest.importorskip("pyarrow")
34803479
pytest.importorskip("google.cloud.bigquery_storage")
34813480
from google.cloud.bigquery import schema
@@ -3509,7 +3508,7 @@ def test_to_arrow_w_bqstorage_creates_client(self):
35093508
bqstorage_client._transport.grpc_channel.close.assert_called_once()
35103509

35113510
def test_to_arrow_ensure_bqstorage_client_wo_bqstorage(self):
3512-
import numpy
3511+
pytest.importorskip("numpy")
35133512
pyarrow = pytest.importorskip(
35143513
"pyarrow", minversion=self.PYARROW_MINIMUM_VERSION
35153514
)
@@ -3543,7 +3542,7 @@ def mock_verify_version(raise_if_error: bool = False):
35433542
self.assertEqual(tbl.num_rows, 2)
35443543

35453544
def test_to_arrow_w_bqstorage_no_streams(self):
3546-
import numpy
3545+
pytest.importorskip("numpy")
35473546
pyarrow = pytest.importorskip("pyarrow")
35483547
pytest.importorskip("google.cloud.bigquery_storage")
35493548
from google.cloud.bigquery import schema
@@ -3583,7 +3582,7 @@ def test_to_arrow_w_bqstorage_no_streams(self):
35833582
self.assertEqual(actual_table.schema[2].name, "colB")
35843583

35853584
def test_to_arrow_progress_bar(self):
3586-
import numpy
3585+
pytest.importorskip("numpy")
35873586
pytest.importorskip("pyarrow")
35883587
pytest.importorskip("tqdm")
35893588
pytest.importorskip("tqdm.notebook")
@@ -3717,7 +3716,7 @@ def test_to_dataframe_iterable_with_dtypes(self):
37173716
self.assertEqual(df_2["age"][0], 33)
37183717

37193718
def test_to_dataframe_iterable_w_bqstorage(self):
3720-
import numpy
3719+
pytest.importorskip("numpy")
37213720
pandas = pytest.importorskip("pandas")
37223721
pyarrow = pytest.importorskip("pyarrow")
37233722
pytest.importorskip("google.cloud.bigquery_storage")
@@ -3792,7 +3791,7 @@ def test_to_dataframe_iterable_w_bqstorage(self):
37923791
bqstorage_client._transport.grpc_channel.close.assert_not_called()
37933792

37943793
def test_to_dataframe_iterable_w_bqstorage_max_results_warning(self):
3795-
import numpy
3794+
pytest.importorskip("numpy")
37963795
pandas = pytest.importorskip("pandas")
37973796
pytest.importorskip("google.cloud.bigquery_storage")
37983797
from google.cloud.bigquery import schema
@@ -4536,7 +4535,7 @@ def test_to_dataframe_w_none_dtypes_mapper(self):
45364535

45374536
def test_to_dataframe_w_unsupported_dtypes_mapper(self):
45384537
pytest.importorskip("pandas")
4539-
import numpy
4538+
numpy = pytest.importorskip("numpy")
45404539
from google.cloud.bigquery.schema import SchemaField
45414540

45424541
schema = [
@@ -4820,7 +4819,7 @@ def test_to_dataframe_max_results_w_create_bqstorage_client_no_warning(self):
48204819
mock_client._ensure_bqstorage_client.assert_not_called()
48214820

48224821
def test_to_dataframe_w_bqstorage_creates_client(self):
4823-
import numpy
4822+
pytest.importorskip("numpy")
48244823
pytest.importorskip("pandas")
48254824
pytest.importorskip("google.cloud.bigquery_storage")
48264825
from google.cloud.bigquery import schema
@@ -4854,7 +4853,7 @@ def test_to_dataframe_w_bqstorage_creates_client(self):
48544853
bqstorage_client._transport.grpc_channel.close.assert_called_once()
48554854

48564855
def test_to_dataframe_w_bqstorage_no_streams(self):
4857-
import numpy
4856+
pytest.importorskip("numpy")
48584857
pytest.importorskip("pandas")
48594858
pytest.importorskip("google.cloud.bigquery_storage")
48604859
from google.cloud.bigquery import schema
@@ -4883,7 +4882,7 @@ def test_to_dataframe_w_bqstorage_no_streams(self):
48834882
self.assertTrue(got.empty)
48844883

48854884
def test_to_dataframe_w_bqstorage_logs_session(self):
4886-
import numpy
4885+
pytest.importorskip("numpy")
48874886
pytest.importorskip("google.cloud.bigquery_storage")
48884887
pytest.importorskip("pandas")
48894888
pytest.importorskip("pyarrow")
@@ -4908,7 +4907,7 @@ def test_to_dataframe_w_bqstorage_logs_session(self):
49084907
)
49094908

49104909
def test_to_dataframe_w_bqstorage_empty_streams(self):
4911-
import numpy
4910+
pytest.importorskip("numpy")
49124911
pytest.importorskip("google.cloud.bigquery_storage")
49134912
pytest.importorskip("pandas")
49144913
pyarrow = pytest.importorskip("pyarrow")
@@ -4963,7 +4962,7 @@ def test_to_dataframe_w_bqstorage_empty_streams(self):
49634962
self.assertTrue(got.empty)
49644963

49654964
def test_to_dataframe_w_bqstorage_nonempty(self):
4966-
import numpy
4965+
pytest.importorskip("numpy")
49674966
pytest.importorskip("google.cloud.bigquery_storage")
49684967
pytest.importorskip("pandas")
49694968
pyarrow = pytest.importorskip("pyarrow")
@@ -5046,7 +5045,7 @@ def test_to_dataframe_w_bqstorage_nonempty(self):
50465045
bqstorage_client._transport.grpc_channel.close.assert_not_called()
50475046

50485047
def test_to_dataframe_w_bqstorage_multiple_streams_return_unique_index(self):
5049-
import numpy
5048+
pytest.importorskip("numpy")
50505049
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
50515050
pytest.importorskip("pandas")
50525051
pyarrow = pytest.importorskip("pyarrow")
@@ -5099,7 +5098,7 @@ def test_to_dataframe_w_bqstorage_multiple_streams_return_unique_index(self):
50995098
self.assertTrue(got.index.is_unique)
51005099

51015100
def test_to_dataframe_w_bqstorage_updates_progress_bar(self):
5102-
import numpy
5101+
pytest.importorskip("numpy")
51035102
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
51045103
pytest.importorskip("pandas")
51055104
pyarrow = pytest.importorskip("pyarrow")
@@ -5177,7 +5176,7 @@ def blocking_to_arrow(*args, **kwargs):
51775176
tqdm_mock().close.assert_called_once()
51785177

51795178
def test_to_dataframe_w_bqstorage_exits_on_keyboardinterrupt(self):
5180-
import numpy
5179+
pytest.importorskip("numpy")
51815180
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
51825181
pytest.importorskip("pandas")
51835182
pyarrow = pytest.importorskip("pyarrow")
@@ -5353,7 +5352,7 @@ def test_to_dataframe_w_bqstorage_snapshot(self):
53535352
row_iterator.to_dataframe(bqstorage_client)
53545353

53555354
def test_to_dataframe_concat_categorical_dtype_w_pyarrow(self):
5356-
import numpy
5355+
pytest.importorskip("numpy")
53575356
pytest.importorskip("google.cloud.bigquery_storage")
53585357
pandas = pytest.importorskip("pandas")
53595358
pyarrow = pytest.importorskip("pyarrow")
@@ -5636,7 +5635,7 @@ def test_rowiterator_to_geodataframe_delegation(self, to_dataframe):
56365635
"""
56375636
pandas = pytest.importorskip("pandas")
56385637
geopandas = pytest.importorskip("geopandas")
5639-
import numpy
5638+
numpy = pytest.importorskip("numpy")
56405639
from shapely import wkt
56415640

56425641
row_iterator = self._make_one_from_data(

0 commit comments

Comments
 (0)