Kaydet (Commit) ada02c55 authored tarafından Saurav Chirania's avatar Saurav Chirania Kaydeden (comit) Thorsten Behrens

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/47863Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 03afd4b7
......@@ -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
......
......@@ -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()
......
......@@ -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__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment