diff options
Diffstat (limited to 'sw/qa/python')
-rw-r--r-- | sw/qa/python/check_cross_references.py | 26 | ||||
-rw-r--r-- | sw/qa/python/check_indexed_property_values.py | 4 | ||||
-rw-r--r-- | sw/qa/python/check_named_property_values.py | 5 | ||||
-rw-r--r-- | sw/qa/python/check_range_properties.py | 5 | ||||
-rw-r--r-- | sw/qa/python/check_styles.py | 23 | ||||
-rw-r--r-- | sw/qa/python/check_table.py | 6 | ||||
-rw-r--r-- | sw/qa/python/check_xautotextcontainer.py | 1 | ||||
-rw-r--r-- | sw/qa/python/check_xautotextgroup.py | 1 | ||||
-rw-r--r-- | sw/qa/python/check_xmodel.py | 2 | ||||
-rw-r--r-- | sw/qa/python/check_xmodifiable2.py | 9 | ||||
-rw-r--r-- | sw/qa/python/check_xnamedgraph.py | 17 | ||||
-rw-r--r-- | sw/qa/python/check_xtextrangecompare.py | 2 | ||||
-rw-r--r-- | sw/qa/python/set_expression.py | 3 | ||||
-rw-r--r-- | sw/qa/python/text_portion_enumeration_test.py | 57 | ||||
-rw-r--r-- | sw/qa/python/xcontrolshape.py | 2 | ||||
-rw-r--r-- | sw/qa/python/xstyleloader.py | 3 | ||||
-rw-r--r-- | sw/qa/python/xtext.py | 1 | ||||
-rw-r--r-- | sw/qa/python/xtextcursor.py | 3 | ||||
-rwxr-xr-x | sw/qa/python/xtextfieldssupplier.py | 2 | ||||
-rw-r--r-- | sw/qa/python/xtextrange.py | 9 |
20 files changed, 59 insertions, 122 deletions
diff --git a/sw/qa/python/check_cross_references.py b/sw/qa/python/check_cross_references.py index 6aad1c47ca3a..7778ff5f2100 100644 --- a/sw/qa/python/check_cross_references.py +++ b/sw/qa/python/check_cross_references.py @@ -16,17 +16,6 @@ the License at http://www.apache.org/licenses/LICENSE-2.0 . ''' import unittest -import unohelper -import os -from com.sun.star.lang import XMultiServiceFactory -from com.sun.star.text import XTextDocument -from com.sun.star.text import XTextField -from com.sun.star.container import XEnumeration -from com.sun.star.util import XRefreshable -from com.sun.star.container import XEnumerationAccess -from com.sun.star.beans import XPropertySet -from com.sun.star.text import XTextFieldsSupplier -from com.sun.star.container import XNamed from com.sun.star.text.ReferenceFieldPart import (NUMBER, NUMBER_NO_CONTEXT, NUMBER_FULL_CONTEXT, TEXT) from com.sun.star.text.ReferenceFieldSource import BOOKMARK from org.libreoffice.unotest import UnoInProcess @@ -103,12 +92,13 @@ class CheckCrossReferences(unittest.TestCase): FieldResult4 = "1" FieldResult5 = "1" FieldResult6 = "A.1" - FieldResult7 = "2(a)" - FieldResult8 = "2(b)" - FieldResult9 = "2" - FieldResult10 = "1(a)" + FieldResult7 = " 2.(a)" + FieldResult8 = " 2.(b)" + FieldResult9 = " 2" + FieldResult10 = " 1.(a)" FieldResult11 = "(b)" FieldResult12 = "(a)" + FieldResult13 = " 1" # variables for current field xField = self.getNextField() @@ -166,9 +156,9 @@ class CheckCrossReferences(unittest.TestCase): xField = self.getNextField() xProps = self.getFieldProps(xField) - self.checkField(xField, xProps, NUMBER, FieldResult4) - self.checkField(xField, xProps, NUMBER_NO_CONTEXT, FieldResult4) - self.checkField(xField, xProps, NUMBER_FULL_CONTEXT, FieldResult4) + self.checkField(xField, xProps, NUMBER, FieldResult13) + self.checkField(xField, xProps, NUMBER_NO_CONTEXT, FieldResult13) + self.checkField(xField, xProps, NUMBER_FULL_CONTEXT, FieldResult13) xField = self.getNextField() xProps = self.getFieldProps(xField) diff --git a/sw/qa/python/check_indexed_property_values.py b/sw/qa/python/check_indexed_property_values.py index ceaf82a6cac6..d6d314adc894 100644 --- a/sw/qa/python/check_indexed_property_values.py +++ b/sw/qa/python/check_indexed_property_values.py @@ -17,12 +17,9 @@ ''' import unittest -import unohelper import uno from org.libreoffice.unotest import UnoInProcess from com.sun.star.beans import PropertyValue -from com.sun.star.container import XIndexContainer -from org.libreoffice.unotest import OfficeConnection from com.sun.star.lang import IllegalArgumentException from com.sun.star.lang import IndexOutOfBoundsException @@ -53,7 +50,6 @@ class CheckIndexedPropertyValues(unittest.TestCase): p3 = PropertyValue(Name="Peter", Value="FamilyGuy") prop3 = uno.Any("[]com.sun.star.beans.PropertyValue", (p3,)) - t = xCont.getElementType() self.assertEqual(0, len(xCont), "Initial container is not empty") uno.invoke(xCont, "insertByIndex", (0, prop1)) diff --git a/sw/qa/python/check_named_property_values.py b/sw/qa/python/check_named_property_values.py index 1a81d13a6323..39d4b33cacc9 100644 --- a/sw/qa/python/check_named_property_values.py +++ b/sw/qa/python/check_named_property_values.py @@ -17,13 +17,9 @@ ''' import unittest -import unohelper -import os import uno from org.libreoffice.unotest import UnoInProcess from com.sun.star.beans import PropertyValue -from com.sun.star.container import XNameContainer -from org.libreoffice.unotest import OfficeConnection from com.sun.star.container import ElementExistException from com.sun.star.lang import IllegalArgumentException from com.sun.star.container import NoSuchElementException @@ -53,7 +49,6 @@ class CheckNamedPropertyValues(unittest.TestCase): p2 = PropertyValue(Name="Horst", Value="BadGuy") prop2 = uno.Any("[]com.sun.star.beans.PropertyValue", (p2,)) - t = xCont.getElementType() self.assertFalse(xCont.hasElements(), "Initial container is not empty") uno.invoke(xCont, "insertByName", ("prop1", prop1)) diff --git a/sw/qa/python/check_range_properties.py b/sw/qa/python/check_range_properties.py index 2be93686242a..26babf5220ce 100644 --- a/sw/qa/python/check_range_properties.py +++ b/sw/qa/python/check_range_properties.py @@ -7,13 +7,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -import math import unittest from org.libreoffice.unotest import UnoInProcess -from com.sun.star.container import NoSuchElementException -from com.sun.star.beans import UnknownPropertyException -from com.sun.star.lang import IndexOutOfBoundsException -from com.sun.star.lang import IllegalArgumentException class CheckRangeProperties(unittest.TestCase): diff --git a/sw/qa/python/check_styles.py b/sw/qa/python/check_styles.py index c2ae21cf9899..5d5052143bd9 100644 --- a/sw/qa/python/check_styles.py +++ b/sw/qa/python/check_styles.py @@ -7,15 +7,12 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -import math import unittest from org.libreoffice.unotest import UnoInProcess from com.sun.star.container import NoSuchElementException from com.sun.star.beans import UnknownPropertyException -from com.sun.star.lang import IndexOutOfBoundsException from com.sun.star.lang import IllegalArgumentException - class CheckStyle(unittest.TestCase): @classmethod @@ -63,8 +60,8 @@ class CheckStyle(unittest.TestCase): with self.assertRaises(NoSuchElementException): xFamily.getByName("foobarbaz") - with self.assertRaises(IndexOutOfBoundsException): - xFamily.getByIndex(-1) + with self.assertRaises(IndexError): + xFamily[len(xFamily) + 1] for sStylename in xFamily.ElementNames: self.assertTrue(xFamily.hasByName(sStylename)) @@ -104,21 +101,21 @@ class CheckStyle(unittest.TestCase): xFamily.removeByName(xRightStyle2.Name) with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyleOld") + xFamily.getByName("RightStyleOld") with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyle") + xFamily.getByName("RightStyle") with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyle2Old") + xFamily.getByName("RightStyle2Old") with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("RightStyle2") + xFamily.getByName("RightStyle2") with self.assertRaises(IllegalArgumentException): xFamily.insertByName("WrongStyle", xWrongStyle) with self.assertRaises(NoSuchElementException): - nope = xFamily.getByName("WrongStyle") + xFamily.getByName("WrongStyle") def test_CharacterFamily(self): xDoc = CheckStyle._uno.openEmptyWriterDoc() @@ -132,7 +129,7 @@ class CheckStyle(unittest.TestCase): def test_ParagraphFamily(self): xDoc = CheckStyle._uno.openEmptyWriterDoc() xParaStyles = xDoc.StyleFamilies["ParagraphStyles"] - vEmptyDocStyles = ['Standard', 'Heading', 'Text body', 'List', 'Caption', 'Index', 'First line indent', 'Hanging indent', 'Text body indent', 'Salutation', 'Signature', 'List Indent', 'Marginalia', 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6', 'Heading 7', 'Heading 8', 'Heading 9', 'Heading 10', 'Title', 'Subtitle', 'Appendix', 'Numbering 1 Start', 'Numbering 1', 'Numbering 1 End', 'Numbering 1 Cont.', 'Numbering 2 Start', 'Numbering 2', 'Numbering 2 End', 'Numbering 2 Cont.', 'Numbering 3 Start', 'Numbering 3', 'Numbering 3 End', 'Numbering 3 Cont.', 'Numbering 4 Start', 'Numbering 4', 'Numbering 4 End', 'Numbering 4 Cont.', 'Numbering 5 Start', 'Numbering 5', 'Numbering 5 End', 'Numbering 5 Cont.', 'List 1 Start', 'List 1', 'List 1 End', 'List 1 Cont.', 'List 2 Start', 'List 2', 'List 2 End', 'List 2 Cont.', 'List 3 Start', 'List 3', 'List 3 End', 'List 3 Cont.', 'List 4 Start', 'List 4', 'List 4 End', 'List 4 Cont.', 'List 5 Start', 'List 5', 'List 5 End', 'List 5 Cont.', 'Index Heading', 'Index 1', 'Index 2', 'Index 3', 'Index Separator', 'Contents Heading', 'Contents 1', 'Contents 2', 'Contents 3', 'Contents 4', 'Contents 5', 'User Index Heading', 'User Index 1', 'User Index 2', 'User Index 3', 'User Index 4', 'User Index 5', 'Contents 6', 'Contents 7', 'Contents 8', 'Contents 9', 'Contents 10', 'Figure Index Heading', 'Figure Index 1', 'Object index heading', 'Object index 1', 'Table index heading', 'Table index 1', 'Bibliography Heading', 'Bibliography 1', 'User Index 6', 'User Index 7', 'User Index 8', 'User Index 9', 'User Index 10', 'Header and Footer','Header', 'Header left', 'Header right', 'Footer', 'Footer left', 'Footer right', 'Table Contents', 'Table Heading', 'Illustration', 'Table', 'Text','Figure', 'Frame contents', 'Footnote', 'Addressee', 'Sender', 'Endnote', 'Drawing', 'Quotations', 'Preformatted Text', 'Horizontal Line', 'List Contents', 'List Heading'] + vEmptyDocStyles = ['Standard', 'Heading', 'Text body', 'List', 'Caption', 'Comment', 'Index', 'First line indent', 'Hanging indent', 'Text body indent', 'Salutation', 'Signature', 'List Indent', 'Marginalia', 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6', 'Heading 7', 'Heading 8', 'Heading 9', 'Heading 10', 'Title', 'Subtitle', 'Appendix', 'Numbering 1 Start', 'Numbering 1', 'Numbering 1 End', 'Numbering 1 Cont.', 'Numbering 2 Start', 'Numbering 2', 'Numbering 2 End', 'Numbering 2 Cont.', 'Numbering 3 Start', 'Numbering 3', 'Numbering 3 End', 'Numbering 3 Cont.', 'Numbering 4 Start', 'Numbering 4', 'Numbering 4 End', 'Numbering 4 Cont.', 'Numbering 5 Start', 'Numbering 5', 'Numbering 5 End', 'Numbering 5 Cont.', 'List 1 Start', 'List 1', 'List 1 End', 'List 1 Cont.', 'List 2 Start', 'List 2', 'List 2 End', 'List 2 Cont.', 'List 3 Start', 'List 3', 'List 3 End', 'List 3 Cont.', 'List 4 Start', 'List 4', 'List 4 End', 'List 4 Cont.', 'List 5 Start', 'List 5', 'List 5 End', 'List 5 Cont.', 'Index Heading', 'Index 1', 'Index 2', 'Index 3', 'Index Separator', 'Contents Heading', 'Contents 1', 'Contents 2', 'Contents 3', 'Contents 4', 'Contents 5', 'User Index Heading', 'User Index 1', 'User Index 2', 'User Index 3', 'User Index 4', 'User Index 5', 'Contents 6', 'Contents 7', 'Contents 8', 'Contents 9', 'Contents 10', 'Figure Index Heading', 'Figure Index 1', 'Object index heading', 'Object index 1', 'Table index heading', 'Table index 1', 'Bibliography Heading', 'Bibliography 1', 'User Index 6', 'User Index 7', 'User Index 8', 'User Index 9', 'User Index 10', 'Header and Footer','Header', 'Header left', 'Header right', 'Footer', 'Footer left', 'Footer right', 'Table Contents', 'Table Heading', 'Illustration', 'Table', 'Text','Figure', 'Frame contents', 'Footnote', 'Addressee', 'Sender', 'Endnote', 'Drawing', 'Quotations', 'Preformatted Text', 'Horizontal Line', 'List Contents', 'List Heading'] self.__test_StyleFamily(xParaStyles, vEmptyDocStyles, "SwXStyle") self.__test_StyleFamilyIndex(xParaStyles, vEmptyDocStyles, "SwXStyle") self.__test_StyleFamilyInsert(xDoc, xParaStyles, vEmptyDocStyles, "com.sun.star.style.ParagraphStyle", "com.sun.star.style.CharacterStyle") @@ -150,7 +147,7 @@ class CheckStyle(unittest.TestCase): def test_FrameFamily(self): xDoc = CheckStyle._uno.openEmptyWriterDoc() xFrameStyles = xDoc.StyleFamilies["FrameStyles"] - vEmptyDocStyles = ['Formula', 'Frame', 'Graphics', 'Labels', 'Marginalia', 'OLE', 'Watermark'] + vEmptyDocStyles = ['Formula', 'Frame', 'Graphics', 'Inline Heading', 'Labels', 'Marginalia', 'OLE', 'Watermark'] self.__test_StyleFamily(xFrameStyles, vEmptyDocStyles, "SwXStyle") self.__test_StyleFamilyIndex(xFrameStyles, vEmptyDocStyles, "SwXStyle") self.__test_StyleFamilyInsert(xDoc, xFrameStyles, vEmptyDocStyles, "com.sun.star.style.FrameStyle", "com.sun.star.style.CharacterStyle") @@ -159,7 +156,7 @@ class CheckStyle(unittest.TestCase): def test_NumberingFamily(self): xDoc = CheckStyle._uno.openEmptyWriterDoc() xNumberingStyles = xDoc.StyleFamilies["NumberingStyles"] - vEmptyDocStyles = ['List 1', 'List 2', 'List 3', 'List 4', 'List 5', 'Numbering 123', 'Numbering ABC', 'Numbering abc', 'Numbering IVX', 'Numbering ivx'] + vEmptyDocStyles = ['No List','List 1', 'List 2', 'List 3', 'List 4', 'List 5', 'Numbering 123', 'Numbering ABC', 'Numbering abc', 'Numbering IVX', 'Numbering ivx'] self.__test_StyleFamily(xNumberingStyles, vEmptyDocStyles, "SwXStyle") self.__test_StyleFamilyIndex(xNumberingStyles, vEmptyDocStyles, "SwXStyle") self.__test_StyleFamilyInsert(xDoc, xNumberingStyles, vEmptyDocStyles, "com.sun.star.style.NumberingStyle", "com.sun.star.style.CharacterStyle") diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py index b06f3caa4d7d..f845be5649ef 100644 --- a/sw/qa/python/check_table.py +++ b/sw/qa/python/check_table.py @@ -35,7 +35,7 @@ class CheckTable(unittest.TestCase): def setUpClass(cls): cls._uno = UnoInProcess() cls._uno.setUp() - cls.OOLineHairline = 2 + cls.OOLineVeryThin = 18 @classmethod def tearDownClass(cls): @@ -44,13 +44,13 @@ class CheckTable(unittest.TestCase): def __test_borderAsserts(self, xBorderLine, line_valid): self.assertTrue(line_valid) self.assertEqual(0, xBorderLine.InnerLineWidth) - self.assertEqual(self.OOLineHairline, xBorderLine.OuterLineWidth) + self.assertEqual(self.OOLineVeryThin, xBorderLine.OuterLineWidth) self.assertEqual(0, xBorderLine.LineDistance) self.assertEqual(0, xBorderLine.Color) def __test_borderAssertsWithLineStyle(self, xBorderLine, line_valid): self.__test_borderAsserts(xBorderLine, line_valid) - self.assertEqual(self.OOLineHairline, xBorderLine.LineWidth) + self.assertEqual(self.OOLineVeryThin, xBorderLine.LineWidth) self.assertEqual(SOLID, xBorderLine.LineStyle) def __test_borderDistance(self, border): diff --git a/sw/qa/python/check_xautotextcontainer.py b/sw/qa/python/check_xautotextcontainer.py index c460c3d0eaa6..b01125dca3f4 100644 --- a/sw/qa/python/check_xautotextcontainer.py +++ b/sw/qa/python/check_xautotextcontainer.py @@ -11,7 +11,6 @@ import unittest from org.libreoffice.unotest import UnoInProcess from com.sun.star.container import NoSuchElementException from com.sun.star.lang import IllegalArgumentException -from com.sun.star.uno import RuntimeException class XAutoTextContainer(unittest.TestCase): # 0 indicates the path of the Office Basis layer diff --git a/sw/qa/python/check_xautotextgroup.py b/sw/qa/python/check_xautotextgroup.py index a41987103e6b..504f12dcd422 100644 --- a/sw/qa/python/check_xautotextgroup.py +++ b/sw/qa/python/check_xautotextgroup.py @@ -11,7 +11,6 @@ import unittest from org.libreoffice.unotest import UnoInProcess from com.sun.star.container import ElementExistException from com.sun.star.container import NoSuchElementException -from com.sun.star.uno import RuntimeException class XAutoTextGroup(unittest.TestCase): diff --git a/sw/qa/python/check_xmodel.py b/sw/qa/python/check_xmodel.py index 27740958ddb1..6487b4781be2 100644 --- a/sw/qa/python/check_xmodel.py +++ b/sw/qa/python/check_xmodel.py @@ -8,11 +8,9 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # import unittest -import unohelper from org.libreoffice.unotest import UnoInProcess from com.sun.star.lang import IllegalArgumentException from com.sun.star.beans import PropertyValue -import uno class TestXModel(unittest.TestCase): diff --git a/sw/qa/python/check_xmodifiable2.py b/sw/qa/python/check_xmodifiable2.py index 53082fc2865e..b860e1f31d0f 100644 --- a/sw/qa/python/check_xmodifiable2.py +++ b/sw/qa/python/check_xmodifiable2.py @@ -173,17 +173,16 @@ class XModifiable2(unittest.TestCase): xDoc = self._uno.openTemplateFromTDOC('WriteProtected.odt') # perform unit test: - # it is unable to set modified flag using text editing - # when modification of the flag was disabled as + # it is able to set modified flag using text editing despite # ODT file was marked to be opened as read-only - self.assertFalse(xDoc.isSetModifiedEnabled()) + self.assertTrue(xDoc.isSetModifiedEnabled()) self.assertFalse(xDoc.isModified()) cursor = xDoc.Text.createTextCursor() xDoc.Text.insertString(cursor, "The first paragraph", 0) - self.assertFalse(xDoc.isSetModifiedEnabled()) - self.assertFalse(xDoc.isModified()) + self.assertTrue(xDoc.isSetModifiedEnabled()) + self.assertTrue(xDoc.isModified()) # clean up xDoc.close(True) diff --git a/sw/qa/python/check_xnamedgraph.py b/sw/qa/python/check_xnamedgraph.py index 84c774bddfa3..3ef7fdedbba0 100644 --- a/sw/qa/python/check_xnamedgraph.py +++ b/sw/qa/python/check_xnamedgraph.py @@ -63,23 +63,6 @@ class XNamedGraph(unittest.TestCase): xDMA = self._uno.openTemplateFromTDOC("XNamedGraph.ott") xGraph = self.getAnyGraph(xDMA) - DATE_URI_STR = "http://www.example.com/Metadata#Version" - OBJECT_STR = "foo" - - # remove by object - self.assertFalse(self.hasStatement(xDMA, xGraph, DATE_URI_STR)) - self.addStatement(xDMA, xGraph, DATE_URI_STR, OBJECT_STR) - self.assertTrue(self.hasStatement(xDMA, xGraph, DATE_URI_STR)) - self.removeStatement(xDMA, xGraph, None, OBJECT_STR) - self.assertFalse(self.hasStatement(xDMA, xGraph, DATE_URI_STR)) - - xDMA.close(True) - - def test_Statements_RemoveByObject(self): - # take any first graph - xDMA = self._uno.openTemplateFromTDOC("XNamedGraph.ott") - xGraph = self.getAnyGraph(xDMA) - DATE_URI_STR_1 = "http://www.example.com/Metadata#Version" DATE_URI_STR_2 = "http://www.example.com/Metadata#Second" OBJECT_STR = "foo" diff --git a/sw/qa/python/check_xtextrangecompare.py b/sw/qa/python/check_xtextrangecompare.py index 181e97ff6b2e..44eb691f4518 100644 --- a/sw/qa/python/check_xtextrangecompare.py +++ b/sw/qa/python/check_xtextrangecompare.py @@ -80,7 +80,7 @@ class XTextRangeCompare(unittest.TestCase): xDoc.close(True) - def test_compareRegionStarts_DiffSelection(self): + def test_compareRegionStarts_SameSelection(self): xDoc = self._uno.openEmptyWriterDoc() cursor1 = xDoc.Text.createTextCursor() diff --git a/sw/qa/python/set_expression.py b/sw/qa/python/set_expression.py index c5dc5e6ae2e9..65f4b3de01d9 100644 --- a/sw/qa/python/set_expression.py +++ b/sw/qa/python/set_expression.py @@ -27,8 +27,7 @@ class TestSetExpression(unittest.TestCase): xDoc = self.__class__._uno.openEmptyWriterDoc() self.__class__._uno.checkProperties( xDoc.createInstance("com.sun.star.text.textfield.SetExpression"), - {"NumberingType": 0, - "Content": "foo", + {"Content": "foo", "CurrentPresentation": "bar", "NumberFormat": 0, "NumberingType": 0, diff --git a/sw/qa/python/text_portion_enumeration_test.py b/sw/qa/python/text_portion_enumeration_test.py index 52b1c2c8b702..9684e03f9a01 100644 --- a/sw/qa/python/text_portion_enumeration_test.py +++ b/sw/qa/python/text_portion_enumeration_test.py @@ -20,11 +20,11 @@ This file incorporates work covered by the following license notice: import uno import unittest import os.path -from org.libreoffice.unotest import UnoInProcess, mkPropertyValue +from org.libreoffice.unotest import UnoInProcess from tempfile import TemporaryDirectory from com.sun.star.uno import RuntimeException from com.sun.star.lang import IllegalArgumentException, NoSupportException -from com.sun.star.beans import PropertyValue, StringPair +from com.sun.star.beans import StringPair from com.sun.star.rdf.URIs import ODF_PREFIX, ODF_SUFFIX from com.sun.star.i18n.NumberFormatIndex import NUMBER_INT from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK, HARD_HYPHEN @@ -45,7 +45,7 @@ class TreeNode(): return "<{}>".format(self.nodetype) def __eq__(self, other): - return type(self) == type(other) + return type(self) is type(other) def __ne__(self, other): return not self == other @@ -192,7 +192,7 @@ class MetaNode(TreeNode): def __eq__(self, other): try: - return (type(other) == type(self) and + return (type(other) is type(self) and MetaNode.eq(other.xmlid, self.xmlid)) except AttributeError: return False @@ -237,7 +237,7 @@ class BookmarkNode(MarkNode): def __eq__(self, other): try: - return (type(other) == type(self) and + return (type(other) is type(self) and super().__eq__(other) and MetaNode.eq(other.xmlid, self.xmlid)) except AttributeError: @@ -275,7 +275,7 @@ class ReferenceMarkNode(MarkNode): self.nodetype = "ReferenceMark" def __eq__(self, other): - return (type(other) == type(self) and super().__eq__(other)) + return (type(other) is type(self) and super().__eq__(other)) def dup(self): return self._dup(ReferenceMarkNode, self.name) @@ -307,7 +307,7 @@ class DocumentIndexMarkNode(MarkNode): self.nodetype = "DocumentIndexMark" def __eq__(self, other): - return (type(other) == type(self) and super().__eq__(other)) + return (type(other) is type(self) and super().__eq__(other)) def dup(self): return self._dup(DocumentIndexMarkNode, self.name) @@ -918,6 +918,10 @@ class FuzzyTester(): print("unexpected node: {}".format(str(node))) +def SoftPageBreakNode(): + raise NotImplementedError("todo") + + class TextPortionEnumerationTest(unittest.TestCase): xMSF = None @@ -963,7 +967,7 @@ class TextPortionEnumerationTest(unittest.TestCase): @unittest.skip("FIXME: insert a soft page break: not done") def test_soft_page_break(self): root = TreeNode() - spbk =SoftPageBreakNode() + spbk = SoftPageBreakNode() text = TextNode("abc") root.appendchild(spbk) root.appendchild(text) @@ -1514,7 +1518,7 @@ class TextPortionEnumerationTest(unittest.TestCase): name2 = self.mkname("toxmark") name3 = self.mkname("bookmark") name4 = self.mkname("frame") - name5 = self.mkname("url") + # name5 = self.mkname("url") name6 = self.mkname("ruby") name7 = self.mkname("refmark") name8 = self.mkname("toxmark") @@ -2119,7 +2123,7 @@ class TextPortionEnumerationTest(unittest.TestCase): met2 = MetaNode(self.mkid("id")) try: inserter.insertrange(Range(0, 4, met2)) - fail("testRangeMetaMeta: overlap left allowed") + self.fail("testRangeMetaMeta: overlap left allowed") except IllegalArgumentException: pass root = TreeNode() @@ -2535,7 +2539,7 @@ class TextPortionEnumerationTest(unittest.TestCase): try: xMeta1.setParent(xMeta4) - fail("setParent(): allowed?") + self.fail("setParent(): allowed?") except NoSupportException: pass self.assertIsNone(xMeta1.getParent(), "getParent(): not None") @@ -2592,7 +2596,7 @@ class TextPortionEnumerationTest(unittest.TestCase): try: xMeta.createTextCursorByRange(None) - fail("createTextCursorByRange(): None allowed?") + self.fail("createTextCursorByRange(): None allowed?") except RuntimeException: pass @@ -2609,13 +2613,13 @@ class TextPortionEnumerationTest(unittest.TestCase): try: xMeta.insertString(None, "foo", False) - fail("insertString(): None allowed?") + self.fail("insertString(): None allowed?") except RuntimeException: pass try: xMeta.insertString(xDocTextCursor, "foo", False) - fail("insertString(): cursor outside allowed?") + self.fail("insertString(): cursor outside allowed?") except RuntimeException: pass @@ -2630,14 +2634,14 @@ class TextPortionEnumerationTest(unittest.TestCase): try: xMeta.insertControlCharacter(None, HARD_HYPHEN, False) - fail("insertControlCharacter(): None allowed?") + self.fail("insertControlCharacter(): None allowed?") except IllegalArgumentException: pass xStart = xMeta.getStart() try: xMeta.insertControlCharacter(xDocTextCursor, HARD_HYPHEN, False) - fail("insertControlCharacter(): cursor outside allowed?") + self.fail("insertControlCharacter(): cursor outside allowed?") except IllegalArgumentException: pass @@ -2654,19 +2658,19 @@ class TextPortionEnumerationTest(unittest.TestCase): xMeta.setString("45") try: xMeta.insertTextContent(None, xMeta, False) - fail("insertTextContent(): None range allowed?") + self.fail("insertTextContent(): None range allowed?") except IllegalArgumentException: pass try: xMeta.insertTextContent(xStart, None, False) - fail("insertTextContent(): None content allowed?") + self.fail("insertTextContent(): None content allowed?") except IllegalArgumentException: pass try: xMeta.insertTextContent(xDocTextCursor, xMeta, False) - fail("insertTextContent(): cursor outside allowed?") + self.fail("insertTextContent(): cursor outside allowed?") except IllegalArgumentException: pass @@ -2699,7 +2703,7 @@ class TextPortionEnumerationTest(unittest.TestCase): try: xMeta.removeTextContent(None) - fail("removeTextContent(): None content allowed?") + self.fail("removeTextContent(): None content allowed?") except RuntimeException: pass @@ -2775,7 +2779,6 @@ class TextPortionEnumerationTest(unittest.TestCase): ## XTextCursor xMetaCursor = xMeta.createTextCursor() self.assertIsNotNone(xMetaCursor, "createTextCursor(): no cursor") - bSuccess = False xMetaCursor.gotoStart(False) xMetaCursor.gotoEnd(False) bSuccess = xMetaCursor.goLeft(1, False) @@ -2790,7 +2793,7 @@ class TextPortionEnumerationTest(unittest.TestCase): xMetaCursor.gotoRange(xEnd, False) try: xMetaCursor.gotoRange(xDocTextCursor, False) - fail("gotoRange(): succeeded") + self.fail("gotoRange(): succeeded") except RuntimeException: pass @@ -3271,7 +3274,7 @@ class TextPortionEnumerationTest(unittest.TestCase): try: if i_comp: i_comp.close(True) - except Exception as e: + except Exception: pass def test_load_store(self): @@ -3295,7 +3298,6 @@ class TextPortionEnumerationTest(unittest.TestCase): self.close(xComp) def checkloadmeta(self, xTextDoc): - xText = xTextDoc.getText() print("Checking meta(-field)s in loaded test document...") root = TreeNode() root.appendchild(RubyNode("ruby1") @@ -3365,7 +3367,6 @@ class TextPortionEnumerationTest(unittest.TestCase): self.close(xComp) def checkloadxmlid(self, xTextDoc): - xText = xTextDoc.getText() xRepo = xTextDoc.getRDFRepository() print("Checking bookmarks in loaded test document...") @@ -3445,7 +3446,7 @@ class TextPortionEnumerationTest(unittest.TestCase): xIndex5 = xIndexes["User-Defined1"] self.assertTrue(self.eq(xIndex5.MetadataReference, StringPair("content.xml", "idUD")), "idUD") - xIndex5s = xSections["User-Defined1"] + xIndex5s = xSections["User-Defined Index1"] # User-Defined => User-Defined Index, tdf#161574 self.assertTrue(self.eq(xIndex5s.MetadataReference, StringPair("content.xml", "idUD")), "idUD") xIndex6 = xIndexes["Table of Objects1"] @@ -3473,7 +3474,7 @@ class TextPortionEnumerationTest(unittest.TestCase): xText = xDoc.getText() xTextEnum = xText.createEnumeration() ## skip to right paragraph - xTextEnum.nextElement(); # skip first -- always empty! + xTextEnum.nextElement() # skip first -- always empty! xElement = xTextEnum.nextElement() # second contains test case xEnum = xElement.createEnumeration() outtree = EnumConverter().convert(xEnum) @@ -3491,7 +3492,7 @@ class TextPortionEnumerationTest(unittest.TestCase): return "{}{}".format(prefix, self.__class__.count) def mkid(self, prefix): - id = self.mkname(prefix) + self.mkname(prefix) return StringPair("content.xml", self.mkname(prefix)) def mkid_(self, id): diff --git a/sw/qa/python/xcontrolshape.py b/sw/qa/python/xcontrolshape.py index 336a6d3449c0..899c0c20b863 100644 --- a/sw/qa/python/xcontrolshape.py +++ b/sw/qa/python/xcontrolshape.py @@ -8,10 +8,8 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # import unittest -import unohelper from org.libreoffice.unotest import UnoInProcess from com.sun.star.beans import UnknownPropertyException -import uno class TestXControlShape(unittest.TestCase): diff --git a/sw/qa/python/xstyleloader.py b/sw/qa/python/xstyleloader.py index ed2d7ffca4a4..92b901b9d527 100644 --- a/sw/qa/python/xstyleloader.py +++ b/sw/qa/python/xstyleloader.py @@ -8,11 +8,8 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -import os import pathlib import unittest -import unohelper -import uno from org.libreoffice.unotest import UnoInProcess, makeCopyFromTDOC from com.sun.star.beans import PropertyValue diff --git a/sw/qa/python/xtext.py b/sw/qa/python/xtext.py index 6d82647bf6b4..db1f83803148 100644 --- a/sw/qa/python/xtext.py +++ b/sw/qa/python/xtext.py @@ -11,7 +11,6 @@ import unittest from org.libreoffice.unotest import UnoInProcess -from com.sun.star.lang import IllegalArgumentException class TestXText(unittest.TestCase): diff --git a/sw/qa/python/xtextcursor.py b/sw/qa/python/xtextcursor.py index 30d0518690a7..2c374bee5870 100644 --- a/sw/qa/python/xtextcursor.py +++ b/sw/qa/python/xtextcursor.py @@ -8,10 +8,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # import unittest -import unohelper from org.libreoffice.unotest import UnoInProcess -import uno -import time class TestXTextCursor(unittest.TestCase): diff --git a/sw/qa/python/xtextfieldssupplier.py b/sw/qa/python/xtextfieldssupplier.py index f99b0fc85ab7..76004a095f26 100755 --- a/sw/qa/python/xtextfieldssupplier.py +++ b/sw/qa/python/xtextfieldssupplier.py @@ -8,10 +8,8 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # import unittest -import unohelper from org.libreoffice.unotest import UnoInProcess from com.sun.star.container import NoSuchElementException -import uno class TestXTextFieldsSupplier(unittest.TestCase): diff --git a/sw/qa/python/xtextrange.py b/sw/qa/python/xtextrange.py index 75e4aed79561..a0b7925b9ff9 100644 --- a/sw/qa/python/xtextrange.py +++ b/sw/qa/python/xtextrange.py @@ -8,10 +8,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # import unittest -import unohelper from org.libreoffice.unotest import UnoInProcess -import uno -import time class TestXTextRange(unittest.TestCase): @@ -94,11 +91,11 @@ class TestXTextRange(unittest.TestCase): def test_textRangesCompare(self): doc = self._uno.getDoc() # Bookmark in body text - bookmark1 = doc.getBookmarks().getByIndex(0).getAnchor() + bookmark1 = doc.getBookmarks()[0].getAnchor() # Bookmarks in table - bookmark2 = doc.getBookmarks().getByIndex(1).getAnchor() - bookmark3 = doc.getBookmarks().getByIndex(2).getAnchor() + bookmark2 = doc.getBookmarks()[1].getAnchor() + bookmark3 = doc.getBookmarks()[2].getAnchor() res = doc.Text.compareRegionStarts(bookmark1, bookmark2) self.assertEqual(res, 1) |