8000 Enhance GaussDB Compatibility and Optimize Test Suite by pangpang20 · Pull Request #6 · HuaweiCloudDeveloper/gaussdb-python · GitHub
[go: up one dir, main page]

Skip to content

Enhance GaussDB Compatibility and Optimize Test Suite #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions tests/fix_faker.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,8 @@ def match_float(self, spec, got, want, rel=None):
assert got == want

def _server_rounds(self):
"""Return True if the connected server perform float rounding"""
if self.conn.info.vendor == "CockroachDB":
return True
else:
# Versions older than 12 make some rounding. e.g. in Postgres 10.4
# select '-1.409006204063909e+112'::float8
# -> -1.40900620406391e+112
return self.conn.info.server_version < 120000
'''Return True if the connected server perform float rounding.'''
return True

def make_Float4(self, spec):
return self.make_float(spec, size=32)
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_load_record_binary(conn, want, rec):
assert type(o1) is type(o2)


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def testcomp(svcconn):
if is_crdb(svcconn):
pytest.skip(crdb_skip_message("composite"))
Expand Down
11 changes: 7 additions & 4 deletions tests/types/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ def test_load_datetimetz_tzname(self, conn, val, expr, datestyle_in, datestyle_o
def test_load_datetimetz_tz(self, conn, fmt_out, tzname, expr, tzoff):
conn.execute("select set_config('TimeZone', %s, true)", [tzname])
cur = conn.cursor(binary=fmt_out)
ts = cur.execute("select %s::timestamptz", [expr]).fetchone()[0]
assert ts.utcoffset().total_seconds() == tzoff
ts = cur.execute("select extract(timezone from %s::timestamptz)", [expr]).fetchone()[0]
assert ts == tzoff

@pytest.mark.parametrize(
"val, type",
Expand Down Expand Up @@ -488,6 +488,11 @@ def test_max_with_timezone(self, conn, fmt_out, valname, tzval, tzname):
tz = dt.timezone(as_tzoffset(tzval))
want = val.replace(tzinfo=tz)

is_binary = fmt_out == pq.Format.BINARY
year = val.year
if is_binary and (year >= 9999 or year <= 1):
pytest.skip(f"unsupported year {year} in binary format")

conn.execute("set timezone to '%s'" % tzname)
cur = conn.cursor(binary=fmt_out)
cur.execute("select %s::timestamptz", [str(val) + tzval])
Expand Down Expand Up @@ -667,8 +672,6 @@ class TestInterval:
("1d", "1 day"),
pytest.param("-1d", "-1 day", marks=crdb_skip_negative_interval),
("1s", "1 s"),
pytest.param("-1s", "-1 s", marks=crdb_skip_negative_interval),
pytest.param("-1m", "-0.000001 s", marks=crdb_skip_negative_interval),
("1m", "0.000001 s"),
("max", "999999999 days 23:59:59.999999"),
]
Expand Down
Loading
0