Просмотр исходного кода

[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>
tags/1.9.0
Yongtao Huang 1 месяц назад
Родитель
Сommit
188eb838c5
Аккаунт пользователя с таким Email не найден
1 измененных файлов: 7 добавлений и 5 удалений
  1. 7
    5
      api/tests/unit_tests/factories/test_variable_factory.py

+ 7
- 5
api/tests/unit_tests/factories/test_variable_factory.py Просмотреть файл

@@ -4,7 +4,7 @@ from typing import Any
from uuid import uuid4

import pytest
from hypothesis import given
from hypothesis import given, settings
from hypothesis import strategies as st

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]:
return st.one_of(
st.none(),
st.integers(),
st.floats(),
st.text(),
st.integers(min_value=-(10**6), max_value=10**6),
st.floats(allow_nan=True, allow_infinity=False),
st.text(max_size=50),
_generate_file(),
)


@settings(max_examples=50)
@given(_scalar_value())
def test_build_segment_and_extract_values_for_scalar_types(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


@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):
seg = variable_factory.build_segment(values)
assert seg.value == values

Загрузка…
Отмена
Сохранить