Open
Description
The test test_main_generates_correct_package
in tests/main/test_main.py
requires manual adding of clients to be tested. This seems to have been forgotten when ClientForwardRefs
was added.
I tried to just blindly add it to the fixture but this actually seems to uncover a bug where relative paths aren't resolved properly. With the following diff:
diff --git a/tests/main/test_main.py b/tests/main/test_main.py
index 3cf9f1d..84da31d 100644
--- a/tests/main/test_main.py
+++ b/tests/main/test_main.py
@@ -213,6 +213,30 @@ def test_main_shows_version():
"example_client",
CLIENTS_PATH / "custom_sync_query_builder" / "expected_client",
),
+ (
+ (
+ CLIENTS_PATH / "client_forward_refs" / "pyproject.toml",
+ (
+ CLIENTS_PATH / "client_forward_refs" / "queries.graphql",
+ CLIENTS_PATH / "client_forward_refs" / "schema.graphql",
+ CLIENTS_PATH / "client_forward_refs" / "custom_scalars.py",
+ ),
+ ),
+ "client_forward_refs",
+ CLIENTS_PATH / "client_forward_refs" / "expected_client",
+ ),
+ (
+ (
+ CLIENTS_PATH / "client_forward_refs_shorter_results" / "pyproject.toml",
+ (
+ CLIENTS_PATH / "client_forward_refs_shorter_results" / "queries.graphql",
+ CLIENTS_PATH / "client_forward_refs_shorter_results" / "schema.graphql",
+ CLIENTS_PATH / "client_forward_refs_shorter_results" / "custom_scalars.py",
+ ),
+ ),
+ "client_forward_refs_shorter_results",
+ CLIENTS_PATH / "client_forward_refs_shorter_results" / "expected_client",
+ ),
],
indirect=["project_dir"],
)
The result is as follows:
› pytest ./tests/main -k test_main_generates_correct_package -vv
[...]
test_main.py::test_main_generates_correct_package[project_dir14-client_forward_refs-expected_package_path14] FAILED [ 93%]
test_main.py::test_main_generates_correct_package[project_dir15-client_forward_refs_shorter_results-expected_package_path15] FAILED [100%]
[...]
E AssertionError: client.py
E assert 'from typing ...ap_fragment\n' == 'from typing ...ap_fragment\n'
E
E - from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Optional, Union
E ? ---------------
E + from typing import Any, AsyncIterator, Dict, List, Optional, Union
E
E from .async_base_client import AsyncBaseClient
E + from .typing import TYPE_CHECKING...
E
E ...Full output truncated (351 lines hidden), use '-vv' to show
[...]
async def list_strings_1(self, **kwargs: Any) -> Optional[List[Optional[str]]]:
- from .list_strings_1 import ListStrings1
+ from ..list_strings_1 import ListStrings1
? +
[...]
/home/xxx/ariadne-codegen/tests/main/test_main.py:49: AssertionError
Metadata
Metadata
Assignees
Labels
No labels