Skip to content

Commit

Permalink
Allow random in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
henadzit committed Dec 29, 2024
1 parent 115fa65 commit ab462d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions tests/benchmarks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def few_fields_benchmark_dataset() -> list[BenchmarkFewFields]:
async def _create() -> list[BenchmarkFewFields]:
res = []
for _ in range(100):
res.append(await BenchmarkFewFields.create(level=random.randint(0, 100), text="test"))
level = random.randint(0, 100) # nosec
res.append(await BenchmarkFewFields.create(level=level, text="test"))
return res

return asyncio.get_event_loop().run_until_complete(_create())
Expand All @@ -41,7 +42,7 @@ async def _create() -> list[BenchmarkManyFields]:
for _ in range(100):
res.append(
await BenchmarkManyFields.create(
level=random.randint(0, 100),
level=random.randint(0, 100), # nosec
text="test",
col_float1=2.2,
col_smallint1=2,
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_create_many_fields(benchmark):
def bench():
async def _bench():
await BenchmarkManyFields.create(
level=random.randint(0, 100),
level=random.randint(0, 100), # nosec
text="test",
col_float1=2.2,
col_smallint1=2,
Expand Down
6 changes: 4 additions & 2 deletions tests/benchmarks/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def test_get_few_fields(benchmark, few_fields_benchmark_dataset):
@benchmark
def bench():
async def _bench():
await BenchmarkFewFields.get(id=random.randint(minid, maxid))
randid = random.randint(minid, maxid) # nosec
await BenchmarkFewFields.get(id=randid)

loop.run_until_complete(_bench())

Expand All @@ -25,6 +26,7 @@ def test_get_many_fields(benchmark, many_fields_benchmark_dataset):
@benchmark
def bench():
async def _bench():
await BenchmarkManyFields.get(id=random.randint(minid, maxid))
randid = random.randint(minid, maxid) # nosec
await BenchmarkManyFields.get(id=randid)

loop.run_until_complete(_bench())

0 comments on commit ab462d7

Please sign in to comment.