From b351dfdbc02632b2ec41fedabd9ac296e5d22df1 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 10:34:11 -0700 Subject: [PATCH 1/9] fix AttributeException --- sdk/core/azure-core/CHANGELOG.md | 3 +++ sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py | 4 ++-- sdk/core/azure-core/azure/core/pipeline/transport/_base.py | 2 +- .../azure/core/pipeline/transport/_requests_basic.py | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 508e9f35bad1..dbd114975faa 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -3,6 +3,9 @@ ## 1.5.1 (Unreleased) +### Bug fixes + +- Fix AttributeException in StreamDownloadGenerator #11462 ## 1.5.0 (2020-05-04) diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py b/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py index 0f064e618f23..165bfc1ed99e 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py @@ -234,8 +234,8 @@ async def __anext__(self): else: await asyncio.sleep(retry_interval) headers = {'range': 'bytes=' + str(self.downloaded) + '-'} - resp = self.pipeline.run(self.request, stream=True, headers=headers) - if resp.status_code == 416: + resp = await self.pipeline.run(self.request, stream=True, headers=headers) + if resp.http_response.status_code == 416: raise chunk = await self.response.internal_response.content.read(self.block_size) if not chunk: diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_base.py b/sdk/core/azure-core/azure/core/pipeline/transport/_base.py index 33d924a4004d..ea5cb1e9e11f 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_base.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_base.py @@ -175,7 +175,7 @@ class HttpTransport( @abc.abstractmethod def send(self, request, **kwargs): - # type: (PipelineRequest, Any) -> PipelineResponse + # type: (PipelineRequest, Any) -> HttpResponse """Send the request using this HTTP sender. :param request: The pipeline request object diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py b/sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py index 537f902ece3b..ea0e7b0e4c9c 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py @@ -137,7 +137,7 @@ def __next__(self): time.sleep(retry_interval) headers = {'range': 'bytes=' + str(self.downloaded) + '-'} resp = self.pipeline.run(self.request, stream=True, headers=headers) - if resp.status_code == 416: + if resp.http_response.status_code == 416: raise chunk = next(self.iter_content_func) if not chunk: From 6e472816cdb5239d689601270a6ecf5303e90e8d Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 10:42:07 -0700 Subject: [PATCH 2/9] update type doc string --- sdk/core/azure-core/azure/core/pipeline/_base.py | 4 ++-- sdk/core/azure-core/azure/core/pipeline/_base_async.py | 2 +- sdk/core/azure-core/azure/core/pipeline/transport/_base.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/core/azure-core/azure/core/pipeline/_base.py b/sdk/core/azure-core/azure/core/pipeline/_base.py index 5d5ca0404390..1ad48850f869 100644 --- a/sdk/core/azure-core/azure/core/pipeline/_base.py +++ b/sdk/core/azure-core/azure/core/pipeline/_base.py @@ -187,13 +187,13 @@ def _prepare_multipart(self, request): request.prepare_multipart_body() # type: ignore def run(self, request, **kwargs): - # type: (HTTPRequestType, Any) -> PipelineResponse + # type: (HTTPRequestType, Any) -> HTTPResponseType """Runs the HTTP Request through the chained policies. :param request: The HTTP request object. :type request: ~azure.core.pipeline.transport.HttpRequest :return: The PipelineResponse object - :rtype: ~azure.core.pipeline.PipelineResponse + :rtype: ~azure.core.pipeline.transport.HttpResponse """ self._prepare_multipart(request) context = PipelineContext(self._transport, **kwargs) diff --git a/sdk/core/azure-core/azure/core/pipeline/_base_async.py b/sdk/core/azure-core/azure/core/pipeline/_base_async.py index 95694a2f90f4..408cd41d7208 100644 --- a/sdk/core/azure-core/azure/core/pipeline/_base_async.py +++ b/sdk/core/azure-core/azure/core/pipeline/_base_async.py @@ -199,7 +199,7 @@ async def run(self, request: HTTPRequestType, **kwargs: Any): :param request: The HTTP request object. :type request: ~azure.core.pipeline.transport.HttpRequest :return: The PipelineResponse object. - :rtype: ~azure.core.pipeline.PipelineResponse + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse """ await self._prepare_multipart(request) context = PipelineContext(self._transport, **kwargs) diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_base.py b/sdk/core/azure-core/azure/core/pipeline/transport/_base.py index ea5cb1e9e11f..6959320d094b 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_base.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_base.py @@ -175,13 +175,13 @@ class HttpTransport( @abc.abstractmethod def send(self, request, **kwargs): - # type: (PipelineRequest, Any) -> HttpResponse + # type: (PipelineRequest, Any) -> HTTPResponseType """Send the request using this HTTP sender. :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :return: The pipeline response object. - :rtype: ~azure.core.pipeline.PipelineResponse + :rtype: ~azure.core.pipeline.transport.HttpResponse """ @abc.abstractmethod From 903668dfe274fb19f9f61871377a1386cb6f09d8 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 10:44:52 -0700 Subject: [PATCH 3/9] fix type --- sdk/core/azure-core/azure/core/pipeline/_base.py | 4 ++-- sdk/core/azure-core/azure/core/pipeline/_base_async.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/core/azure-core/azure/core/pipeline/_base.py b/sdk/core/azure-core/azure/core/pipeline/_base.py index 1ad48850f869..5d5ca0404390 100644 --- a/sdk/core/azure-core/azure/core/pipeline/_base.py +++ b/sdk/core/azure-core/azure/core/pipeline/_base.py @@ -187,13 +187,13 @@ def _prepare_multipart(self, request): request.prepare_multipart_body() # type: ignore def run(self, request, **kwargs): - # type: (HTTPRequestType, Any) -> HTTPResponseType + # type: (HTTPRequestType, Any) -> PipelineResponse """Runs the HTTP Request through the chained policies. :param request: The HTTP request object. :type request: ~azure.core.pipeline.transport.HttpRequest :return: The PipelineResponse object - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.pipeline.PipelineResponse """ self._prepare_multipart(request) context = PipelineContext(self._transport, **kwargs) diff --git a/sdk/core/azure-core/azure/core/pipeline/_base_async.py b/sdk/core/azure-core/azure/core/pipeline/_base_async.py index 408cd41d7208..95694a2f90f4 100644 --- a/sdk/core/azure-core/azure/core/pipeline/_base_async.py +++ b/sdk/core/azure-core/azure/core/pipeline/_base_async.py @@ -199,7 +199,7 @@ async def run(self, request: HTTPRequestType, **kwargs: Any): :param request: The HTTP request object. :type request: ~azure.core.pipeline.transport.HttpRequest :return: The PipelineResponse object. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.pipeline.PipelineResponse """ await self._prepare_multipart(request) context = PipelineContext(self._transport, **kwargs) From bf0ea874d707a3d88835ba32adef442b59be06e6 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 10:45:14 -0700 Subject: [PATCH 4/9] add tests --- .../test_stream_generator.py | 57 +++++++++++++++++++ .../azure-core/tests/test_stream_generator.py | 51 +++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py create mode 100644 sdk/core/azure-core/tests/test_stream_generator.py diff --git a/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py b/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py new file mode 100644 index 000000000000..cbf5d39a5058 --- /dev/null +++ b/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py @@ -0,0 +1,57 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +from azure.core.pipeline.transport import ( + HttpRequest, + AsyncHttpResponse, + AsyncHttpTransport, +) +from azure.core.pipeline import AsyncPipeline +from azure.core.pipeline.transport._aiohttp import AioHttpStreamDownloadGenerator +from unittest import mock +import pytest + +@pytest.mark.asyncio +async def test_connetion_error_response(): + class MockTransport(AsyncHttpTransport): + def __init__(self): + self._count = 0 + + async def __aexit__(self, exc_type, exc_val, exc_tb): + pass + async def close(self): + pass + async def open(self): + pass + + async def send(self, request, **kwargs): + request = HttpRequest('GET', 'http://127.0.0.1/') + response = AsyncHttpResponse(request, None) + response.status_code = 416 + return response + + class MockContent(): + async def read(self, block_size): + raise ConnectionError + + class MockInternalResponse(): + def __init__(self): + self.headers = {} + self.content = MockContent() + + async def close(self): + pass + + class AsyncMock(mock.MagicMock): + async def __call__(self, *args, **kwargs): + return super(AsyncMock, self).__call__(*args, **kwargs) + + http_request = HttpRequest('GET', 'http://127.0.0.1/') + pipeline = AsyncPipeline(MockTransport()) + http_response = AsyncHttpResponse(http_request, None) + http_response.internal_response = MockInternalResponse() + stream = AioHttpStreamDownloadGenerator(pipeline, http_response) + with mock.patch('asyncio.sleep', new_callable=AsyncMock): + with pytest.raises(ConnectionError): + await stream.__anext__() diff --git a/sdk/core/azure-core/tests/test_stream_generator.py b/sdk/core/azure-core/tests/test_stream_generator.py new file mode 100644 index 000000000000..d91a113d7b4c --- /dev/null +++ b/sdk/core/azure-core/tests/test_stream_generator.py @@ -0,0 +1,51 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +import requests +from azure.core.pipeline.transport import ( + HttpRequest, + HttpResponse, + HttpTransport, +) +from azure.core.pipeline import Pipeline, PipelineResponse +from azure.core.pipeline.transport._requests_basic import StreamDownloadGenerator +try: + from unittest import mock +except ImportError: + import mock + +def test_connetion_error_response(): + class MockTransport(HttpTransport): + def __init__(self): + self._count = 0 + + def __exit__(self, exc_type, exc_val, exc_tb): + pass + def close(self): + pass + def open(self): + pass + + def send(self, request, **kwargs): + request = HttpRequest('GET', 'http://127.0.0.1/') + response = HttpResponse(request, None) + response.status_code = 200 + return response + + def __next__(self): + if self._count == 0: + self._count += 1 + raise requests.exceptions.ConnectionError + + class MockInternalResponse(): + def iter_content(self, block_size): + return MockTransport() + + http_request = HttpRequest('GET', 'http://127.0.0.1/') + pipeline = Pipeline(MockTransport()) + http_response = HttpResponse(http_request, None) + http_response.internal_response = MockInternalResponse() + stream = StreamDownloadGenerator(pipeline, http_response) + with mock.patch('time.sleep', return_value=None): + list(stream) From 1acb0cf3e723e0c0b40a1abffbfdb456c0999487 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 11:28:35 -0700 Subject: [PATCH 5/9] update --- sdk/core/azure-core/azure/core/pipeline/transport/_base.py | 4 ++-- .../azure-core/azure/core/pipeline/transport/_base_async.py | 2 ++ .../tests/azure_core_asynctests/test_stream_generator.py | 2 +- sdk/core/azure-core/tests/test_stream_generator.py | 5 ++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_base.py b/sdk/core/azure-core/azure/core/pipeline/transport/_base.py index 6959320d094b..d8f82b34f4da 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_base.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_base.py @@ -175,11 +175,11 @@ class HttpTransport( @abc.abstractmethod def send(self, request, **kwargs): - # type: (PipelineRequest, Any) -> HTTPResponseType + # type: (HTTPRequestType, Any) -> HTTPResponseType """Send the request using this HTTP sender. :param request: The pipeline request object - :type request: ~azure.core.pipeline.PipelineRequest + :type request: ~azure.core.transport.HTTPRequest :return: The pipeline response object. :rtype: ~azure.core.pipeline.transport.HttpResponse """ diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py b/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py index d79999ed6297..82bdef6c5593 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py @@ -168,6 +168,8 @@ class AsyncHttpTransport( @abc.abstractmethod async def send(self, request, **kwargs): + # type: (HTTPRequestType, Any) -> AsyncHTTPResponseType + """Send the request using this HTTP sender. """ diff --git a/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py b/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py index cbf5d39a5058..a2eefdd8b921 100644 --- a/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py +++ b/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py @@ -13,7 +13,7 @@ import pytest @pytest.mark.asyncio -async def test_connetion_error_response(): +async def test_connection_error_response(): class MockTransport(AsyncHttpTransport): def __init__(self): self._count = 0 diff --git a/sdk/core/azure-core/tests/test_stream_generator.py b/sdk/core/azure-core/tests/test_stream_generator.py index d91a113d7b4c..138019afd2f8 100644 --- a/sdk/core/azure-core/tests/test_stream_generator.py +++ b/sdk/core/azure-core/tests/test_stream_generator.py @@ -15,7 +15,7 @@ except ImportError: import mock -def test_connetion_error_response(): +def test_connection_error_response(): class MockTransport(HttpTransport): def __init__(self): self._count = 0 @@ -42,6 +42,9 @@ class MockInternalResponse(): def iter_content(self, block_size): return MockTransport() + def close(self): + pass + http_request = HttpRequest('GET', 'http://127.0.0.1/') pipeline = Pipeline(MockTransport()) http_response = HttpResponse(http_request, None) From a2e09ab8156b5062b75377be5c336f1a848ae2dc Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 12:05:00 -0700 Subject: [PATCH 6/9] update --- .../azure-core/azure/core/pipeline/transport/_base_async.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py b/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py index 82bdef6c5593..b1d6feeee840 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py @@ -28,7 +28,7 @@ import abc from collections.abc import AsyncIterator -from typing import AsyncIterator as AsyncIteratorType, TypeVar, Generic +from typing import AsyncIterator as AsyncIteratorType, TypeVar, Generic, Any from ._base import ( _HttpResponseBase, _HttpClientTransportResponse, @@ -168,7 +168,7 @@ class AsyncHttpTransport( @abc.abstractmethod async def send(self, request, **kwargs): - # type: (HTTPRequestType, Any) -> AsyncHTTPResponseType + # type: (HTTPRequestType, Any) -> HTTPResponseType """Send the request using this HTTP sender. """ From ecd94f032141e3e56f8d8ffa57d1d8f4df458d23 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 12:14:34 -0700 Subject: [PATCH 7/9] update --- .../azure/core/pipeline/transport/_aiohttp.py | 2 +- .../test_stream_generator.py | 50 +++++++++++++++++++ .../azure-core/tests/test_stream_generator.py | 43 +++++++++++++++- 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py b/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py index 165bfc1ed99e..9b0089401513 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py @@ -239,7 +239,7 @@ async def __anext__(self): raise chunk = await self.response.internal_response.content.read(self.block_size) if not chunk: - raise StopIteration() + raise StopAsyncIteration() self.downloaded += len(chunk) return chunk continue diff --git a/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py b/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py index a2eefdd8b921..f7368159615f 100644 --- a/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py +++ b/sdk/core/azure-core/tests/azure_core_asynctests/test_stream_generator.py @@ -14,6 +14,56 @@ @pytest.mark.asyncio async def test_connection_error_response(): + class MockTransport(AsyncHttpTransport): + def __init__(self): + self._count = 0 + + async def __aexit__(self, exc_type, exc_val, exc_tb): + pass + async def close(self): + pass + async def open(self): + pass + + async def send(self, request, **kwargs): + request = HttpRequest('GET', 'http://127.0.0.1/') + response = AsyncHttpResponse(request, None) + response.status_code = 200 + return response + + class MockContent(): + def __init__(self): + self._first = True + + async def read(self, block_size): + if self._first: + self._first = False + raise ConnectionError + return None + + class MockInternalResponse(): + def __init__(self): + self.headers = {} + self.content = MockContent() + + async def close(self): + pass + + class AsyncMock(mock.MagicMock): + async def __call__(self, *args, **kwargs): + return super(AsyncMock, self).__call__(*args, **kwargs) + + http_request = HttpRequest('GET', 'http://127.0.0.1/') + pipeline = AsyncPipeline(MockTransport()) + http_response = AsyncHttpResponse(http_request, None) + http_response.internal_response = MockInternalResponse() + stream = AioHttpStreamDownloadGenerator(pipeline, http_response) + with mock.patch('asyncio.sleep', new_callable=AsyncMock): + with pytest.raises(StopAsyncIteration): + await stream.__anext__() + +@pytest.mark.asyncio +async def test_connection_error_416(): class MockTransport(AsyncHttpTransport): def __init__(self): self._count = 0 diff --git a/sdk/core/azure-core/tests/test_stream_generator.py b/sdk/core/azure-core/tests/test_stream_generator.py index 138019afd2f8..4e3c9439215d 100644 --- a/sdk/core/azure-core/tests/test_stream_generator.py +++ b/sdk/core/azure-core/tests/test_stream_generator.py @@ -14,6 +14,7 @@ from unittest import mock except ImportError: import mock +import pytest def test_connection_error_response(): class MockTransport(HttpTransport): @@ -51,4 +52,44 @@ def close(self): http_response.internal_response = MockInternalResponse() stream = StreamDownloadGenerator(pipeline, http_response) with mock.patch('time.sleep', return_value=None): - list(stream) + with pytest.raises(StopIteration): + stream.__next__() + +def test_connection_error_416(): + class MockTransport(HttpTransport): + def __init__(self): + self._count = 0 + + def __exit__(self, exc_type, exc_val, exc_tb): + pass + def close(self): + pass + def open(self): + pass + + def send(self, request, **kwargs): + request = HttpRequest('GET', 'http://127.0.0.1/') + response = HttpResponse(request, None) + response.status_code = 416 + return response + + def __next__(self): + if self._count == 0: + self._count += 1 + raise requests.exceptions.ConnectionError + + class MockInternalResponse(): + def iter_content(self, block_size): + return MockTransport() + + def close(self): + pass + + http_request = HttpRequest('GET', 'http://127.0.0.1/') + pipeline = Pipeline(MockTransport()) + http_response = HttpResponse(http_request, None) + http_response.internal_response = MockInternalResponse() + stream = StreamDownloadGenerator(pipeline, http_response) + with mock.patch('time.sleep', return_value=None): + with pytest.raises(requests.exceptions.ConnectionError): + stream.__next__() \ No newline at end of file From de25b7a1a44374f668050812f485f43586b184b5 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 13:03:09 -0700 Subject: [PATCH 8/9] update --- .../azure-core/azure/core/pipeline/transport/_base_async.py | 2 -- sdk/core/azure-core/tests/test_stream_generator.py | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py b/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py index b1d6feeee840..bfc51ef6109b 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_base_async.py @@ -168,8 +168,6 @@ class AsyncHttpTransport( @abc.abstractmethod async def send(self, request, **kwargs): - # type: (HTTPRequestType, Any) -> HTTPResponseType - """Send the request using this HTTP sender. """ diff --git a/sdk/core/azure-core/tests/test_stream_generator.py b/sdk/core/azure-core/tests/test_stream_generator.py index 4e3c9439215d..9c53e99d031e 100644 --- a/sdk/core/azure-core/tests/test_stream_generator.py +++ b/sdk/core/azure-core/tests/test_stream_generator.py @@ -73,6 +73,9 @@ def send(self, request, **kwargs): response.status_code = 416 return response + def next(self): + self.__next__() + def __next__(self): if self._count == 0: self._count += 1 From 3f08ca114d75387c7762c33d930b93c099f45456 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 15 May 2020 13:21:28 -0700 Subject: [PATCH 9/9] update --- sdk/core/azure-core/tests/test_stream_generator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/core/azure-core/tests/test_stream_generator.py b/sdk/core/azure-core/tests/test_stream_generator.py index 9c53e99d031e..4f40bba885eb 100644 --- a/sdk/core/azure-core/tests/test_stream_generator.py +++ b/sdk/core/azure-core/tests/test_stream_generator.py @@ -34,6 +34,9 @@ def send(self, request, **kwargs): response.status_code = 200 return response + def next(self): + self.__next__() + def __next__(self): if self._count == 0: self._count += 1