refactor: update flaky tests in test_schema.py (#3933)

* Fix flaky tests in `test_schema.py` by using sets for type comparisons

- Updated `post_process_type` function assertions to use sets for more reliable type comparisons.
- Adjusted imports for better code organization.

* Fix import order in test_database.py

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-09-27 13:45:26 -03:00 • committed by GitHub
commit 706f9a0277
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View file

@ -1,5 +1,5 @@
from typing import Union
from collections.abc import Sequence
from typing import Union
import pytest
from pydantic import ValidationError
@ -40,11 +40,11 @@ class TestInput:
assert input_obj.field_type == "int"
def test_post_process_type_function(self):
assert post_process_type(int) == [int]
assert post_process_type(list[int]) == [int]
assert post_process_type(Union[int, str]) == [int, str]
assert post_process_type(Union[int, Sequence[str]]) == [int, str]
assert post_process_type(Union[int, Sequence[int]]) == [int]
assert set(post_process_type(int)) == {int}
assert set(post_process_type(list[int])) == {int}
assert set(post_process_type(Union[int, str])) == {int, str}
assert set(post_process_type(Union[int, Sequence[str]])) == {int, str}
assert set(post_process_type(Union[int, Sequence[int]])) == {int}
def test_input_to_dict(self):
input_obj = Input(field_type="str")
@ -110,7 +110,7 @@ class TestPostProcessType:
assert post_process_type(list[int]) == [int]
def test_union_type(self):
assert post_process_type(Union[int, str]) == [int, str]
assert set(post_process_type(Union[int, str])) == {int, str}
def test_custom_type(self):
class CustomType: