Skip to content

Commit

Permalink
Fix __str__ method in SinglepartWriter (#791)
Browse files Browse the repository at this point in the history
* Fix __str__ method in SinglepartWriter

* Add unit test

* Fix test

* simplify test

---------

Co-authored-by: Michael Penkov <[email protected]>
  • Loading branch information
ThosRTanner and mpenkov authored Feb 22, 2024
1 parent 192845b commit 101bc0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion smart_open/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.close()

def __str__(self):
return "smart_open.s3.SinglepartWriter(%r, %r)" % (self._object.bucket_name, self._object.key)
return "smart_open.s3.SinglepartWriter(%r, %r)" % (self._bucket, self._key)

def __repr__(self):
return "smart_open.s3.SinglepartWriter(bucket=%r, key=%r)" % (self._bucket, self._key)
Expand Down
4 changes: 4 additions & 0 deletions smart_open/tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ def test_writebuffer(self):

assert actual == contents

def test_str(self):
with smart_open.s3.open(BUCKET_NAME, 'key', 'wb', multipart_upload=False) as fout:
assert str(fout) == "smart_open.s3.SinglepartWriter('test-smartopen', 'key')"


ARBITRARY_CLIENT_ERROR = botocore.client.ClientError(error_response={}, operation_name='bar')

Expand Down

0 comments on commit 101bc0d

Please sign in to comment.