tests: try multiple times to get a database name (#42634)
This commit is contained in:
parent
84c72bd320
commit
7e07d08a67
|
@ -47,8 +47,17 @@ def cursor():
|
|||
|
||||
@pytest.fixture
|
||||
def database(cursor):
|
||||
dbname = 'wcstests%d' % random.randint(0, 100000)
|
||||
cursor.execute('CREATE DATABASE %s' % dbname)
|
||||
i = 0
|
||||
while True:
|
||||
dbname = 'wcstests%d' % random.randint(0, 100000)
|
||||
try:
|
||||
cursor.execute('CREATE DATABASE %s' % dbname)
|
||||
break
|
||||
except psycopg2.Error:
|
||||
if i < 5:
|
||||
i += 1
|
||||
continue
|
||||
raise
|
||||
yield dbname
|
||||
cleanup_connection()
|
||||
cursor.execute('DROP DATABASE %s' % dbname)
|
||||
|
|
Loading…
Reference in New Issue