Skip to content

Commit db5f09c

Browse files
committed
test: materialize parametrize argvalues to silence a pytest deprecation
The language server part tests passed their parametrization helpers straight into @pytest.mark.parametrize as generators. Newer pytest warns about this (PytestRemovedIn10Warning: "Passing a non-Collection iterable to parametrize is deprecated"), because it needs to iterate the values more than once. Wrap the generate_tests_from_source_document call sites in list(), and let the local prepend_protocol_data helper return a list instead of yielding.
1 parent 7baa0ac commit db5f09c

9 files changed

Lines changed: 16 additions & 16 deletions

tests/robotcode/language_server/robotframework/parts/test_code_action_show_documentation.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828

2929
@pytest.mark.parametrize(
3030
("test_document", "data"),
31-
generate_tests_from_source_document(
32-
Path(
33-
Path(__file__).parent,
34-
"data/tests/code_action_show_documentation.robot",
31+
list(
32+
generate_tests_from_source_document(
33+
Path(
34+
Path(__file__).parent,
35+
"data/tests/code_action_show_documentation.robot",
36+
)
3537
)
3638
),
3739
indirect=["test_document"],

tests/robotcode/language_server/robotframework/parts/test_document_highlight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@pytest.mark.parametrize(
2121
("test_document", "data"),
22-
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/document_highlight.robot")),
22+
list(generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/document_highlight.robot"))),
2323
indirect=["test_document"],
2424
ids=generate_test_id,
2525
scope="module",

tests/robotcode/language_server/robotframework/parts/test_document_symbols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def split(
4747

4848
@pytest.mark.parametrize(
4949
("test_document", "data"),
50-
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/symbols.robot")),
50+
list(generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/symbols.robot"))),
5151
indirect=["test_document"],
5252
ids=generate_test_id,
5353
scope="module",

tests/robotcode/language_server/robotframework/parts/test_foldingrange.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import Any, Iterable, Iterator, Tuple, Union
2+
from typing import Any, Iterable, List, Tuple, Union
33

44
import pytest
55
import yaml
@@ -25,10 +25,8 @@
2525
def prepend_protocol_data(
2626
protocol: Iterable[Any],
2727
data: Iterable[Union[Tuple[Any, Path, GeneratedTestData], Any]],
28-
) -> Iterator[Union[Tuple[Any, Path, GeneratedTestData], Any]]:
29-
for p in protocol:
30-
for d in data:
31-
yield (p, *d)
28+
) -> List[Union[Tuple[Any, Path, GeneratedTestData], Any]]:
29+
return [(p, *d) for p in protocol for d in data]
3230

3331

3432
def generate_foldingrange_test_id(params: Any) -> Any:

tests/robotcode/language_server/robotframework/parts/test_goto_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
@pytest.mark.parametrize(
2222
("test_document", "data"),
23-
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/goto.robot")),
23+
list(generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/goto.robot"))),
2424
indirect=["test_document"],
2525
ids=generate_test_id,
2626
scope="module",

tests/robotcode/language_server/robotframework/parts/test_goto_implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def split(
4444

4545
@pytest.mark.parametrize(
4646
("test_document", "data"),
47-
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/goto.robot")),
47+
list(generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/goto.robot"))),
4848
indirect=["test_document"],
4949
ids=generate_test_id,
5050
scope="module",

tests/robotcode/language_server/robotframework/parts/test_hover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def split(hover: Optional[Hover]) -> Optional[Hover]:
4141

4242
@pytest.mark.parametrize(
4343
("test_document", "data"),
44-
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/hover.robot")),
44+
list(generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/hover.robot"))),
4545
indirect=["test_document"],
4646
ids=generate_test_id,
4747
scope="module",

tests/robotcode/language_server/robotframework/parts/test_references.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@pytest.mark.parametrize(
2121
("test_document", "data"),
22-
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/references.robot")),
22+
list(generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/references.robot"))),
2323
indirect=["test_document"],
2424
ids=generate_test_id,
2525
scope="module",

tests/robotcode/language_server/robotframework/parts/test_signature_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
@pytest.mark.parametrize(
2626
("test_document", "data"),
27-
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/signature_help.robot")),
27+
list(generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/signature_help.robot"))),
2828
indirect=["test_document"],
2929
ids=generate_test_id,
3030
scope="module",

0 commit comments

Comments
 (0)