From: Mike Bayer Date: Thu, 27 Apr 2023 13:49:07 +0000 (-0400) Subject: use a lot more random names X-Git-Tag: rel_2_0_12~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1329037bfed428e458547824a861ce1aa9df0c78;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git use a lot more random names very small number of tiny names generated by random_names() could cause _ordered_name_fixture() to run out of names. Fixes: #9706 Change-Id: I3df00c9cf99e76fe82eb535c7fe589b73b10cd67 --- diff --git a/test/orm/test_inspect.py b/test/orm/test_inspect.py index 6ae0d1d3ff..ab2e5ae3ad 100644 --- a/test/orm/test_inspect.py +++ b/test/orm/test_inspect.py @@ -440,14 +440,16 @@ class TestORMInspection(_fixtures.FixtureTest): import random import keyword - names = { - "".join( - random.choice("abcdegfghijklmnopqrstuvwxyz") - for i in range(random.randint(3, 15)) - ) - for j in range(random.randint(4, 12)) - } - return list(names.difference(keyword.kwlist)) + def _random_name(): + while True: + name = "".join( + random.choice("abcdegfghijklmnopqrstuvwxyz") + for i in range(random.randint(5, 15)) + ) + if name not in keyword.kwlist: + return name + + return [_random_name() for i in range(random.randint(8, 15))] def _ordered_name_fixture(self, glbls, clsname, base, supercls):