From 35a8c5e6ba96fc5f7be93e46a85fcbaec0e6c032 Mon Sep 17 00:00:00 2001 From: Matthew Chang Date: Wed, 21 Aug 2024 15:12:32 -0700 Subject: [PATCH] Adds unittest for readlines with azure --- smart_open/tests/test_azure.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/smart_open/tests/test_azure.py b/smart_open/tests/test_azure.py index a82dbf17..a65a9186 100644 --- a/smart_open/tests/test_azure.py +++ b/smart_open/tests/test_azure.py @@ -373,6 +373,24 @@ def test_read(self): self.assertEqual(content[6:14], fin.read(8)) # ř is 2 bytes self.assertEqual(content[14:], fin.read()) # read the rest + def test_readline(self): + """Are Azure Blob Storage files read correctly with readlines?""" + content = u"hello wořld\nhow are you?".encode('utf8') + blob_name = "test_read_%s" % BLOB_NAME + put_to_container(blob_name, contents=content) + logger.debug('content: %r len: %r', content, len(content)) + + with smart_open.azure.Reader(CONTAINER_NAME, blob_name, CLIENT) as fin: + line = fin.readline() + self.assertEqual(line, 'hello wořld\n') + + fin.seek(0) + actual = list(fin) + self.assertEqual(fin.tell(), len(content)) + + expected = ['hello wořld\n', 'how are you?'] + self.assertEqual(expected, actual) + def test_read_max_concurrency(self): """Are Azure Blob Storage files read correctly?""" content = u"hello wořld\nhow are you?".encode('utf8')