[Test] speed up Hypothesis strategies to avoid too_slow (#25623)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
36ab9974d2
commit
188eb838c5
1 changed files with 7 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ from typing import Any
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from hypothesis import given
|
from hypothesis import given, settings
|
||||||
from hypothesis import strategies as st
|
from hypothesis import strategies as st
|
||||||
|
|
||||||
from core.file import File, FileTransferMethod, FileType
|
from core.file import File, FileTransferMethod, FileType
|
||||||
|
|
@ -486,13 +486,14 @@ def _generate_file(draw) -> File:
|
||||||
def _scalar_value() -> st.SearchStrategy[int | float | str | File | None]:
|
def _scalar_value() -> st.SearchStrategy[int | float | str | File | None]:
|
||||||
return st.one_of(
|
return st.one_of(
|
||||||
st.none(),
|
st.none(),
|
||||||
st.integers(),
|
st.integers(min_value=-(10**6), max_value=10**6),
|
||||||
st.floats(),
|
st.floats(allow_nan=True, allow_infinity=False),
|
||||||
st.text(),
|
st.text(max_size=50),
|
||||||
_generate_file(),
|
_generate_file(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@settings(max_examples=50)
|
||||||
@given(_scalar_value())
|
@given(_scalar_value())
|
||||||
def test_build_segment_and_extract_values_for_scalar_types(value):
|
def test_build_segment_and_extract_values_for_scalar_types(value):
|
||||||
seg = variable_factory.build_segment(value)
|
seg = variable_factory.build_segment(value)
|
||||||
|
|
@ -503,7 +504,8 @@ def test_build_segment_and_extract_values_for_scalar_types(value):
|
||||||
assert seg.value == value
|
assert seg.value == value
|
||||||
|
|
||||||
|
|
||||||
@given(st.lists(_scalar_value()))
|
@settings(max_examples=50)
|
||||||
|
@given(values=st.lists(_scalar_value(), max_size=20))
|
||||||
def test_build_segment_and_extract_values_for_array_types(values):
|
def test_build_segment_and_extract_values_for_array_types(values):
|
||||||
seg = variable_factory.build_segment(values)
|
seg = variable_factory.build_segment(values)
|
||||||
assert seg.value == values
|
assert seg.value == values
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue