Nir Soffer has uploaded a new change for review.

Change subject: directio: Add failing test for DirectFile.readlines()
......................................................................

directio: Add failing test for DirectFile.readlines()

Unlike built-in file object, or io.FileIO, line terminators are not kept
in the output of readlines(). This is usually convenient, but it is not
the expected and documented behavior.

This patch add a new failing test and mark it as brokentest. We will fix
this in the next patch.

Change-Id: I9b487a6537efcf38e61a9170835124cab8821531
Signed-off-by: Nir Soffer <[email protected]>
---
M tests/storage_directio_test.py
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/54694/1

diff --git a/tests/storage_directio_test.py b/tests/storage_directio_test.py
index 1f0822a..1dd2020 100644
--- a/tests/storage_directio_test.py
+++ b/tests/storage_directio_test.py
@@ -18,6 +18,7 @@
 # Refer to the README and COPYING files for full details of the license
 #
 
+from testValidation import brokentest
 from testlib import VdsmTestCase as TestCaseBase
 from testlib import permutations, expandPermutations
 from testlib import temporaryPath
@@ -28,7 +29,7 @@
 @expandPermutations
 class TestDirectFile(TestCaseBase):
 
-    DATA = "a" * 512 + "b" * 512
+    DATA = "".join((c * 127) + "\n" for c in "abcdefgh")
 
     @permutations([[0], [512], [1024], [1024 + 512]])
     def test_read(self, size):
@@ -70,3 +71,11 @@
 
             with open(srcPath) as f:
                 self.assertEquals(f.read(), self.DATA)
+
+    @brokentest("DirectFile does not keep line terminator")
+    def test_readlines(self):
+        with temporaryPath(data=self.DATA) as srcPath, \
+                directio.DirectFile(srcPath, "r") as direct_file, \
+                open(srcPath, "r") as buffered_file:
+            self.assertEquals(direct_file.readlines(),
+                              buffered_file.readlines())


-- 
To view, visit https://gerrit.ovirt.org/54694
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b487a6537efcf38e61a9170835124cab8821531
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to