Skip to content

Commit

Permalink
remove dep on pytest-lazy-fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 committed Feb 29, 2024
1 parent 073786d commit 0c7c2cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
36 changes: 20 additions & 16 deletions benchmark/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
from typing import Any, Dict, List

from pytest import fixture, lazy_fixture, mark, param
from pytest import fixture, mark, param

from omegaconf import OmegaConf
from omegaconf._utils import ValueKind, _is_missing_literal, get_value_kind
Expand Down Expand Up @@ -72,16 +72,17 @@ def small_listconfig(small_list: Any) -> Any:


@mark.parametrize(
"data",
"data_fixture",
[
lazy_fixture("small_dict"), # type: ignore
lazy_fixture("large_dict"), # type: ignore
lazy_fixture("small_dict_config"), # type: ignore
lazy_fixture("large_dict_config"), # type: ignore
lazy_fixture("dict_config_with_list_leaf"), # type: ignore
"small_dict",
"large_dict",
"small_dict_config",
"large_dict_config",
"dict_config_with_list_leaf",
],
)
def test_omegaconf_create(data: Any, benchmark: Any) -> None:
def test_omegaconf_create(data_fixture: str, benchmark: Any, request: Any) -> None:
data = request.getfixturevalue(data_fixture)
benchmark(OmegaConf.create, data)


Expand All @@ -97,24 +98,27 @@ def test_omegaconf_merge(merge_function: Any, merge_data: Any, benchmark: Any) -


@mark.parametrize(
"lst",
"lst_fixture",
[
lazy_fixture("small_list"), # type: ignore
lazy_fixture("small_listconfig"), # type: ignore
"small_list",
"small_listconfig",
],
)
def test_list_in(lst: List[Any], benchmark: Any) -> None:
def test_list_in(lst_fixture: str, benchmark: Any, request: Any) -> None:
lst: List[Any] = request.getfixturevalue(lst_fixture)
benchmark(lambda seq, val: val in seq, lst, 10)


@mark.parametrize(
"lst",
"lst_fixture",
[
lazy_fixture("small_list"), # type: ignore
lazy_fixture("small_listconfig"), # type: ignore
"small_list",
"small_listconfig",
],
)
def test_list_iter(lst: List[Any], benchmark: Any) -> None:
def test_list_iter(lst_fixture: str, benchmark: Any, request: Any) -> None:
lst: List[Any] = request.getfixturevalue(lst_fixture)

def iterate(seq: Any) -> None:
for _ in seq:
pass
Expand Down
1 change: 0 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pre-commit
pyflakes
pytest
pytest-benchmark
pytest-lazy-fixture
pytest-mock
towncrier
types-setuptools # makes mypy happy
Expand Down

0 comments on commit 0c7c2cf

Please sign in to comment.