]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Disable creation of empty ranges in random tests
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 2 Oct 2021 17:47:43 +0000 (19:47 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 4 Oct 2021 12:44:13 +0000 (14:44 +0200)
If one end up as the first item in a list the array dumping the array
will fail. There are xfail tests in test_range for it.

tests/fix_faker.py

index c26eda4e5afabf7acd2aa3b6033d9630a9c10576..149ef68c218f5f9111b70898eec995caddbd647b 100644 (file)
@@ -528,7 +528,13 @@ class Faker:
         return (cls, choice(subtypes))
 
     def make_Range(self, spec, empty_chance=0.02, no_bound_chance=0.05):
-        if random() < empty_chance and spec[0] is Range:
+        # TODO: drop format check after fixing binary dumping of empty ranges
+        # (an array starting with an empty range will get the wrong type currently)
+        if (
+            random() < empty_chance
+            and spec[0] is Range
+            and self.format == PyFormat.TEXT
+        ):
             return spec[0](empty=True)
 
         while True: