sw/qa/python/check_cross_references.py |    6 ++----
 sw/qa/python/check_fields.py           |    3 +--
 sw/qa/python/check_flies.py            |   10 +++++-----
 3 files changed, 8 insertions(+), 11 deletions(-)

New commits:
commit ada02c556531e9e5f28a159223fc7e2b36a7a84d
Author: Saurav Chirania <saurav.c...@gmail.com>
Date:   Sun Jan 14 20:51:17 2018 +0530

    tdf#97361 Tests in sw should be more pythonic
    
    The modified files have been made more pythonic
    by removing Java-like codes.
    
    Change-Id: I46c121f3bd350b0218ca700ea949616e010f917e
    Reviewed-on: https://gerrit.libreoffice.org/47863
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/sw/qa/python/check_cross_references.py 
b/sw/qa/python/check_cross_references.py
index 9eaabf0b0105..742cc0d94ad5 100644
--- a/sw/qa/python/check_cross_references.py
+++ b/sw/qa/python/check_cross_references.py
@@ -59,8 +59,7 @@ class CheckCrossReferences(unittest.TestCase):
             if (self.xPortionEnum is None):
                 break
 
-            while self.xPortionEnum.hasMoreElements():
-                xPortionProps = self.xPortionEnum.nextElement()
+            for xPortionProps in self.xPortionEnum:
                 sPortionType = 
str(xPortionProps.getPropertyValue("TextPortionType"))
                 if (sPortionType == "TextField"):
                     xField = xPortionProps.getPropertyValue("TextField")
@@ -185,8 +184,7 @@ class CheckCrossReferences(unittest.TestCase):
         self.xParaEnum = xParaEnumAccess.createEnumeration()
 
         # iterate on the paragraphs to find certain paragraph to insert the 
bookmark
-        while self.xParaEnum.hasMoreElements():
-            xParaTextRange = self.xParaEnum.nextElement()
+        for xParaTextRange in self.xParaEnum:
 
             if xParaTextRange.getString() == "J":
                 break
diff --git a/sw/qa/python/check_fields.py b/sw/qa/python/check_fields.py
index 2fdbdf93cc2c..60418a93001d 100644
--- a/sw/qa/python/check_fields.py
+++ b/sw/qa/python/check_fields.py
@@ -29,8 +29,7 @@ class CheckFields(unittest.TestCase):
         xDoc = self.__class__._xDoc
         xEnumerationAccess = xDoc.getTextFields()
         xFieldEnum = xEnumerationAccess.createEnumeration()
-        while xFieldEnum.hasMoreElements():
-            xField = xFieldEnum.nextElement()
+        for xField in xFieldEnum:
             if xField.supportsService("com.sun.star.text.TextField.JumpEdit"):
                 xAnchor = xField.getAnchor()
                 read_content = xAnchor.getString()
diff --git a/sw/qa/python/check_flies.py b/sw/qa/python/check_flies.py
index d9407731e609..6353ccda150d 100644
--- a/sw/qa/python/check_flies.py
+++ b/sw/qa/python/check_flies.py
@@ -64,7 +64,7 @@ class CheckFlies(unittest.TestCase):
                          "Unexpected number of embedded frames reported")
 
         for nCurrentFrameIdx in range(len(xEmbeddedFramesIdx)):
-            xEmbeddedFramesIdx.getByIndex(nCurrentFrameIdx)
+            xEmbeddedFramesIdx[nCurrentFrameIdx]
 
     def checkGraphicFrames(self, xTGOS):
         vExpectedGraphicFrames = ["graphics1"]
@@ -76,7 +76,7 @@ class CheckFlies(unittest.TestCase):
             # raises ValueError if not found
             xGraphicFrames[sFrameName]
             self.assertTrue(
-                xGraphicFrames.hasByName(sFrameName),
+                sFrameName in xGraphicFrames,
                 "Could not find graphics frame by name.")
         self.assertTrue(
             not(vExpectedGraphicFrames),
@@ -87,7 +87,7 @@ class CheckFlies(unittest.TestCase):
                          "Unexpected number of graphics frames reported")
 
         for nCurrentFrameIdx in range(len(xGraphicFramesIdx)):
-            xGraphicFramesIdx.getByIndex(nCurrentFrameIdx)
+            xGraphicFramesIdx[nCurrentFrameIdx]
 
     def checkTextFrames(self, xTFS):
         vExpectedTextFrames = ["Frame1", "Frame2"]
@@ -100,7 +100,7 @@ class CheckFlies(unittest.TestCase):
             # raises ValueError if not found
             xTextFrames[sFrameName]
             self.assertTrue(
-                xTextFrames.hasByName(sFrameName),
+                sFrameName in xTextFrames,
                 "Could not find text frame by name.")
 
         self.assertTrue(
@@ -112,7 +112,7 @@ class CheckFlies(unittest.TestCase):
                          "Unexpected number of text frames reported")
 
         for nCurrentFrameIdx in range(len(xTextFramesIdx)):
-            xTextFramesIdx.getByIndex(nCurrentFrameIdx)
+            xTextFramesIdx[nCurrentFrameIdx]
 
 
 if __name__ == "__main__":
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to