summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2013-03-30 22:10:48 +0100
committerDavid Ostrovsky <David.Ostrovsky@gmx.de>2013-04-09 05:52:23 +0000
commit0e68bac85293e2d60fa6db3e46de8b74ab5d502b (patch)
tree17b4edeb6bfbce3724de003a87718d6b8f895642 /sw
parentd64b5cc1c3d232ba42479fe0a3c186ecabd25144 (diff)
set up python unit test infrastructure
Extract boostraping code from convwatch.py to unotest.py. Use python builtin unittest module as unit test framework. Specify the unit test modules in make file. Another option would be to use discover mode of unittest module. Add __pycache__ to global .gitignore to keep the source directory clean. Another option would be to deliver the unit tests to workdir prior to test execution. Currently only system python3 is supported. Change-Id: I2692817673f786e950e1176a17c7675f989755b6 Reviewed-on: https://gerrit.libreoffice.org/3214 Reviewed-by: David Ostrovsky <David.Ostrovsky@gmx.de> Tested-by: David Ostrovsky <David.Ostrovsky@gmx.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/Module_sw.mk9
-rw-r--r--sw/PythonTest_sw_unoapi.mk17
-rw-r--r--sw/qa/unoapi/python/get_expression.py53
-rw-r--r--sw/qa/unoapi/python/set_expression.py40
4 files changed, 119 insertions, 0 deletions
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index d11f167bc920..2f6e75b00b94 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -66,4 +66,13 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sw,\
))
endif
+# TODO: FixMe restrict to system python
+ifneq ($(DISABLE_PYTHON),TRUE)
+ifeq ($(SYSTEM_PYTHON),YES)
+$(eval $(call gb_Module_add_subsequentcheck_targets,sw,\
+ PythonTest_sw_unoapi \
+))
+endif
+endif
+
# vim: set noet sw=4 ts=4:
diff --git a/sw/PythonTest_sw_unoapi.mk b/sw/PythonTest_sw_unoapi.mk
new file mode 100644
index 000000000000..de486effec9a
--- /dev/null
+++ b/sw/PythonTest_sw_unoapi.mk
@@ -0,0 +1,17 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# 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/.
+#
+
+$(eval $(call gb_PythonTest_PythonTest,sw_unoapi))
+
+$(eval $(call gb_PythonTest_add_classes,sw_unoapi,\
+ $(SRCDIR)/sw/qa/unoapi/python/set_expression.py \
+ $(SRCDIR)/sw/qa/unoapi/python/get_expression.py \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/qa/unoapi/python/get_expression.py b/sw/qa/unoapi/python/get_expression.py
new file mode 100644
index 000000000000..277d3cfa5ba9
--- /dev/null
+++ b/sw/qa/unoapi/python/get_expression.py
@@ -0,0 +1,53 @@
+import unittest
+from org.libreoffice.unotest import UnoConnection
+
+class TestGetExpression(unittest.TestCase):
+ _unoCon = None
+ _xDoc = None
+
+ @classmethod
+ def setUpClass(cls):
+ cls._unoCon = UnoConnection({})
+ cls._unoCon.setUp()
+ cls._xDoc = cls._unoCon.openEmptyWriterDoc()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls._unoCon.tearDown()
+
+ def test_get_expression(self):
+ self.__class__._unoCon.checkProperties(
+ self.__class__._xDoc.createInstance("com.sun.star.text.textfield.GetExpression"),
+ {"Content": "foo",
+ "CurrentPresentation": "bar",
+ "NumberFormat": 0,
+ "IsShowFormula": False,
+ "SubType": 0,
+ "VariableSubtype": 1,
+ "IsFixedLanguage": False,
+ },
+ self
+ )
+
+ # property 'Value' is read only?
+ @unittest.expectedFailure
+ def test_get_expression_veto_read_only(self):
+ self.__class__._unoCon.checkProperties(
+ self.__class__._xDoc.createInstance("com.sun.star.text.textfield.GetExpression"),
+ {"Value": 0.0},
+ self
+ )
+
+ # property 'NumberingType' is unknown?
+ @unittest.expectedFailure
+ def test_get_expression_unknown_property(self):
+ self.__class__._unoCon.checkProperties(
+ self.__class__._xDoc.createInstance("com.sun.star.text.textfield.GetExpression"),
+ {"NumberingType": 0},
+ self
+ )
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sw/qa/unoapi/python/set_expression.py b/sw/qa/unoapi/python/set_expression.py
new file mode 100644
index 000000000000..8f6d19e26396
--- /dev/null
+++ b/sw/qa/unoapi/python/set_expression.py
@@ -0,0 +1,40 @@
+import unittest
+from org.libreoffice.unotest import UnoConnection
+
+#@unittest.skip("that seems to work")
+class TestSetExpresion(unittest.TestCase):
+ _unoCon = None
+ _xDoc = None
+
+ @classmethod
+ def setUpClass(cls):
+ cls._unoCon = UnoConnection({})
+ cls._unoCon.setUp()
+ cls._xDoc = cls._unoCon.openEmptyWriterDoc()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls._unoCon.tearDown()
+
+ def test_set_expression(self):
+ self.__class__._unoCon.checkProperties(
+ self.__class__._xDoc.createInstance("com.sun.star.text.textfield.SetExpression"),
+ {"NumberingType": 0,
+ "Content": "foo",
+ "CurrentPresentation": "bar",
+ "NumberFormat": 0,
+ "NumberingType": 0,
+ "IsShowFormula": False,
+ "IsInput": False,
+ "IsVisible": True,
+ "SequenceValue": 0,
+ "SubType": 0,
+ "Value": 1.0,
+ "IsFixedLanguage": False
+ },
+ self
+ )
+
+if __name__ == '__main__':
+ unittest.main()
+