Kaydet (Commit) ea3661e6 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

move check_table/fill_table from inner f. to priv. member fnct.

Change-Id: I7670f8164d8a44414277f285e3aa19de1764a86e
üst ea35a682
...@@ -248,15 +248,15 @@ class CheckTable(unittest.TestCase): ...@@ -248,15 +248,15 @@ class CheckTable(unittest.TestCase):
# close document # close document
xDoc.dispose() xDoc.dispose()
def _fill_table(self, xTable):
for x in range(3):
for y in range(3):
xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
def _check_table(self, xTable):
for x in range(3):
for y in range(3):
self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
def test_descriptions(self): def test_descriptions(self):
def fill_table():
for x in range(3):
for y in range(3):
xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
def check_table():
for x in range(3):
for y in range(3):
self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
xDoc = CheckTable._uno.openEmptyWriterDoc() xDoc = CheckTable._uno.openEmptyWriterDoc()
# insert table # insert table
xTable = xDoc.createInstance("com.sun.star.text.TextTable") xTable = xDoc.createInstance("com.sun.star.text.TextTable")
...@@ -266,8 +266,8 @@ class CheckTable(unittest.TestCase): ...@@ -266,8 +266,8 @@ class CheckTable(unittest.TestCase):
self.assertEqual(3, xTable.Rows.Count) self.assertEqual(3, xTable.Rows.Count)
self.assertEqual(3, xTable.Columns.Count) self.assertEqual(3, xTable.Columns.Count)
# fill table # fill table
fill_table() self._fill_table(xTable)
check_table() self._check_table(xTable)
# check without labels first # check without labels first
xTable.ChartColumnAsLabel = False xTable.ChartColumnAsLabel = False
xTable.ChartRowAsLabel = False xTable.ChartRowAsLabel = False
...@@ -275,7 +275,7 @@ class CheckTable(unittest.TestCase): ...@@ -275,7 +275,7 @@ class CheckTable(unittest.TestCase):
self.assertEqual(0, len(xTable.ColumnDescriptions)) self.assertEqual(0, len(xTable.ColumnDescriptions))
self.RowDescriptions = ('foo', 'bar', 'baz') # no labels, thus noop self.RowDescriptions = ('foo', 'bar', 'baz') # no labels, thus noop
self.ColumnDescriptions = ('foo', 'bar', 'baz') # no labels, thus noop self.ColumnDescriptions = ('foo', 'bar', 'baz') # no labels, thus noop
check_table() self._check_table(xTable)
# now check with labels # now check with labels
xTable.ChartColumnAsLabel = True xTable.ChartColumnAsLabel = True
xTable.ChartRowAsLabel = True xTable.ChartRowAsLabel = True
...@@ -289,7 +289,7 @@ class CheckTable(unittest.TestCase): ...@@ -289,7 +289,7 @@ class CheckTable(unittest.TestCase):
xTable.RowDescriptions = ('foo',) # too short xTable.RowDescriptions = ('foo',) # too short
with self.assertRaises(Exception): with self.assertRaises(Exception):
xTable.ColumnDescriptions = ('foo',) # too short xTable.ColumnDescriptions = ('foo',) # too short
check_table() self._check_table(xTable)
xTable.RowDescriptions = ('fooRow', 'bazRow') xTable.RowDescriptions = ('fooRow', 'bazRow')
xTable.ColumnDescriptions = ('fooColumn', 'bazColumn') xTable.ColumnDescriptions = ('fooColumn', 'bazColumn')
self.assertEqual('fooRow', xTable.getCellByPosition(0,1).String) self.assertEqual('fooRow', xTable.getCellByPosition(0,1).String)
...@@ -300,7 +300,7 @@ class CheckTable(unittest.TestCase): ...@@ -300,7 +300,7 @@ class CheckTable(unittest.TestCase):
xTable.getCellByPosition(0,2).String = 'Cell 0 2' xTable.getCellByPosition(0,2).String = 'Cell 0 2'
xTable.getCellByPosition(1,0).String = 'Cell 1 0' xTable.getCellByPosition(1,0).String = 'Cell 1 0'
xTable.getCellByPosition(2,0).String = 'Cell 2 0' xTable.getCellByPosition(2,0).String = 'Cell 2 0'
check_table() # ... to ensure the rest was untouched self._check_table(xTable) # ... to ensure the rest was untouched
# check disconnected table excepts, but doesnt crash # check disconnected table excepts, but doesnt crash
xTable2 = xDoc.createInstance("com.sun.star.text.TextTable") xTable2 = xDoc.createInstance("com.sun.star.text.TextTable")
xTable2.initialize(3, 3) xTable2.initialize(3, 3)
......
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