Skip to content

Commit d6af4ab

Browse files
authored
tests(google-cloud-bigquery-storage): drop usage of pytz in tests/*.py (#15480)
This PR resolves the following failure which appears in ``` ==================================== ERRORS ==================================== ________________ ERROR collecting tests/unit/test_reader_v1.py _________________ ImportError while importing test module '/tmpfs/src/github/google-cloud-python/packages/google-cloud-bigquery-storage/tests/unit/test_reader_v1.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /usr/local/lib/python3.14/importlib/__init__.py:88: in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/unit/test_reader_v1.py:31: in from .helpers import SCALAR_BLOCKS, SCALAR_COLUMN_NAMES, SCALAR_COLUMNS tests/unit/helpers.py:20: in import pytz E ModuleNotFoundError: No module named 'pytz' _____________ ERROR collecting tests/unit/test_reader_v1_arrow.py ______________ ImportError while importing test module '/tmpfs/src/github/google-cloud-python/packages/google-cloud-bigquery-storage/tests/unit/test_reader_v1_arrow.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /usr/local/lib/python3.14/importlib/__init__.py:88: in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/unit/test_reader_v1_arrow.py:33: in from .helpers import SCALAR_BLOCKS, SCALAR_COLUMN_NAMES, SCALAR_COLUMNS tests/unit/helpers.py:20: in import pytz E ModuleNotFoundError: No module named 'pytz' ``` `pytz` was used in tests but not explicitly installed. This PR removes usage of `pytz` in tests, although it is still needed transitively via `pandas`
1 parent d727ef3 commit d6af4ab

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

.librarian/generator-input/client-post-processing/bigquery-storage-integration.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ replacements:
461461
google-api-core==1.34.1
462462
libcst==0.2.5
463463
fastavro==0.21.2
464+
# pytz is required by pandas
465+
pytz
464466
pandas==1.0.5
465467
pyarrow==0.15.0
466468
google-auth==2.14.1

.librarian/state.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ libraries:
892892
tag_format: '{id}-v{version}'
893893
- id: google-cloud-bigquery-storage
894894
version: 2.36.0
895-
last_generated_commit: bd94e0b8c4975af0a66dc1f846c63c77dbc0064e
895+
last_generated_commit: 6b36371f6f3099624547e9ce4c1db304161e6afe
896896
apis:
897897
- path: google/cloud/bigquery/storage/v1beta2
898898
service_config: bigquerystorage_v1beta2.yaml

packages/google-cloud-bigquery-storage/noxfile.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
PACKAGE_NAME = "google-cloud-bigquery-storage"
5656

5757
UNIT_TEST_STANDARD_DEPENDENCIES = [
58-
"cachetools",
5958
"mock",
6059
"asyncmock",
6160
"pytest",
@@ -85,7 +84,6 @@
8584
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = []
8685
SYSTEM_TEST_DEPENDENCIES: List[str] = []
8786
SYSTEM_TEST_EXTRAS: List[str] = [
88-
"cryptography",
8987
"fastavro",
9088
"pandas",
9189
"pyarrow",

packages/google-cloud-bigquery-storage/testing/constraints-3.7.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
google-api-core==1.34.1
88
libcst==0.2.5
99
fastavro==0.21.2
10+
# pytz is required by pandas
11+
pytz
1012
pandas==1.0.5
1113
pyarrow==0.15.0
1214
google-auth==2.14.1
15+
# cryptography is a direct dependency of google-auth
16+
cryptography==38.0.3
1317
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2453)
1418
# Add the minimum supported version of grpcio to constraints files
1519
proto-plus==1.22.3

packages/google-cloud-bigquery-storage/tests/system/reader/test_reader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import uuid
2323

2424
import pytest
25-
import pytz
2625

2726
from google.cloud import bigquery
2827

@@ -451,7 +450,9 @@ def test_decoding_data_types(
451450
"bool_field": True,
452451
"geography_field": "POINT(-49.3028 69.0622)",
453452
"person_struct_field": {"name": "John", "age": 42},
454-
"timestamp_field": dt.datetime(2019, 8, 9, 13, 38, 22, 17896, tzinfo=pytz.UTC),
453+
"timestamp_field": dt.datetime(
454+
2019, 8, 9, 13, 38, 22, 17896, tzinfo=dt.timezone.utc
455+
),
455456
"date_field": dt.date(1995, 3, 17),
456457
"time_field": dt.time(16, 24, 51),
457458
"string_array_field": ["foo", "bar", "baz"],

packages/google-cloud-bigquery-storage/tests/unit/helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import datetime
1818
import decimal
1919

20-
import pytz
21-
2220
SCALAR_COLUMNS = [
2321
{"name": "int_col", "type": "int64"},
2422
{"name": "float_col", "type": "float64"},
@@ -42,7 +40,7 @@
4240
"bytes_col": b"ascii bytes",
4341
"date_col": datetime.date(1998, 9, 4),
4442
"time_col": datetime.time(12, 0),
45-
"ts_col": datetime.datetime(2000, 1, 1, 5, 0, tzinfo=pytz.utc),
43+
"ts_col": datetime.datetime(2000, 1, 1, 5, 0, tzinfo=datetime.timezone.utc),
4644
},
4745
{
4846
"int_col": 456,
@@ -53,7 +51,7 @@
5351
"bytes_col": b"\xbb\xee\xff",
5452
"date_col": datetime.date(1995, 3, 2),
5553
"time_col": datetime.time(13, 37),
56-
"ts_col": datetime.datetime(1965, 4, 3, 2, 1, tzinfo=pytz.utc),
54+
"ts_col": datetime.datetime(1965, 4, 3, 2, 1, tzinfo=datetime.timezone.utc),
5755
},
5856
],
5957
[
@@ -66,7 +64,9 @@
6664
"bytes_col": b"\x54\x69\x6d",
6765
"date_col": datetime.date(1970, 1, 1),
6866
"time_col": datetime.time(16, 20),
69-
"ts_col": datetime.datetime(1991, 8, 25, 20, 57, 8, tzinfo=pytz.utc),
67+
"ts_col": datetime.datetime(
68+
1991, 8, 25, 20, 57, 8, tzinfo=datetime.timezone.utc
69+
),
7070
}
7171
],
7272
]

0 commit comments

Comments
 (0)