Skip to content

Commit

Permalink
Fixed TestBulk::test_bulk_works_with_bytestring_body.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Nov 7, 2023
1 parent 1efe172 commit e9baa62
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions opensearchpy/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ def _wrapped(*args: Any, **kwargs: Any) -> Any:

def _bulk_body(serializer: Optional[Serializer], body: Any) -> Any:
# if not passed in a string, serialize items and join by newline
if serializer and not isinstance(body, str):
body = "\n".join(map(serializer.dumps, body))
if not isinstance(body, string_types):
body = "\n".join(map(serializer.dumps, body)) # type: ignore

Check warning on line 191 in opensearchpy/client/utils.py

View check run for this annotation

Codecov / codecov/patch

opensearchpy/client/utils.py#L191

Added line #L191 was not covered by tests

# bulk body must end with a newline
if isinstance(body, bytes):
if not body.endswith(b"\n"):
body += b"\n"
elif isinstance(body, str) and not body.endswith("\n"):
body += "\n"
elif isinstance(body, string_types) and not body.endswith("\n"): # type: ignore
body += "\n" # type: ignore

return body

Expand Down

0 comments on commit e9baa62

Please sign in to comment.