diff options
author | Chenxiong Qi <qcxhome@gmail.com> | 2023-12-20 20:54:05 +0800 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2024-01-23 14:00:46 +0100 |
commit | 74de0ebb810f3e13c45f01c63067cb8de794ce3c (patch) | |
tree | b5f069ad74d12b5ce095b4ad9159861fd1445614 /sw/qa/python | |
parent | 3a20c691ab1d6a16ad0fc144926b22c098552be4 (diff) |
tdf#97361 Make unittests more pythonic: XIndexAccess
Change-Id: I05ef274dd0ad5dc35b5455cfc01feabc6c0820a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161276
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'sw/qa/python')
-rw-r--r-- | sw/qa/python/check_styles.py | 4 | ||||
-rw-r--r-- | sw/qa/python/xtextrange.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/sw/qa/python/check_styles.py b/sw/qa/python/check_styles.py index aca3d8f0486e..59e9637d56a9 100644 --- a/sw/qa/python/check_styles.py +++ b/sw/qa/python/check_styles.py @@ -62,8 +62,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)) diff --git a/sw/qa/python/xtextrange.py b/sw/qa/python/xtextrange.py index 583cabc30aba..a0b7925b9ff9 100644 --- a/sw/qa/python/xtextrange.py +++ b/sw/qa/python/xtextrange.py @@ -91,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) |