Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-python"
---

Use specific exception types in status code range mock_api tests for sync and async
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ class NamespaceType(str, Enum):

LOCALS_LENGTH_LIMIT = 25

REQUEST_BUILDER_BODY_VARIABLES_LENGTH = (
6 # how many body variables are present in a request builder
)
REQUEST_BUILDER_BODY_VARIABLES_LENGTH = 6 # how many body variables are present in a request builder

OPERATION_BODY_VARIABLES_LENGTH = (
14 # how many body variables are present in an operation
)
OPERATION_BODY_VARIABLES_LENGTH = 14 # how many body variables are present in an operation
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ async def client():


@pytest.mark.asyncio
async def test_error_response_status_code_in_range(client: StatusCodeRangeClient):
with pytest.raises(Exception) as exc_info:
async def test_error_response_status_code_in_range(client: StatusCodeRangeClient, core_library):
with pytest.raises(core_library.exceptions.HttpResponseError) as exc_info:
await client.error_response_status_code_in_range()

error = exc_info.value.model
Expand All @@ -28,8 +28,8 @@ async def test_error_response_status_code_in_range(client: StatusCodeRangeClient


@pytest.mark.asyncio
async def test_error_response_status_code_404(client: StatusCodeRangeClient):
with pytest.raises(Exception) as exc_info:
async def test_error_response_status_code_404(client: StatusCodeRangeClient, core_library):
with pytest.raises(core_library.exceptions.ResourceNotFoundError) as exc_info:
await client.error_response_status_code404()

error = exc_info.value.model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def client():
yield client


def test_error_response_status_code_in_range(client: StatusCodeRangeClient):
with pytest.raises(Exception) as exc_info:
def test_error_response_status_code_in_range(client: StatusCodeRangeClient, core_library):
with pytest.raises(core_library.exceptions.HttpResponseError) as exc_info:
client.error_response_status_code_in_range()

error = exc_info.value.model
Expand All @@ -25,8 +25,8 @@ def test_error_response_status_code_in_range(client: StatusCodeRangeClient):
assert exc_info.value.response.status_code == 494


def test_error_response_status_code_404(client: StatusCodeRangeClient):
with pytest.raises(Exception) as exc_info:
def test_error_response_status_code_404(client: StatusCodeRangeClient, core_library):
with pytest.raises(core_library.exceptions.ResourceNotFoundError) as exc_info:
client.error_response_status_code404()

error = exc_info.value.model
Expand Down
Loading