From: Daniele Varrazzo Date: Sun, 10 Jan 2021 04:15:27 +0000 (+0100) Subject: Added randomisation of tests run X-Git-Tag: 3.0.dev0~178 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c42b77d7898e86c1b465e770fa08b808f6435c5;p=thirdparty%2Fpsycopg.git Added randomisation of tests run Fixed a test dealing with an unpredictable libpq behaviour --- diff --git a/psycopg3/setup.py b/psycopg3/setup.py index 6e7da1b7c..2befb50bd 100644 --- a/psycopg3/setup.py +++ b/psycopg3/setup.py @@ -34,6 +34,7 @@ extras_require = { "test": [ "pytest >= 6, < 6.1", "pytest-asyncio >= 0.14.0, < 0.15", + "pytest-randomly >= 3.5, < 3.6", ], "dev": [ "black", diff --git a/tests/pq/test_escaping.py b/tests/pq/test_escaping.py index b55c5132e..d6ba9de0b 100644 --- a/tests/pq/test_escaping.py +++ b/tests/pq/test_escaping.py @@ -122,13 +122,17 @@ def test_escape_string_1char(pgconn, scs): (b"", b""), (b"hello", b"hello"), (b"foo'bar", b"foo''bar"), - (b"foo\\bar", b"foo\\\\bar"), + # This libpq function behaves unpredictably when not passed a conn + (b"foo\\bar", (b"foo\\\\bar", b"foo\\bar")), ], ) def test_escape_string_noconn(data, want): esc = pq.Escaping() out = esc.escape_string(data) - assert out == want + if isinstance(want, bytes): + assert out == want + else: + assert out in want def test_escape_string_badconn(pgconn):