]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Added randomisation of tests run
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 10 Jan 2021 04:15:27 +0000 (05:15 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 12 Jan 2021 15:16:34 +0000 (16:16 +0100)
Fixed a test dealing with an unpredictable libpq behaviour

psycopg3/setup.py
tests/pq/test_escaping.py

index 6e7da1b7c2c7874841276b807ae6fb81542e8d06..2befb50bdb04da627b2ace5536350d2439975839 100644 (file)
@@ -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",
index b55c5132e0fb0856f97c3d28893ab15bd8faa8b7..d6ba9de0b74df2ad44e765dfe926718acf2e9588 100644 (file)
@@ -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):