Skip to content

Commit 86c1066

Browse files
committed
Ruff PT018: broke up multi-part asserts
1 parent 7ea544f commit 86c1066

File tree

5 files changed

+44
-22
lines changed

5 files changed

+44
-22
lines changed

tests/fast/api/test_native_tz.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@ class TestNativeTimeZone:
1616
def test_native_python_timestamp_timezone(self, duckdb_cursor):
1717
duckdb_cursor.execute("SET timezone='America/Los_Angeles';")
1818
res = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").fetchone()
19-
assert res[0].hour == 14 and res[0].minute == 52
19+
assert res[0].hour == 14
20+
assert res[0].minute == 52
2021
assert res[0].tzinfo.zone == "America/Los_Angeles"
2122

2223
res = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").fetchall()[0]
23-
assert res[0].hour == 14 and res[0].minute == 52
24+
assert res[0].hour == 14
25+
assert res[0].minute == 52
2426
assert res[0].tzinfo.zone == "America/Los_Angeles"
2527

2628
res = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").fetchmany(1)[0]
27-
assert res[0].hour == 14 and res[0].minute == 52
29+
assert res[0].hour == 14
30+
assert res[0].minute == 52
2831
assert res[0].tzinfo.zone == "America/Los_Angeles"
2932

3033
duckdb_cursor.execute("SET timezone='UTC';")
3134
res = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").fetchone()
32-
assert res[0].hour == 21 and res[0].minute == 52
35+
assert res[0].hour == 21
36+
assert res[0].minute == 52
3337
assert res[0].tzinfo.zone == "UTC"
3438

3539
def test_native_python_time_timezone(self, duckdb_cursor):
@@ -43,11 +47,13 @@ def test_pandas_timestamp_timezone(self, duckdb_cursor):
4347
res = duckdb_cursor.execute("SET timezone='America/Los_Angeles';")
4448
res = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").df()
4549
assert res.dtypes["tz"].tz.zone == "America/Los_Angeles"
46-
assert res["tz"][0].hour == 14 and res["tz"][0].minute == 52
50+
assert res["tz"][0].hour == 14
51+
assert res["tz"][0].minute == 52
4752

4853
duckdb_cursor.execute("SET timezone='UTC';")
4954
res = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").df()
50-
assert res["tz"][0].hour == 21 and res["tz"][0].minute == 52
55+
assert res["tz"][0].hour == 21
56+
assert res["tz"][0].minute == 52
5157

5258
def test_pandas_timestamp_time(self, duckdb_cursor):
5359
with pytest.raises(
@@ -63,12 +69,14 @@ def test_arrow_timestamp_timezone(self, duckdb_cursor):
6369
table = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").fetch_arrow_table()
6470
res = table.to_pandas()
6571
assert res.dtypes["tz"].tz.zone == "America/Los_Angeles"
66-
assert res["tz"][0].hour == 14 and res["tz"][0].minute == 52
72+
assert res["tz"][0].hour == 14
73+
assert res["tz"][0].minute == 52
6774

6875
duckdb_cursor.execute("SET timezone='UTC';")
6976
res = duckdb_cursor.execute(f"select TimeRecStart as tz from '{filename}'").fetch_arrow_table().to_pandas()
7077
assert res.dtypes["tz"].tz.zone == "UTC"
71-
assert res["tz"][0].hour == 21 and res["tz"][0].minute == 52
78+
assert res["tz"][0].hour == 21
79+
assert res["tz"][0].minute == 52
7280

7381
def test_arrow_timestamp_time(self, duckdb_cursor):
7482
duckdb_cursor.execute("SET timezone='America/Los_Angeles';")
@@ -82,8 +90,10 @@ def test_arrow_timestamp_time(self, duckdb_cursor):
8290
.fetch_arrow_table()
8391
.to_pandas()
8492
)
85-
assert res1["tz"][0].hour == 14 and res1["tz"][0].minute == 52
86-
assert res2["tz"][0].hour == res2["tz"][0].hour and res2["tz"][0].minute == res1["tz"][0].minute
93+
assert res1["tz"][0].hour == 14
94+
assert res1["tz"][0].minute == 52
95+
assert res2["tz"][0].hour == res2["tz"][0].hour
96+
assert res2["tz"][0].minute == res1["tz"][0].minute
8797

8898
duckdb_cursor.execute("SET timezone='UTC';")
8999
res1 = (
@@ -96,5 +106,7 @@ def test_arrow_timestamp_time(self, duckdb_cursor):
96106
.fetch_arrow_table()
97107
.to_pandas()
98108
)
99-
assert res1["tz"][0].hour == 21 and res1["tz"][0].minute == 52
100-
assert res2["tz"][0].hour == res2["tz"][0].hour and res2["tz"][0].minute == res1["tz"][0].minute
109+
assert res1["tz"][0].hour == 21
110+
assert res1["tz"][0].minute == 52
111+
assert res2["tz"][0].hour == res2["tz"][0].hour
112+
assert res2["tz"][0].minute == res1["tz"][0].minute

tests/fast/arrow/test_arrow_version_format.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def test_decimal_v1_5(self, duckdb_cursor):
2121
pa.schema([("data", pa.decimal32(5, 2))]),
2222
)
2323
col_type = duckdb_cursor.execute("FROM decimal_32").fetch_arrow_table().schema.field("data").type
24-
assert col_type.bit_width == 32 and pa.types.is_decimal(col_type)
24+
assert col_type.bit_width == 32
25+
assert pa.types.is_decimal(col_type)
2526

2627
decimal_64 = pa.Table.from_pylist( # noqa: F841
2728
[
@@ -33,19 +34,22 @@ def test_decimal_v1_5(self, duckdb_cursor):
3334
pa.schema([("data", pa.decimal64(16, 3))]),
3435
)
3536
col_type = duckdb_cursor.execute("FROM decimal_64").fetch_arrow_table().schema.field("data").type
36-
assert col_type.bit_width == 64 and pa.types.is_decimal(col_type)
37+
assert col_type.bit_width == 64
38+
assert pa.types.is_decimal(col_type)
3739
for version in ["1.0", "1.1", "1.2", "1.3", "1.4"]:
3840
duckdb_cursor.execute(f"SET arrow_output_version = {version}")
3941
result = duckdb_cursor.execute("FROM decimal_32").fetch_arrow_table()
4042
col_type = result.schema.field("data").type
41-
assert col_type.bit_width == 128 and pa.types.is_decimal(col_type)
43+
assert col_type.bit_width == 128
44+
assert pa.types.is_decimal(col_type)
4245
assert result.to_pydict() == {
4346
"data": [Decimal("100.20"), Decimal("110.21"), Decimal("31.20"), Decimal("500.20")]
4447
}
4548

4649
result = duckdb_cursor.execute("FROM decimal_64").fetch_arrow_table()
4750
col_type = result.schema.field("data").type
48-
assert col_type.bit_width == 128 and pa.types.is_decimal(col_type)
51+
assert col_type.bit_width == 128
52+
assert pa.types.is_decimal(col_type)
4953
assert result.to_pydict() == {
5054
"data": [Decimal("1000.231"), Decimal("1100.231"), Decimal("999999999999.231"), Decimal("500.200")]
5155
}

tests/fast/spark/test_spark_filter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def test_dataframe_filter(self, spark):
8181
res = df2.collect()
8282
assert len(res) == 2
8383
for item in res:
84-
assert item.gender == "M" and item.state == "OH"
84+
assert item.gender == "M"
85+
assert item.state == "OH"
8586

8687
# Filter IS IN List values
8788
li = ["OH", "NY"]
@@ -95,7 +96,8 @@ def test_dataframe_filter(self, spark):
9596
df2 = df.filter(~df.state.isin(li))
9697
res = df2.collect()
9798
for item in res:
98-
assert item.state != "OH" and item.state != "NY"
99+
assert item.state != "OH"
100+
assert item.state != "NY"
99101

100102
df2 = df.filter(not df.state.isin(li))
101103
res2 = df2.collect()

tests/fast/spark/test_spark_functions_numeric.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,12 @@ def test_random(self, spark):
334334
res = df.withColumn("rand", sf.rand()).collect()
335335

336336
assert isinstance(res[0].rand, float)
337-
assert res[0].rand >= 0 and res[0].rand < 1
337+
assert res[0].rand >= 0
338+
assert res[0].rand < 1
338339

339340
assert isinstance(res[1].rand, float)
340-
assert res[1].rand >= 0 and res[1].rand < 1
341+
assert res[1].rand >= 0
342+
assert res[1].rand < 1
341343

342344
@pytest.mark.parametrize("sign_func", [sf.sign, sf.signum])
343345
def test_sign(self, spark, sign_func):

tests/fast/test_import_export.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ def import_database(import_location):
3232
def move_database(export_location, import_location):
3333
export_dir = Path(export_location)
3434
import_dir = Path(import_location)
35-
assert export_dir.exists() and export_dir.is_dir()
36-
assert import_dir.exists() and import_dir.is_dir()
35+
assert export_dir.exists()
36+
assert export_dir.is_dir()
37+
assert import_dir.exists()
38+
assert import_dir.is_dir()
3739

3840
for file in ["schema.sql", "load.sql", "tbl.csv"]:
3941
shutil.move(export_dir / file, import_dir)

0 commit comments

Comments
 (0)