summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/qa/pytests/insertremovecells.py4
-rw-r--r--pyuno/qa/pytests/testcollections_XCellRange.py39
-rw-r--r--pyuno/qa/pytests/testcollections_XIndexAccess.py57
-rw-r--r--pyuno/qa/pytests/testcollections_XIndexContainer.py64
-rw-r--r--pyuno/qa/pytests/testcollections_XIndexReplace.py34
-rw-r--r--pyuno/qa/pytests/testcollections_XNameAccess.py6
-rw-r--r--pyuno/qa/pytests/testcollections_XNameContainer.py30
-rw-r--r--pyuno/qa/pytests/testcollections_XNameReplace.py22
-rw-r--r--pyuno/qa/pytests/testcollections_base.py8
-rw-r--r--pyuno/qa/pytests/testcollections_mixednameindex.py18
10 files changed, 150 insertions, 132 deletions
diff --git a/pyuno/qa/pytests/insertremovecells.py b/pyuno/qa/pytests/insertremovecells.py
index 5c2585ae16e0..5e29f3256c7f 100644
--- a/pyuno/qa/pytests/insertremovecells.py
+++ b/pyuno/qa/pytests/insertremovecells.py
@@ -23,13 +23,13 @@ class InsertRemoveCells(unittest.TestCase):
smgr = ctxt.ServiceManager
desktop = smgr.createInstanceWithContext('com.sun.star.frame.Desktop', ctxt)
- loadProps = tuple(mkPropertyValue(k, v) for (k, v) in (
+ load_props = tuple(mkPropertyValue(k, v) for (k, v) in (
('Hidden', True),
('ReadOnly', False)
))
tdoc_dir = getenv('TDOC')
url = 'file://' + quote(path.join(tdoc_dir, 'fdo74824.ods'))
- doc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps)
+ doc = desktop.loadComponentFromURL(url, "_blank", 0, load_props)
sheet = doc.Sheets.Sheet1
area = sheet.getCellRangeByName('A2:B4')
diff --git a/pyuno/qa/pytests/testcollections_XCellRange.py b/pyuno/qa/pytests/testcollections_XCellRange.py
index 871f92d3aaed..6754ef52814c 100644
--- a/pyuno/qa/pytests/testcollections_XCellRange.py
+++ b/pyuno/qa/pytests/testcollections_XCellRange.py
@@ -14,6 +14,9 @@ from testcollections_base import CollectionsTestBase
from com.sun.star.beans import PropertyValue
from com.sun.star.table import CellAddress
+# TextTable instance factory
+def getTextTableInstance(doc):
+ return doc.createInstance('com.sun.star.text.TextTable')
# Tests behaviour of objects implementing XCellRange using the new-style
# collection accessors
@@ -48,10 +51,10 @@ class TestXCellRange(CollectionsTestBase):
def test_XCellRange_Table_Cell_00(self):
# Given
doc = self.createBlankTextDocument()
- textTable = doc.createInstance('com.sun.star.text.TextTable')
- textTable.initialize(10, 10)
+ text_table = getTextTableInstance(doc)
+ text_table.initialize(10, 10)
cursor = doc.Text.createTextCursor()
- doc.Text.insertTextContent(cursor, textTable, False)
+ doc.Text.insertTextContent(cursor, text_table, False)
tbl = doc.TextTables.getByIndex(0)
# When
@@ -86,10 +89,10 @@ class TestXCellRange(CollectionsTestBase):
def test_XCellRange_Table_Cell_37(self):
# Given
doc = self.createBlankTextDocument()
- textTable = doc.createInstance('com.sun.star.text.TextTable')
- textTable.initialize(10, 10)
+ text_table = getTextTableInstance(doc)
+ text_table.initialize(10, 10)
cursor = doc.Text.createTextCursor()
- doc.Text.insertTextContent(cursor, textTable, False)
+ doc.Text.insertTextContent(cursor, text_table, False)
tbl = doc.TextTables.getByIndex(0)
# When
@@ -124,10 +127,10 @@ class TestXCellRange(CollectionsTestBase):
def test_XCellRange_Table_Range_Index_Slice(self):
# Given
doc = self.createBlankTextDocument()
- textTable = doc.createInstance('com.sun.star.text.TextTable')
- textTable.initialize(10, 10)
+ text_table = getTextTableInstance(doc)
+ text_table.initialize(10, 10)
cursor = doc.Text.createTextCursor()
- doc.Text.insertTextContent(cursor, textTable, False)
+ doc.Text.insertTextContent(cursor, text_table, False)
tbl = doc.TextTables.getByIndex(0)
doc.lockControllers()
tbl.DataArray = tuple(tuple(str(100 + y) for y in range(10*x, 10*x + 10)) for x in range(10))
@@ -165,10 +168,10 @@ class TestXCellRange(CollectionsTestBase):
def test_XCellRange_Table_Range_Slice_Index(self):
# Given
doc = self.createBlankTextDocument()
- textTable = doc.createInstance('com.sun.star.text.TextTable')
- textTable.initialize(10, 10)
+ text_table = getTextTableInstance(doc)
+ text_table.initialize(10, 10)
cursor = doc.Text.createTextCursor()
- doc.Text.insertTextContent(cursor, textTable, False)
+ doc.Text.insertTextContent(cursor, text_table, False)
tbl = doc.TextTables.getByIndex(0)
doc.lockControllers()
tbl.DataArray = tuple(tuple(str(100 + y) for y in range(10*x, 10*x + 10)) for x in range(10))
@@ -222,10 +225,10 @@ class TestXCellRange(CollectionsTestBase):
def test_XCellRange_Table_Range_Slices(self):
# Given
doc = self.createBlankTextDocument()
- textTable = doc.createInstance('com.sun.star.text.TextTable')
- textTable.initialize(10, 10)
+ text_table = getTextTableInstance(doc)
+ text_table.initialize(10, 10)
cursor = doc.Text.createTextCursor()
- doc.Text.insertTextContent(cursor, textTable, False)
+ doc.Text.insertTextContent(cursor, text_table, False)
tbl = doc.TextTables.getByIndex(0)
doc.lockControllers()
tbl.DataArray = tuple(tuple(str(100 + y) for y in range(10*x, 10*x + 10)) for x in range(10))
@@ -263,10 +266,10 @@ class TestXCellRange(CollectionsTestBase):
def test_XCellRange_Table_Range_Descriptor(self):
# Given
doc = self.createBlankTextDocument()
- textTable = doc.createInstance('com.sun.star.text.TextTable')
- textTable.initialize(10, 10)
+ text_table = getTextTableInstance(doc)
+ text_table.initialize(10, 10)
cursor = doc.Text.createTextCursor()
- doc.Text.insertTextContent(cursor, textTable, False)
+ doc.Text.insertTextContent(cursor, text_table, False)
tbl = doc.TextTables.getByIndex(0)
doc.lockControllers()
tbl.DataArray = tuple(tuple(str(100 + y) for y in range(10*x, 10*x + 10)) for x in range(10))
diff --git a/pyuno/qa/pytests/testcollections_XIndexAccess.py b/pyuno/qa/pytests/testcollections_XIndexAccess.py
index 9a44811bc2be..4631ca3706ed 100644
--- a/pyuno/qa/pytests/testcollections_XIndexAccess.py
+++ b/pyuno/qa/pytests/testcollections_XIndexAccess.py
@@ -15,6 +15,9 @@ from inspect import isclass
from testcollections_base import CollectionsTestBase
from com.sun.star.beans import PropertyValue
+# Footnote instance factory
+def getFootnoteInstance(doc):
+ return doc.createInstance("com.sun.star.text.Footnote")
# Tests behaviour of objects implementing XIndexAccess using the new-style
# collection accessors
@@ -26,7 +29,7 @@ class TestXIndexAccess(CollectionsTestBase):
def insertTestFootnotes(self, doc, count):
cursor = doc.Text.createTextCursor()
for i in range(count):
- footnote = doc.createInstance("com.sun.star.text.Footnote")
+ footnote = getFootnoteInstance(doc)
footnote.Label = 'n'+str(i)
doc.Text.insertTextContent(cursor, footnote, 0)
@@ -82,7 +85,7 @@ class TestXIndexAccess(CollectionsTestBase):
# Given
doc = self.createBlankTextDocument()
cursor = doc.Text.createTextCursor()
- footnote = doc.createInstance("com.sun.star.text.Footnote")
+ footnote = getFootnoteInstance(doc)
doc.Text.insertTextContent(cursor, footnote, 0)
# When
@@ -128,11 +131,11 @@ class TestXIndexAccess(CollectionsTestBase):
# val1,val2 = obj[2:4] # Access by slice
def test_XIndexAccess_ReadSlice(self):
doc = self.createBlankTextDocument()
- testMax = 4
- for i in range(testMax):
+ test_max = 4
+ for i in range(test_max):
t = tuple(range(i))
- for j in [x for x in range(-testMax-2, testMax+3)] + [None]:
- for k in [x for x in range(-testMax-2, testMax+3)] + [None]:
+ for j in [x for x in range(-test_max-2, test_max+3)] + [None]:
+ for k in [x for x in range(-test_max-2, test_max+3)] + [None]:
key = slice(j, k)
expected = t[key]
self.readValuesTestFixture(doc, i, key, expected)
@@ -141,11 +144,11 @@ class TestXIndexAccess(CollectionsTestBase):
# val1,val2 = obj[0:3:2] # Access by extended slice
def test_XIndexAccess_ReadExtendedSlice(self):
doc = self.createBlankTextDocument()
- testMax = 4
- for i in range(testMax):
+ test_max = 4
+ for i in range(test_max):
t = tuple(range(i))
- for j in [x for x in range(-testMax-2, testMax+3)] + [None]:
- for k in [x for x in range(-testMax-2, testMax+3)] + [None]:
+ for j in [x for x in range(-test_max-2, test_max+3)] + [None]:
+ for k in [x for x in range(-test_max-2, test_max+3)] + [None]:
for l in [-2, -1, 2]:
key = slice(j, k, l)
expected = t[key]
@@ -159,7 +162,7 @@ class TestXIndexAccess(CollectionsTestBase):
# Given
doc = self.createBlankTextDocument()
cursor = doc.Text.createTextCursor()
- footnote = doc.createInstance("com.sun.star.text.Footnote")
+ footnote = getFootnoteInstance(doc)
footnote.setLabel('foo')
doc.Text.insertTextContent(cursor, footnote, 0)
footnote = doc.Footnotes.getByIndex(0)
@@ -219,12 +222,12 @@ class TestXIndexAccess(CollectionsTestBase):
doc = self.createBlankTextDocument()
# When
- readFootnotes = []
+ read_footnotes = []
for f in doc.Footnotes:
- readFootnotes.append(f)
+ read_footnotes.append(f)
# Then
- self.assertEqual(0, len(readFootnotes))
+ self.assertEqual(0, len(read_footnotes))
# Tests syntax:
# for val in obj: ... # Implicit iterator (values)
@@ -234,18 +237,18 @@ class TestXIndexAccess(CollectionsTestBase):
# Given
doc = self.createBlankTextDocument()
cursor = doc.Text.createTextCursor()
- footnote = doc.createInstance("com.sun.star.text.Footnote")
+ footnote = getFootnoteInstance(doc)
footnote.setLabel('foo')
doc.Text.insertTextContent(cursor, footnote, 0)
# When
- readFootnotes = []
+ read_footnotes = []
for f in doc.Footnotes:
- readFootnotes.append(f)
+ read_footnotes.append(f)
# Then
- self.assertEqual(1, len(readFootnotes))
- self.assertEqual('foo', readFootnotes[0].Label)
+ self.assertEqual(1, len(read_footnotes))
+ self.assertEqual('foo', read_footnotes[0].Label)
# Tests syntax:
# for val in obj: ... # Implicit iterator (values)
@@ -255,22 +258,22 @@ class TestXIndexAccess(CollectionsTestBase):
# Given
doc = self.createBlankTextDocument()
cursor = doc.Text.createTextCursor()
- footnote1 = doc.createInstance("com.sun.star.text.Footnote")
- footnote2 = doc.createInstance("com.sun.star.text.Footnote")
+ footnote1 = getFootnoteInstance(doc)
+ footnote2 = getFootnoteInstance(doc)
footnote1.setLabel('foo')
footnote2.setLabel('bar')
doc.Text.insertTextContent(cursor, footnote1, 0)
doc.Text.insertTextContent(cursor, footnote2, 0)
# When
- readFootnotes = []
+ read_footnotes = []
for f in doc.Footnotes:
- readFootnotes.append(f)
+ read_footnotes.append(f)
# Then
- self.assertEqual(2, len(readFootnotes))
- self.assertEqual('foo', readFootnotes[0].Label)
- self.assertEqual('bar', readFootnotes[1].Label)
+ self.assertEqual(2, len(read_footnotes))
+ self.assertEqual('foo', read_footnotes[0].Label)
+ self.assertEqual('bar', read_footnotes[1].Label)
# Tests syntax:
# itr = iter(obj) # Named iterator (values)
@@ -280,7 +283,7 @@ class TestXIndexAccess(CollectionsTestBase):
# Given
doc = self.createBlankTextDocument()
cursor = doc.Text.createTextCursor()
- footnote = doc.createInstance("com.sun.star.text.Footnote")
+ footnote = getFootnoteInstance(doc)
footnote.setLabel('foo')
doc.Text.insertTextContent(cursor, footnote, 0)
diff --git a/pyuno/qa/pytests/testcollections_XIndexContainer.py b/pyuno/qa/pytests/testcollections_XIndexContainer.py
index b25a17b8ec87..7bf9e5223039 100644
--- a/pyuno/qa/pytests/testcollections_XIndexContainer.py
+++ b/pyuno/qa/pytests/testcollections_XIndexContainer.py
@@ -13,6 +13,10 @@ import uno
from testcollections_base import CollectionsTestBase
from com.sun.star.beans import PropertyValue
+# DataForm factory
+def getDataFormInstance(doc):
+ return doc.createInstance("com.sun.star.form.component.DataForm")
+
# Tests behaviour of objects implementing XIndexContainer using the new-style
# collection accessors
@@ -37,18 +41,18 @@ class TestXIndexContainer(CollectionsTestBase):
def assignValuesTestFixture(self, count, key, values, expected):
# Given
- propertyValues = self.generateTestPropertyValues(count)
+ property_values = self.generateTestPropertyValues(count)
if type(values) is list:
- toAssign = self.generateTestTuple(values)
+ to_assign = self.generateTestTuple(values)
else:
- toAssign = values
+ to_assign = values
if not (isinstance(expected, Exception)):
- toCompare = self.generateTestTuple(expected)
+ to_compare = self.generateTestTuple(expected)
# When
captured = None
try:
- propertyValues[key] = toAssign
+ property_values[key] = to_assign
except Exception as e:
captured = e
@@ -60,20 +64,20 @@ class TestXIndexContainer(CollectionsTestBase):
else:
# expected is list
self.assertEqual(None, captured)
- self.assertEqual(len(expected), propertyValues.getCount())
- for i in range(propertyValues.getCount()):
- self.assertEqual(toCompare[i][0].Name, propertyValues.getByIndex(i)[0].Name)
+ self.assertEqual(len(expected), property_values.getCount())
+ for i in range(property_values.getCount()):
+ self.assertEqual(to_compare[i][0].Name, property_values.getByIndex(i)[0].Name)
def deleteValuesTestFixture(self, count, key, expected):
# Given
- propertyValues = self.generateTestPropertyValues(count)
+ property_values = self.generateTestPropertyValues(count)
if not (isinstance(expected, Exception)):
- toCompare = self.generateTestTuple(expected)
+ to_compare = self.generateTestTuple(expected)
# When
captured = None
try:
- del propertyValues[key]
+ del property_values[key]
except Exception as e:
captured = e
@@ -85,9 +89,9 @@ class TestXIndexContainer(CollectionsTestBase):
else:
# expected is list
self.assertEqual(None, captured)
- self.assertEqual(len(expected), propertyValues.getCount())
- for i in range(propertyValues.getCount()):
- self.assertEqual(toCompare[i][0].Name, propertyValues.getByIndex(i)[0].Name)
+ self.assertEqual(len(expected), property_values.getCount())
+ for i in range(property_values.getCount()):
+ self.assertEqual(to_compare[i][0].Name, property_values.getByIndex(i)[0].Name)
# Tests syntax:
# obj[2:4] = val1,val2 # Replace by slice
@@ -98,13 +102,13 @@ class TestXIndexContainer(CollectionsTestBase):
# For:
# Cases requiring sequence type coercion
def test_XIndexContainer_AssignSlice(self):
- baseMax = 5
- assignMax = 5
- for i in range(baseMax):
- for j in [x for x in range(-baseMax-2, baseMax+3)] + [None]:
- for k in [x for x in range(-baseMax-2, baseMax+3)] + [None]:
+ base_max = 5
+ assign_max = 5
+ for i in range(base_max):
+ for j in [x for x in range(-base_max-2, base_max+3)] + [None]:
+ for k in [x for x in range(-base_max-2, base_max+3)] + [None]:
key = slice(j, k)
- for l in range(assignMax):
+ for l in range(assign_max):
assign = [y+100 for y in range(l)]
expected = list(range(i))
expected[key] = assign
@@ -132,7 +136,7 @@ class TestXIndexContainer(CollectionsTestBase):
def test_XIndexContainer_AssignSlice_NoCoercion(self):
# Given
doc = self.createBlankTextDocument()
- form = doc.createInstance("com.sun.star.form.component.DataForm")
+ form = getDataFormInstance(doc)
form.Name = 'foo'
# When
@@ -146,14 +150,14 @@ class TestXIndexContainer(CollectionsTestBase):
# For:
# Cases requiring sequence type coercion
def test_XIndexContainer_AssignExtendedSlice(self):
- baseMax = 5
- assignMax = 5
- for i in range(baseMax):
- for j in [x for x in range(-baseMax-2, baseMax+3)] + [None]:
- for k in [x for x in range(-baseMax-2, baseMax+3)] + [None]:
+ base_max = 5
+ assign_max = 5
+ for i in range(base_max):
+ for j in [x for x in range(-base_max-2, base_max+3)] + [None]:
+ for k in [x for x in range(-base_max-2, base_max+3)] + [None]:
for l in [-2, -1, 1, 2]:
key = slice(j, k, l)
- for m in range(assignMax):
+ for m in range(assign_max):
assign = [y+100 for y in range(m)]
expected = list(range(i))
try:
@@ -166,9 +170,9 @@ class TestXIndexContainer(CollectionsTestBase):
# Tests syntax:
# del obj[0] # Delete by index
def test_XIndexContainer_DelIndex(self):
- baseMax = 5
- for i in range(baseMax):
- for j in [x for x in range(-baseMax-2, baseMax+3)]:
+ base_max = 5
+ for i in range(base_max):
+ for j in [x for x in range(-base_max-2, base_max+3)]:
expected = list(range(i))
try:
del expected[j]
diff --git a/pyuno/qa/pytests/testcollections_XIndexReplace.py b/pyuno/qa/pytests/testcollections_XIndexReplace.py
index d545a5cc8fa1..45d1cc075f33 100644
--- a/pyuno/qa/pytests/testcollections_XIndexReplace.py
+++ b/pyuno/qa/pytests/testcollections_XIndexReplace.py
@@ -14,6 +14,10 @@ from testcollections_base import CollectionsTestBase
from com.sun.star.beans import PropertyValue
+# ContentIndex instance factory
+def getContentIndexInstance(doc):
+ return doc.createInstance("com.sun.star.text.ContentIndex")
+
# Tests behaviour of objects implementing XIndexReplace using the new-style
# collection accessors
# The objects chosen have no special meaning, they just happen to implement the
@@ -22,7 +26,7 @@ from com.sun.star.beans import PropertyValue
class TestXIndexReplace(CollectionsTestBase):
def generateTestContentIndex(self, doc):
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
for i in range(10):
styles = ('n'+str(i),)
uno.invoke(index.LevelParagraphStyles, "replaceByIndex", (i, uno.Any("[]string", styles)))
@@ -37,14 +41,14 @@ class TestXIndexReplace(CollectionsTestBase):
def assignValuesTestFixture(self, doc, key, values, expected):
# Given
index = self.generateTestContentIndex(doc)
- toAssign = self.generateTestTuple(values)
+ to_assign = self.generateTestTuple(values)
if not (isinstance(expected, Exception)):
toCompare = self.generateTestTuple(expected)
# When
captured = None
try:
- index.LevelParagraphStyles[key] = toAssign
+ index.LevelParagraphStyles[key] = to_assign
except Exception as e:
captured = e
@@ -66,7 +70,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceIndex(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When
index.LevelParagraphStyles[0] = ('Caption',)
@@ -81,7 +85,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceIndex_Invalid_None(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When / Then
with self.assertRaises(TypeError):
@@ -94,7 +98,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceIndex_Invalid_String(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When / Then
with self.assertRaises(TypeError):
@@ -107,7 +111,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceIndex_Invalid_Float(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When / Then
with self.assertRaises(TypeError):
@@ -120,7 +124,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceIndex_Invalid_List(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When / Then
with self.assertRaises(TypeError):
@@ -133,7 +137,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceIndex_Invalid_Dict(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When / Then
with self.assertRaises(TypeError):
@@ -146,7 +150,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceIndex_Invalid_InconsistentTuple(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When / Then
with self.assertRaises(TypeError):
@@ -157,13 +161,13 @@ class TestXIndexReplace(CollectionsTestBase):
# For:
# Cases requiring sequence type coercion
def test_XIndexReplace_ReplaceSlice(self):
- assignMax = 12
+ assign_max = 12
doc = self.createBlankTextDocument()
t = tuple(range(10))
for j in [x for x in range(-12, 13)] + [None]:
for k in [x for x in range(-12, 13)] + [None]:
key = slice(j, k)
- for l in range(assignMax):
+ for l in range(assign_max):
assign = [y+100 for y in range(l)]
expected = list(range(10))
try:
@@ -181,7 +185,7 @@ class TestXIndexReplace(CollectionsTestBase):
def test_XIndexReplace_ReplaceSlice_Invalid_InconsistentTuple(self):
# Given
doc = self.createBlankTextDocument()
- index = doc.createInstance("com.sun.star.text.ContentIndex")
+ index = getContentIndexInstance(doc)
# When / Then
with self.assertRaises(TypeError):
@@ -195,14 +199,14 @@ class TestXIndexReplace(CollectionsTestBase):
# For:
# Cases requiring sequence type coercion
def test_XIndexReplace_ReplaceExtendedSlice(self):
- assignMax = 12
+ assign_max = 12
doc = self.createBlankTextDocument()
t = tuple(range(10))
for j in [x for x in range(-12, 13)] + [None]:
for k in [x for x in range(-12, 13)] + [None]:
for l in [-2, -1, 2]:
key = slice(j, k, l)
- for m in range(assignMax):
+ for m in range(assign_max):
assign = [y+100 for y in range(m)]
expected = list(range(10))
try:
diff --git a/pyuno/qa/pytests/testcollections_XNameAccess.py b/pyuno/qa/pytests/testcollections_XNameAccess.py
index 26485602cb75..a93064e78bb1 100644
--- a/pyuno/qa/pytests/testcollections_XNameAccess.py
+++ b/pyuno/qa/pytests/testcollections_XNameAccess.py
@@ -150,12 +150,12 @@ class TestXNameAccess(CollectionsTestBase):
i += 1
# When
- readLinks = []
+ read_links = []
for link in drw.Links:
- readLinks.append(link)
+ read_links.append(link)
# Then
- self.assertEqual(['foo0', 'foo1'], readLinks)
+ self.assertEqual(['foo0', 'foo1'], read_links)
# Tests syntax:
# itr = iter(obj) # Named iterator (keys)
diff --git a/pyuno/qa/pytests/testcollections_XNameContainer.py b/pyuno/qa/pytests/testcollections_XNameContainer.py
index 8838516fdd15..48b63a786f7e 100644
--- a/pyuno/qa/pytests/testcollections_XNameContainer.py
+++ b/pyuno/qa/pytests/testcollections_XNameContainer.py
@@ -13,6 +13,10 @@ import uno
from testcollections_base import CollectionsTestBase
from com.sun.star.beans import PropertyValue
+# SheetCellRanges instance factory
+def getSheetCellRangesInstance(spr):
+ return spr.createInstance("com.sun.star.sheet.SheetCellRanges")
+
# Tests behaviour of objects implementing XNameContainer using the new-style
# collection accessors
@@ -28,11 +32,11 @@ class TestXNameContainer(CollectionsTestBase):
def test_XNameContainer_InsertName(self):
# Given
spr = self.createBlankSpreadsheet()
- ranges = spr.createInstance("com.sun.star.sheet.SheetCellRanges")
- newRange = spr.Sheets.getByIndex(0).getCellRangeByPosition(1, 2, 1, 2)
+ ranges = getSheetCellRangesInstance(spr)
+ new_range = spr.Sheets.getByIndex(0).getCellRangeByPosition(1, 2, 1, 2)
# When
- ranges['foo'] = newRange
+ ranges['foo'] = new_range
# Then
self.assertEqual(1, len(ranges.ElementNames))
@@ -44,30 +48,30 @@ class TestXNameContainer(CollectionsTestBase):
def test_XNameContainer_InsertName_Invalid(self):
# Given
spr = self.createBlankSpreadsheet()
- ranges = spr.createInstance("com.sun.star.sheet.SheetCellRanges")
- newRange = spr.Sheets.getByIndex(0).getCellRangeByPosition(1, 2, 1, 2)
+ ranges = getSheetCellRangesInstance(spr)
+ new_range = spr.Sheets.getByIndex(0).getCellRangeByPosition(1, 2, 1, 2)
# When / Then
with self.assertRaises(TypeError):
- ranges[12.34] = newRange
+ ranges[12.34] = new_range
# Tests syntax:
# obj[key] = val # Replace by key
def test_XNameContainer_ReplaceName(self):
# Given
spr = self.createBlankSpreadsheet()
- ranges = spr.createInstance("com.sun.star.sheet.SheetCellRanges")
- newRange1 = spr.Sheets.getByIndex(0).getCellRangeByPosition(1, 2, 1, 2)
- newRange2 = spr.Sheets.getByIndex(0).getCellRangeByPosition(6, 6, 6, 6)
+ ranges = getSheetCellRangesInstance(spr)
+ new_range1 = spr.Sheets.getByIndex(0).getCellRangeByPosition(1, 2, 1, 2)
+ new_range2 = spr.Sheets.getByIndex(0).getCellRangeByPosition(6, 6, 6, 6)
# When
- ranges['foo'] = newRange1
- ranges['foo'] = newRange2
+ ranges['foo'] = new_range1
+ ranges['foo'] = new_range2
# Then
self.assertEqual(1, len(ranges.ElementNames))
- readRange = ranges['foo']
- self.assertEqual(6, readRange.CellAddress.Column)
+ read_range = ranges['foo']
+ self.assertEqual(6, read_range.CellAddress.Column)
# Tests syntax:
# del obj[key] # Delete by key
diff --git a/pyuno/qa/pytests/testcollections_XNameReplace.py b/pyuno/qa/pytests/testcollections_XNameReplace.py
index e8a405146094..2176f935d9dc 100644
--- a/pyuno/qa/pytests/testcollections_XNameReplace.py
+++ b/pyuno/qa/pytests/testcollections_XNameReplace.py
@@ -14,6 +14,9 @@ from testcollections_base import CollectionsTestBase
from com.sun.star.beans import PropertyValue
+def getScriptName():
+ return 'macro://Standard.Module1.MySave()'
+
# Tests behaviour of objects implementing XNameReplace using the new-style
# collection accessors
# The objects chosen have no special meaning, they just happen to implement the
@@ -28,15 +31,14 @@ class TestXNameReplace(CollectionsTestBase):
def test_XNameReplace_ReplaceName(self):
# Given
doc = self.createBlankTextDocument()
- scriptName = 'macro://Standard.Module1.MySave()'
- eventProperties = (PropertyValue(Name='Script', Value=scriptName),)
+ event_properties = (PropertyValue(Name='Script', Value=getScriptName()),)
# When
- doc.Events['OnSave'] = eventProperties
+ doc.Events['OnSave'] = event_properties
# Then
- onSave = [p.Value for p in doc.Events['OnSave'] if p.Name == 'Script'][0]
- self.assertEqual(scriptName, onSave)
+ on_save = [p.Value for p in doc.Events['OnSave'] if p.Name == 'Script'][0]
+ self.assertEqual(getScriptName(), on_save)
# Tests syntax:
# obj[key] = val # Replace by key
@@ -45,12 +47,11 @@ class TestXNameReplace(CollectionsTestBase):
def test_XNameReplace_ReplaceName_Invalid(self):
# Given
doc = self.createBlankTextDocument()
- scriptName = 'macro://Standard.Module1.MySave()'
- eventProperties = (PropertyValue(Name='Script', Value=scriptName),)
+ event_properties = (PropertyValue(Name='Script', Value=getScriptName()),)
# When / Then
with self.assertRaises(KeyError):
- doc.Events['qqqqq'] = eventProperties
+ doc.Events['qqqqq'] = event_properties
# Tests syntax:
# obj[key] = val # Replace by key
@@ -59,12 +60,11 @@ class TestXNameReplace(CollectionsTestBase):
def test_XNameReplace_ReplaceName_Invalid(self):
# Given
doc = self.createBlankTextDocument()
- scriptName = 'macro://Standard.Module1.MySave()'
- eventProperties = (PropertyValue(Name='Script', Value=scriptName),)
+ event_properties = (PropertyValue(Name='Script', Value=getScriptName()),)
# When / Then
with self.assertRaises(TypeError):
- doc.Events[12.34] = eventProperties
+ doc.Events[12.34] = event_properties
if __name__ == '__main__':
diff --git a/pyuno/qa/pytests/testcollections_base.py b/pyuno/qa/pytests/testcollections_base.py
index 8db14189f149..b3fcd2eb92f8 100644
--- a/pyuno/qa/pytests/testcollections_base.py
+++ b/pyuno/qa/pytests/testcollections_base.py
@@ -32,13 +32,13 @@ class CollectionsTestBase(unittest.TestCase):
pass
def createHiddenWindow(self, url):
- serviceManager = self.context.ServiceManager
- desktop = serviceManager.createInstanceWithContext('com.sun.star.frame.Desktop', self.context)
- loadProps = (
+ service_manager = self.context.ServiceManager
+ desktop = service_manager.createInstanceWithContext('com.sun.star.frame.Desktop', self.context)
+ load_props = (
PropertyValue(Name='Hidden', Value=True),
PropertyValue(Name='ReadOnly', Value=False)
)
- component = desktop.loadComponentFromURL(url, '_blank', 0, loadProps)
+ component = desktop.loadComponentFromURL(url, '_blank', 0, load_props)
return component
def createBlankTextDocument(self):
diff --git a/pyuno/qa/pytests/testcollections_mixednameindex.py b/pyuno/qa/pytests/testcollections_mixednameindex.py
index ac28f1032227..67e97a88dd90 100644
--- a/pyuno/qa/pytests/testcollections_mixednameindex.py
+++ b/pyuno/qa/pytests/testcollections_mixednameindex.py
@@ -26,20 +26,20 @@ class TestMixedNameIndex(CollectionsTestBase):
def testWriterTextTableNameAndIndex(self):
# Given
doc = self.createBlankTextDocument()
- textTable = doc.createInstance("com.sun.star.text.TextTable")
- textTable.initialize(2, 2)
- textTable.Name = 'foo'
+ text_table = doc.createInstance("com.sun.star.text.TextTable")
+ text_table.initialize(2, 2)
+ text_table.Name = 'foo'
cursor = doc.Text.createTextCursor()
- doc.Text.insertTextContent(cursor, textTable, False)
+ doc.Text.insertTextContent(cursor, text_table, False)
# When
- tableByName = doc.TextTables['foo']
- tableByIndex = doc.TextTables[0]
+ table_by_name = doc.TextTables['foo']
+ table_by_index = doc.TextTables[0]
# Then
- self.assertEqual('foo', tableByName.Name)
- self.assertEqual('foo', tableByIndex.Name)
- self.assertEqual(tableByName, tableByIndex)
+ self.assertEqual('foo', table_by_name.Name)
+ self.assertEqual('foo', table_by_index.Name)
+ self.assertEqual(table_by_name, table_by_index)
if __name__ == '__main__':