Skip to content

Commit 6224fb6

Browse files
authored
tests(bigframes): re-enable some tests blocking the doctest (#16806)
Fixes internal tests 506201379🦕
1 parent 68c3016 commit 6224fb6

3 files changed

Lines changed: 10 additions & 15 deletions

File tree

packages/bigframes/bigframes/bigquery/_operations/struct.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ def struct(value: dataframe.DataFrame) -> series.Series:
4141
4242
>>> srs = series.Series([{"version": 1, "project": "pandas"}, {"version": 2, "project": "numpy"},])
4343
>>> df = srs.struct.explode()
44-
>>> df = df[["project", "version"]] # set the column order to ensure stable output for doctest
4544
>>> bbq.struct(df)
46-
0 {'project': 'pandas', 'version': 1}
47-
1 {'project': 'numpy', 'version': 2}
48-
dtype: struct<project: string, version: int64>[pyarrow]
45+
0 {'version': 1, 'project': 'pandas'}
46+
1 {'version': 2, 'project': 'numpy'}
47+
dtype: struct<version: int64, project: string>[pyarrow]
4948
5049
Args:
5150
value (bigframes.dataframe.DataFrame):

packages/bigframes/tests/system/small/bigquery/test_json.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ def test_to_json_from_int():
398398
def test_to_json_from_struct():
399399
s = bpd.Series(
400400
[
401-
{"project": "pandas", "version": 1},
402-
{"project": "numpy", "version": 2},
401+
{"version": 1, "project": "pandas"},
402+
{"version": 2, "project": "numpy"},
403403
]
404404
)
405405
assert dtypes.is_struct_like(s.dtype)
@@ -410,9 +410,7 @@ def test_to_json_from_struct():
410410
dtype=dtypes.JSON_DTYPE,
411411
)
412412

413-
actual_json = [json.loads(x) for x in actual.to_pandas()]
414-
expected_json = [json.loads(x) for x in expected.to_pandas()]
415-
assert actual_json == expected_json
413+
pd.testing.assert_series_equal(actual.to_pandas(), expected.to_pandas())
416414

417415

418416
def test_to_json_string_from_int():
@@ -425,8 +423,8 @@ def test_to_json_string_from_int():
425423
def test_to_json_string_from_struct():
426424
s = bpd.Series(
427425
[
428-
{"project": "pandas", "version": 1},
429-
{"project": "numpy", "version": 2},
426+
{"version": 1, "project": "pandas"},
427+
{"version": 2, "project": "numpy"},
430428
]
431429
)
432430
assert dtypes.is_struct_like(s.dtype)
@@ -437,9 +435,7 @@ def test_to_json_string_from_struct():
437435
dtype=dtypes.STRING_DTYPE,
438436
)
439437

440-
actual_json = [json.loads(x) for x in actual.to_pandas()]
441-
expected_json = [json.loads(x) for x in expected.to_pandas()]
442-
assert actual_json == expected_json
438+
pd.testing.assert_series_equal(actual.to_pandas(), expected.to_pandas())
443439

444440

445441
def test_json_keys():

packages/bigframes/tests/system/small/test_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ def test_divmods_scalars(scalars_dfs, col_x, other, method):
12881288

12891289
if bf_mod_result.dtype == pd.Int64Dtype():
12901290
bigframes.testing.utils.assert_series_equal(
1291-
pd_mod_result, bf_mod_result.to_pandas()
1291+
pd_div_result, bf_div_result.to_pandas(), check_dtype=False
12921292
)
12931293
else:
12941294
bigframes.testing.utils.assert_series_equal(

0 commit comments

Comments
 (0)