summaryrefslogtreecommitdiff
path: root/sc/qa/uitest/statistics
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-21 16:21:30 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-22 14:46:39 +0200
commitbe0a41679fea524e0935dc6617b5e65349812dd1 (patch)
treef14372226d5054c045f954e38ea09da5c412215b /sc/qa/uitest/statistics
parent14069d84174ca7a4e60db4d75912903e9679b643 (diff)
uitest: guard load_file
Mostly done by a script for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac < UITest: introduce guarded context managers > Change-Id: Ia924293dc2a12230fd13f69fd734875ced86be8a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117593 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa/uitest/statistics')
-rw-r--r--sc/qa/uitest/statistics/regression.py29
-rw-r--r--sc/qa/uitest/statistics/tdf76731.py89
2 files changed, 58 insertions, 60 deletions
diff --git a/sc/qa/uitest/statistics/regression.py b/sc/qa/uitest/statistics/regression.py
index 588b1bea77fc..0102df1f8f92 100644
--- a/sc/qa/uitest/statistics/regression.py
+++ b/sc/qa/uitest/statistics/regression.py
@@ -20,22 +20,21 @@ class regression(UITestCase):
self._regression_check(data_groupedby_column = True)
def _regression_check(self, data_groupedby_column = True):
- calc_doc = self.ui_test.load_file(get_url_for_data_file("regression.ods"))
- xCalcDoc = self.xUITest.getTopFocusWindow()
- gridwin = xCalcDoc.getChild("grid_window")
- document = self.ui_test.get_component()
+ with self.ui_test.load_file(get_url_for_data_file("regression.ods")) as calc_doc:
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
- # Initially the final check status is "FALSE" (failed).
- self.assertEqual(get_cell_by_position(document, 14, 1, 6).getString(), "FALSE",
- "Check status must be FALSE before the test")
- self._do_regression(regression_type = "LINEAR", data_groupedby_column = data_groupedby_column, calc_intercept = True)
- self._do_regression(regression_type = "LINEAR", data_groupedby_column = data_groupedby_column, calc_intercept = False)
- self._do_regression(regression_type = "LOG", data_groupedby_column = data_groupedby_column)
- self._do_regression(regression_type = "POWER", data_groupedby_column = data_groupedby_column)
- self.assertEqual(get_cell_by_position(document, 14, 1, 6).getString(), "TRUE",
- "One of more of the checks failed for data_groupedby_column = {}, manually try with the document".
- format(data_groupedby_column))
- self.ui_test.close_doc()
+ # Initially the final check status is "FALSE" (failed).
+ self.assertEqual(get_cell_by_position(document, 14, 1, 6).getString(), "FALSE",
+ "Check status must be FALSE before the test")
+ self._do_regression(regression_type = "LINEAR", data_groupedby_column = data_groupedby_column, calc_intercept = True)
+ self._do_regression(regression_type = "LINEAR", data_groupedby_column = data_groupedby_column, calc_intercept = False)
+ self._do_regression(regression_type = "LOG", data_groupedby_column = data_groupedby_column)
+ self._do_regression(regression_type = "POWER", data_groupedby_column = data_groupedby_column)
+ self.assertEqual(get_cell_by_position(document, 14, 1, 6).getString(), "TRUE",
+ "One of more of the checks failed for data_groupedby_column = {}, manually try with the document".
+ format(data_groupedby_column))
def _do_regression(self, regression_type, data_groupedby_column = True, calc_intercept = True):
assert(regression_type == "LINEAR" or regression_type == "LOG" or regression_type == "POWER")
diff --git a/sc/qa/uitest/statistics/tdf76731.py b/sc/qa/uitest/statistics/tdf76731.py
index 48db1ff350d2..12cecdab1832 100644
--- a/sc/qa/uitest/statistics/tdf76731.py
+++ b/sc/qa/uitest/statistics/tdf76731.py
@@ -17,52 +17,51 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
class anova(UITestCase):
def test_tdf76731_anova(self):
- calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf76731.ods"))
- xCalcDoc = self.xUITest.getTopFocusWindow()
- gridwin = xCalcDoc.getChild("grid_window")
- document = self.ui_test.get_component()
- #1. Open the attached sample document in Calc.
- #2. Select the data range, i.e. A1:C5.
- gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"}))
- #3. Choose Data - Analysis of Variance (ANOVA).
- #4. Choose an arbitrary output cell and click OK.
- self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- xinputrangeedit = xDialog.getChild("input-range-edit")
- xoutputrangeedit = xDialog.getChild("output-range-edit")
- xradiotwofactor = xDialog.getChild("radio-two-factor")
- xradiosinglefactor = xDialog.getChild("radio-single-factor")
- xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
- xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
- xalphaspin = xDialog.getChild("alpha-spin")
+ with self.ui_test.load_file(get_url_for_data_file("tdf76731.ods")) as calc_doc:
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+ #1. Open the attached sample document in Calc.
+ #2. Select the data range, i.e. A1:C5.
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"}))
+ #3. Choose Data - Analysis of Variance (ANOVA).
+ #4. Choose an arbitrary output cell and click OK.
+ self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ xinputrangeedit = xDialog.getChild("input-range-edit")
+ xoutputrangeedit = xDialog.getChild("output-range-edit")
+ xradiotwofactor = xDialog.getChild("radio-two-factor")
+ xradiosinglefactor = xDialog.getChild("radio-single-factor")
+ xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
+ xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
+ xalphaspin = xDialog.getChild("alpha-spin")
- xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
- xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
- xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"}))
- xradiosinglefactor.executeAction("CLICK", tuple())
- xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
- xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
- xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"}))
- xOKBtn = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(xOKBtn)
- #Verify, Table of results is shown, "F critical" cell has "#NAME?" error value.
- self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor")
- self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
- self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups")
- self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1")
- self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2")
- self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3")
- self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation")
- self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups")
- self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups")
- self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total")
+ xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"}))
+ xradiosinglefactor.executeAction("CLICK", tuple())
+ xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"}))
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+ #Verify, Table of results is shown, "F critical" cell has "#NAME?" error value.
+ self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total")
- self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical")
- self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),9), 3.885293835)
+ self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical")
+ self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),9), 3.885293835)
- #undo
- self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
+ #undo
+ self.xUITest.executeCommand(".uno:Undo")
+ self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
- self.ui_test.close_doc()
-# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file
+# vim: set shiftwidth=4 softtabstop=4 expandtab: