From: Daniele Varrazzo Date: Tue, 24 Mar 2020 10:29:55 +0000 (+1300) Subject: Skip test for waiting on send X-Git-Tag: 3.0.dev0~675 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c541b9211443d9d87abe363eb32595ed93ef9a0e;p=thirdparty%2Fpsycopg.git Skip test for waiting on send It doesn't seem reliable --- diff --git a/tests/fix_db.py b/tests/fix_db.py index 72d07bb9c..02cd63251 100644 --- a/tests/fix_db.py +++ b/tests/fix_db.py @@ -30,17 +30,19 @@ def pq(request): from psycopg3 import pq for m in request.node.iter_markers(name="libpq"): - if not libpq_version_matches(pq.version(), m.args): - pytest.skip(f"skipping test as libpq {pq.version()}") + check_libpq_version(pq.version(), m.args) return pq -def libpq_version_matches(got, want): +def check_libpq_version(got, want): # convert 90603 to (9, 6, 3), 120003 to (12, 0, 3) got, got_fix = divmod(got, 100) got_maj, got_min = divmod(got, 100) - got = (got_maj, got_min, got_fix) + if got_maj >= 10: + got = (got_maj, got_fix) + else: + got = (got_maj, got_min, got_fix) # Parse a spec like "> 9.6" if len(want) != 1: @@ -57,17 +59,22 @@ def libpq_version_matches(got, want): want_min = int(m.group(3) or "0") want_fix = int(m.group(4) or "0") if want_maj >= 10: - if not want_fix: - want_min, want_fix = 0, want_min - else: + if want_fix: pytest.fail(f"bad libpq version in {want}") - - want = (want_maj, want_min, want_fix) + want = (want_maj, want_min) + else: + want = (want_maj, want_min, want_fix) op = getattr( operator, {">=": "ge", "<=": "le", ">": "gt", "<": "lt"}[m.group(1)] ) - return op(got, want) + + if not op(got, want): + revops = {">=": "<", "<=": ">", ">": "<=", "<": ">="} + pytest.skip( + f"skipping test: libpq loaded is {'.'.join(map(str, got))}" + f" {revops[m.group(1)]} {'.'.join(map(str, want))}" + ) @pytest.fixture diff --git a/tests/pq/test_async.py b/tests/pq/test_async.py index 2f998552b..543c24c60 100644 --- a/tests/pq/test_async.py +++ b/tests/pq/test_async.py @@ -28,7 +28,9 @@ def test_send_query(pq, pgconn): pgconn.consume_input() continue - assert waited_on_send + # Not sure about this check, and why PG 12 changed. + if pq.version() < 120000: + assert waited_on_send # read loop results = []