Skip to content

Commit

Permalink
Using itertools.chain to not degrade coverage on empty chunker.decode…
Browse files Browse the repository at this point in the history
… in iter_text
  • Loading branch information
jamesbraza committed Dec 11, 2023
1 parent de404b3 commit 576d69c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions httpx/_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import email.message
import itertools
import json as jsonlib
import typing
import urllib.request
Expand Down Expand Up @@ -851,10 +852,9 @@ def iter_text(
text_content = decoder.decode(byte_content)
for chunk in chunker.decode(text_content):
yield chunk
text_content = decoder.flush()
for chunk in chunker.decode(text_content):
yield chunk
for chunk in chunker.flush():
for chunk in itertools.chain(
chunker.decode(decoder.flush()), chunker.flush()
):
yield chunk

def iter_lines(self) -> typing.Iterator[str]:
Expand Down Expand Up @@ -955,10 +955,9 @@ async def aiter_text(
text_content = decoder.decode(byte_content)
for chunk in chunker.decode(text_content):
yield chunk
text_content = decoder.flush()
for chunk in chunker.decode(text_content):
yield chunk
for chunk in chunker.flush():
for chunk in itertools.chain(
chunker.decode(decoder.flush()), chunker.flush()
):
yield chunk

async def aiter_lines(self) -> typing.AsyncIterator[str]:
Expand Down

0 comments on commit 576d69c

Please sign in to comment.