Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed Mar 20, 2024
1 parent 2d632d5 commit 330e6f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion smart_open/tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,25 +379,31 @@ def test_binary_iterator(self):
expected = u"выйду ночью в поле с конём".encode('utf-8').split(b' ')
_resource('s3').Object(BUCKET_NAME, KEY_NAME).put(Body=b'\n'.join(expected))

# test the __iter__ method
with self.assertApiCalls(GetObject=1):
with smart_open.s3.open(BUCKET_NAME, KEY_NAME, 'rb') as fin:
actual = [line.rstrip() for line in fin]
self.assertEqual(expected, actual)

# test the __next__ method
with self.assertApiCalls(GetObject=1):
with smart_open.s3.open(BUCKET_NAME, KEY_NAME, 'rb') as fin:
first = next(fin).rstrip()
self.assertEqual(expected[0], first)

def test_text_iterator(self):
expected = u"выйду ночью в поле с конём".split(' ')
_resource('s3').Object(BUCKET_NAME, KEY_NAME).put(Body=b'\n'.join(expected))
_resource('s3').Object(BUCKET_NAME, KEY_NAME).put(
Body='\n'.join(expected).encode('utf-8')
)

# test the __iter__ method
with self.assertApiCalls(GetObject=1):
with smart_open.s3.open(BUCKET_NAME, KEY_NAME, 'r') as fin:
actual = [line.rstrip() for line in fin]
self.assertEqual(expected, actual)

# test the __next__ method
with self.assertApiCalls(GetObject=1):
with smart_open.s3.open(BUCKET_NAME, KEY_NAME, 'r') as fin:
first = next(fin).rstrip()
Expand Down

0 comments on commit 330e6f7

Please sign in to comment.