[Libreoffice-commits] core.git: sw/qa
Saurav Chirania
saurav.chir at gmail.com
Tue Jan 16 14:41:04 UTC 2018
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.chir at 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 <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at 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__":
More information about the Libreoffice-commits
mailing list