diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index 231d016ec4e..1abc43c233e 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @typespec/http-client-python +## 0.6.8 + +### Bug Fixes + +- Fix for scenario that output folder is different with namespace + ## 0.6.7 ### Bug Fixes diff --git a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py index 3cf6e1a7c30..99fa85c430c 100644 --- a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py +++ b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py @@ -479,7 +479,12 @@ def exec_path_compensation(self) -> Path: else Path(".") ) + def exec_path_for_test_sample(self, namespace: str) -> Path: + return self.exec_path_compensation / Path(*namespace.split(".")) + def exec_path(self, namespace: str) -> Path: + if self.code_model.options["no_namespace_folders"] and not self.code_model.options["multiapi"]: + return Path(".") return self.exec_path_compensation / Path(*namespace.split(".")) @property @@ -492,7 +497,7 @@ def _additional_folder(self) -> Path: return Path("") def _serialize_and_write_sample(self, env: Environment, namespace: str): - out_path = self.exec_path(namespace) / Path("generated_samples") + out_path = self.exec_path_for_test_sample(namespace) / Path("generated_samples") for client in self.code_model.clients: for op_group in client.operation_groups: for operation in op_group.operations: @@ -526,7 +531,7 @@ def _serialize_and_write_sample(self, env: Environment, namespace: str): def _serialize_and_write_test(self, env: Environment, namespace: str): self.code_model.for_test = True - out_path = self.exec_path(namespace) / Path("generated_tests") + out_path = self.exec_path_for_test_sample(namespace) / Path("generated_tests") general_serializer = TestGeneralSerializer(code_model=self.code_model, env=env) self.write_file(out_path / "conftest.py", general_serializer.serialize_conftest()) if not self.code_model.options["azure_arm"]: