Skip to content

Commit d2d69a9

Browse files
committed
optimize tests
1 parent a89f077 commit d2d69a9

File tree

8 files changed

+25
-4
lines changed

8 files changed

+25
-4
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@
5353
"justMyCode": false,
5454
"cwd": "${workspaceFolder}",
5555
},
56+
{
57+
"name": "Python: Pytest Some Test",
58+
"type": "python",
59+
"request": "launch",
60+
"module": "pytest",
61+
"args": [
62+
//"tests/robotcode/language_server/robotframework/parts/test_foldingrange.py"
63+
//"tests/robotcode/language_server/robotframework/parts/test_references.py"
64+
"tests/robotcode/language_server/robotframework/parts/test_goto.py"
65+
],
66+
"console": "integratedTerminal",
67+
"justMyCode": false,
68+
"cwd": "${workspaceFolder}",
69+
},
5670
{
5771
"name": "Python: Pytest All Test Parallel",
5872
"type": "python",

tests/robotcode/language_server/robotframework/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import pytest
55

66

7-
@pytest.fixture(scope="module")
7+
@pytest.fixture(scope="session")
88
def event_loop() -> Generator[asyncio.AbstractEventLoop, None, None]:
9+
import asyncio.runners
10+
911
loop = asyncio.new_event_loop()
10-
loop.set_debug(True)
12+
# loop.set_debug(True)
1113
try:
1214
yield loop
1315
finally:

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
from tests.robotcode.language_server.robotframework.tools import generate_test_id
3030

3131

32-
@pytest_asyncio.fixture(scope="module", ids=generate_test_id)
33-
@pytest.mark.usefixtures("event_loop")
32+
@pytest_asyncio.fixture(scope="package", ids=generate_test_id)
3433
async def protocol(request: Any) -> AsyncGenerator[RobotLanguageServerProtocol, None]:
3534
root_path = Path(Path(__file__).resolve().parent, "data")
3635

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/document_highlight.robot")),
2222
indirect=["test_document"],
2323
ids=generate_test_id,
24+
scope="package",
2425
)
2526
@pytest.mark.usefixtures("protocol")
2627
@pytest.mark.asyncio

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def generate_foldingrange_test_id(params: Any) -> Any:
5959
),
6060
indirect=["protocol", "test_document"],
6161
ids=generate_foldingrange_test_id,
62+
scope="module",
6263
)
6364
@pytest.mark.asyncio
6465
async def test(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def split(
4646
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/goto.robot")),
4747
indirect=["test_document"],
4848
ids=generate_test_id,
49+
scope="module",
4950
)
5051
@pytest.mark.usefixtures("protocol")
5152
@pytest.mark.asyncio
@@ -70,6 +71,7 @@ async def test_definition(
7071
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/goto.robot")),
7172
indirect=["test_document"],
7273
ids=generate_test_id,
74+
scope="module",
7375
)
7476
@pytest.mark.usefixtures("protocol")
7577
@pytest.mark.asyncio

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/hover.robot")),
2323
indirect=["test_document"],
2424
ids=generate_test_id,
25+
scope="module",
2526
)
2627
@pytest.mark.usefixtures("protocol")
2728
@pytest.mark.asyncio

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
generate_tests_from_source_document(Path(Path(__file__).parent, "data/tests/references.robot")),
2626
indirect=["test_document"],
2727
ids=generate_test_id,
28+
scope="module",
2829
)
2930
@pytest.mark.usefixtures("protocol")
3031
@pytest.mark.asyncio

0 commit comments

Comments
 (0)