From: Daniele Varrazzo Date: Sat, 2 Oct 2021 17:47:43 +0000 (+0200) Subject: Disable creation of empty ranges in random tests X-Git-Tag: 3.0~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a22743ea12b2604ce3f5541589037cd48a5faa6;p=thirdparty%2Fpsycopg.git Disable creation of empty ranges in random tests 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. --- diff --git a/tests/fix_faker.py b/tests/fix_faker.py index c26eda4e5..149ef68c2 100644 --- a/tests/fix_faker.py +++ b/tests/fix_faker.py @@ -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: