8000 Fix several pytest "skip if" markers (#8694) · googleapis/google-cloud-python@a40d0d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit a40d0d4

Browse files
plamuttswast
authored andcommitted
Fix several pytest "skip if" markers (#8694)
"skipif" should be used instead of "skipIf", the latter is the thing from the unittest nodule.
1 parent 94043b1 commit a40d0d4

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

bigquery/tests/unit/test__pandas_helpers.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def all_(*functions):
7878
return functools.partial(do_all, functions)
7979

8080

81-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
81+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
8282
def test_is_datetime():
8383
assert is_datetime(pyarrow.timestamp("us", tz=None))
8484
assert not is_datetime(pyarrow.timestamp("ms", tz=None))
@@ -242,15 +242,15 @@ def test_all_():
242242
("UNKNOWN_TYPE", "REPEATED", is_none),
243243
],
244244
)
245-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
245+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
246246
def test_bq_to_arrow_data_type(module_under_test, bq_type, bq_mode, is_correct_type):
247247
field = schema.SchemaField("ignored_name", bq_type, mode=bq_mode)
248248
actual = module_under_test.bq_to_arrow_data_type(field)
249249
assert is_correct_type(actual)
250250

251251

252252
@pytest.mark.parametrize("bq_type", ["RECORD", "record", "STRUCT", "struct"])
253-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
253+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
254254
def test_bq_to_arrow_data_type_w_struct(module_under_test, bq_type):
255255
fields = (
256256
schema.SchemaField("field01", "STRING"),
@@ -294,7 +294,7 @@ def test_bq_to_arrow_data_type_w_struct(module_under_test, bq_type):
294294

295295

296296
@pytest.mark.parametrize("bq_type", ["RECORD", "record", "STRUCT", "struct"])
297-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
297+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
298298
def test_bq_to_arrow_data_type_w_array_struct(module_under_test, bq_type):
299299
fields = (
300300
schema.SchemaField("field01", "STRING"),
@@ -338,7 +338,7 @@ def test_bq_to_arrow_data_type_w_array_struct(module_under_test, bq_type):
338338
assert actual.value_type.equals(expected_value_type)
339339

340340

341-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
341+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
342342
def test_bq_to_arrow_data_type_w_struct_unknown_subfield(module_under_test):
343343
fields = (
344344
schema.SchemaField("field1", "STRING"),
@@ -434,8 +434,8 @@ def test_bq_to_arrow_data_type_w_struct_unknown_subfield(module_under_test):
434434
),
435435
],
436436
)
437-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
438-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
437+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
438+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
439439
def test_bq_to_arrow_array_w_nullable_scalars(module_under_test, bq_type, rows):
440440
series = pandas.Series(rows, dtype="object")
441441
bq_field = schema.SchemaField("field_name", bq_type)
@@ -444,8 +444,8 @@ def test_bq_to_arrow_array_w_nullable_scalars(module_under_test, bq_type, rows):
444444
assert rows == roundtrip
445445

446446

447-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
448-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
447+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
448+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
449449
def test_bq_to_arrow_array_w_arrays(module_under_test):
450450
rows = [[1, 2, 3], [], [4, 5, 6]]
451451
series = pandas.Series(rows, dtype="object")
@@ -456,8 +456,8 @@ def test_bq_to_arrow_array_w_arrays(module_under_test):
456456

457457

458458
@pytest.mark.parametrize("bq_type", ["RECORD", "record", "STRUCT", "struct"])
459-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
460-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
459+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
460+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
461461
def test_bq_to_arrow_array_w_structs(module_under_test, bq_type):
462462
rows = [
463463
{"int_col": 123, "string_col": "abc"},
@@ -478,8 +478,8 @@ def test_bq_to_arrow_array_w_structs(module_under_test, bq_type):
478478
assert rows == roundtrip
479479

480480

481-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
482-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
481+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
482+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
483483
def test_bq_to_arrow_array_w_special_floats(module_under_test):
484484
bq_field = schema.SchemaField("field_name", "FLOAT64")
485485
rows = [float("-inf"), float("nan"), float("inf"), None]
@@ -493,7 +493,7 @@ def test_bq_to_arrow_array_w_special_floats(module_under_test):
493493
assert roundtrip[3] is None
494494

495495

496-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
496+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
497497
def test_bq_to_arrow_schema_w_unknown_type(module_under_test):
498498
fields = (
499499
schema.SchemaField("field1", "STRING"),
@@ -506,8 +506,8 @@ def test_bq_to_arrow_schema_w_unknown_type(module_under_test):
506506
assert actual is None
507507

508508

509-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
510-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
509+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
510+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
511511
def test_dataframe_to_arrow_w_required_fields(module_under_test):
512512
bq_schema = (
513513
schema.SchemaField("field01", "STRING", mode="REQUIRED"),
@@ -561,8 +561,8 @@ def test_dataframe_to_arrow_w_required_fields(module_under_test):
561561
assert not arrow_field.nullable
562562

563563

564-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
565-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
564+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
565+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
566566
def test_dataframe_to_arrow_w_unknown_type(module_under_test):
567567
bq_schema = (
568568
schema.SchemaField("field00", "UNKNOWN_TYPE"),
@@ -594,16 +594,16 @@ def test_dataframe_to_arrow_w_unknown_type(module_under_test):
594594
assert arrow_schema[3].name == "field03"
595595

596596

597-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
597+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
598598
def test_dataframe_to_parquet_without_pyarrow(module_under_test, monkeypatch):
599599
monkeypatch.setattr(module_under_test, "pyarrow", None)
600600
with pytest.raises(ValueError) as exc_context:
601601
module_under_test.dataframe_to_parquet(pandas.DataFrame(), (), None)
602602
assert "pyarrow is required" in str(exc_context.value)
603603

604604

605-
@pytest.mark.skipIf(pandas is None, "Requires `pandas`")
606-
@pytest.mark.skipIf(pyarrow is None, "Requires `pyarrow`")
605+
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
606+
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
607607
def test_dataframe_to_parquet_w_missing_columns(module_under_test, monkeypatch):
608608
with pytest.raises(ValueError) as exc_context:
609609
module_under_test.dataframe_to_parquet(

bigquery/tests/unit/test_magics.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def test__make_bqstorage_client_false():
256256
assert got is None
257257

258258

259-
@pytest.mark.skipIf(
260-
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
259+
@pytest.mark.skipif(
260+
bigquery_storage_v1beta1 is None, reason="Requires `google-cloud-bigquery-storage`"
261261
)
262262
def test__make_bqstorage_client_true():
263263
credentials_mock = mock.create_autospec(
@@ -411,8 +411,8 @@ def test_bigquery_magic_clears_display_in_verbose_mode():
411411

412412

413413
@pytest.mark.usefixtures("ipython_interactive")
414-
@pytest.mark.skipIf(
415-
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
414+
@pytest.mark.skipif(
415+
bigquery_storage_v1beta1 is None, reason="Requires `google-cloud-bigquery-storage`"
416416
)
417417
def test_bigquery_magic_with_bqstorage_from_argument(monkeypatch):
418418
ip = IPython.get_ipython()
@@ -461,8 +461,8 @@ def test_bigquery_magic_with_bqstorage_from_argument(monkeypatch):
461461

462462

463463
@pytest.mark.usefixtures("ipython_interactive")
464-
@pytest.mark.skipIf(
465-
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
464+
@pytest.mark.skipif(
465+
bigquery_storage_v1beta1 is None, reason="Requires `google-cloud-bigquery-storage`"
466466
)
467467
def test_bigquery_magic_with_bqstorage_from_context(monkeypatch):
468468
ip = IPython.get_ipython()
@@ -511,8 +511,8 @@ def test_bigquery_magic_with_bqstorage_from_context(monkeypatch):
511511

512512

513513
@pytest.mark.usefixtures("ipython_interactive")
514-
@pytest.mark.skipIf(
515-
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
514+
@pytest.mark.skipif(
515+
bigquery_storage_v1beta1 is None, reason="Requires `google-cloud-bigquery-storage`"
516516
)
517517
def test_bigquery_magic_without_bqstorage(monkeypatch):
518518
ip = IPython.get_ipython()

0 commit comments

Comments
 (0)
0