diff options
author | robot-ydb-importer <robot-ydb-importer@yandex-team.com> | 2024-06-28 14:57:17 +0300 |
---|---|---|
committer | robot-ydb-importer <robot-ydb-importer@yandex-team.com> | 2024-06-28 15:10:57 +0300 |
commit | a75ea2cde045917041437c8859477ba4323503bd (patch) | |
tree | 565ad17417cc162775e29f4b27987e2c322ddc29 /contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py | |
parent | d0dc9572233e6c5a1040c5eb91227066c876b832 (diff) | |
download | ydb-a75ea2cde045917041437c8859477ba4323503bd.tar.gz |
YDB Import 604
a63e035353af5512e5e1c2789d17f495871e0007
Diffstat (limited to 'contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py')
-rw-r--r-- | contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py new file mode 100644 index 0000000000..3c675c2aaf --- /dev/null +++ b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py @@ -0,0 +1,21 @@ +import pytest + +from .lazy_fixture import LazyFixtureWrapper +from .lazy_fixture_callable import LazyFixtureCallableWrapper + + +def load_lazy_fixtures(value, request: pytest.FixtureRequest): + if isinstance(value, LazyFixtureCallableWrapper): + return value.get_func(request)( + *load_lazy_fixtures(value.args, request), + **load_lazy_fixtures(value.kwargs, request), + ) + if isinstance(value, LazyFixtureWrapper): + return value.load_fixture(request) + # we need to check exact type + if type(value) is dict: # noqa: E721 + return {key: load_lazy_fixtures(value, request) for key, value in value.items()} + # we need to check exact type + elif type(value) in {list, tuple, set}: + return type(value)([load_lazy_fixtures(value, request) for value in value]) + return value |