mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 00:45:37 +01:00
antithesis-tests: Fix generate_random_value() on older Python versions
This commit is contained in:
@@ -4,17 +4,16 @@ from antithesis.random import get_random, random_choice
|
||||
def generate_random_identifier(type: str, num: int):
|
||||
return ''.join(type, '_', get_random() % num)
|
||||
|
||||
def generate_random_value(type: str):
|
||||
match type:
|
||||
case 'INTEGER':
|
||||
return str(get_random() % 100)
|
||||
case 'REAL':
|
||||
return '{:.2f}'.format(get_random() % 100 / 100.0)
|
||||
case 'TEXT':
|
||||
return f"'{''.join(random_choice(string.ascii_lowercase) for _ in range(5))}'"
|
||||
case 'BLOB':
|
||||
return f"x'{''.join(random_choice(string.ascii_lowercase) for _ in range(5)).encode().hex()}'"
|
||||
case 'NUMERIC':
|
||||
return str(get_random() % 100)
|
||||
case _:
|
||||
return NULL
|
||||
def generate_random_value(type_str):
|
||||
if type_str == 'INTEGER':
|
||||
return str(get_random() % 100)
|
||||
elif type_str == 'REAL':
|
||||
return '{:.2f}'.format(get_random() % 100 / 100.0)
|
||||
elif type_str == 'TEXT':
|
||||
return f"'{''.join(random_choice(string.ascii_lowercase) for _ in range(5))}'"
|
||||
elif type_str == 'BLOB':
|
||||
return f"x'{''.join(random_choice(string.ascii_lowercase) for _ in range(5)).encode().hex()}'"
|
||||
elif type_str == 'NUMERIC':
|
||||
return str(get_random() % 100)
|
||||
else:
|
||||
return NULL
|
||||
|
||||
Reference in New Issue
Block a user