Skip to content

Commit

Permalink
Fix zstd compression in ab mode (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed Aug 15, 2024
1 parent 8a58abe commit 472ef6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions smart_open/tests/test_smart_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,22 @@ def test_atplus(self):
self.assertEqual(text, SAMPLE_TEXT * 2)


class CompressionRealFileSystemTests(RealFileSystemTests):
"""Same as RealFileSystemTests but with a compressed file."""

def setUp(self):
with named_temporary_file(prefix='test', suffix='.zst', delete=False) as fout:
self.temp_file = fout.name
with smart_open.open(self.temp_file, 'wb') as fout:
fout.write(SAMPLE_BYTES)

def test_aplus(self):
pass # transparent (de)compression unsupported for mode 'ab+'

def test_atplus(self):
pass # transparent (de)compression unsupported for mode 'ab+'


#
# What exactly to patch here differs on _how_ we're opening the file.
# See the _shortcut_open function for details.
Expand Down
2 changes: 2 additions & 0 deletions smart_open/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):


class FileLikeProxy(wrapt.ObjectProxy):
__inner = ... # initialized before wrapt disallows __setattr__ on certain objects

def __init__(self, outer, inner):
super().__init__(outer)
self.__inner = inner
Expand Down

0 comments on commit 472ef6e

Please sign in to comment.