aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-01-19 13:46:40 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:51:47 -0300
commit3e0b9e52deae29e6e7e463603db9a5f5847e826a (patch)
treecd0a1959c70e28228d6eaf5a5fe170506b98b66a /tests
parent4f72f1d3686a1bf3a249b5b3265d8e10e24014cf (diff)
Added test for module reloading.
Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/pyside_reload_test.py42
-rw-r--r--tests/QtGui/test_module_template.py9
3 files changed, 52 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 47d612c49..3d6c11e2b 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -39,6 +39,7 @@ PYSIDE_TEST(keep_reference_test.py)
PYSIDE_TEST(missing_symbols_test.py)
PYSIDE_TEST(paint_event_test.py)
PYSIDE_TEST(parent_method_test.py)
+PYSIDE_TEST(pyside_reload_test.py)
PYSIDE_TEST(python_properties_test.py)
PYSIDE_TEST(qabstracttextdocumentlayout_test.py)
PYSIDE_TEST(qapplication_exit_segfault_test.py)
diff --git a/tests/QtGui/pyside_reload_test.py b/tests/QtGui/pyside_reload_test.py
new file mode 100644
index 000000000..ca12b8ba8
--- /dev/null
+++ b/tests/QtGui/pyside_reload_test.py
@@ -0,0 +1,42 @@
+import os
+import sys
+import shutil
+import unittest
+
+orig_path = os.path.join(os.path.dirname(__file__))
+workdir = os.getcwd()
+src = os.path.join(orig_path, 'test_module_template.py')
+dst = os.path.join(workdir, 'test_module.py')
+shutil.copyfile(src, dst)
+sys.path.append(workdir)
+
+def increment_module_value():
+ modfile = open(dst, 'a')
+ modfile.write('MyQWidget.value += 1' + os.linesep)
+ modfile.flush()
+ modfile.close()
+ os.remove(dst + 'c')
+
+class TestModuleReloading(unittest.TestCase):
+
+ def testModuleReloading(self):
+ '''Test module reloading with on-the-fly modifications.'''
+
+ import test_module
+ self.assertEqual(test_module.MyQWidget.value, 10)
+
+ increment_module_value()
+ reload(sys.modules['test_module'])
+ self.assertEqual(test_module.MyQWidget.value, 11)
+
+ reload(sys.modules['test_module'])
+ self.assertEqual(test_module.MyQWidget.value, 11)
+
+ increment_module_value()
+ reload(sys.modules['test_module'])
+ self.assertEqual(test_module.MyQWidget.value, 12)
+
+if __name__ == "__main__":
+ unittest.main()
+
+
diff --git a/tests/QtGui/test_module_template.py b/tests/QtGui/test_module_template.py
new file mode 100644
index 000000000..fb72a978d
--- /dev/null
+++ b/tests/QtGui/test_module_template.py
@@ -0,0 +1,9 @@
+from PySide.QtGui import *
+from PySide.QtCore import *
+
+class MyQObject(QObject):
+ pass
+
+class MyQWidget(QWidget):
+ value = 10
+