From e47b49f86d63845fe214768838c4fc7c55e3012a Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 8 Jun 2010 11:17:48 -0300 Subject: Re-add the possibility to run tests by module. --- tests/CMakeLists.txt | 5 ++- tests/QtCore/CMakeLists.txt | 3 +- tests/QtCore/thread_signals.py | 33 --------------- tests/QtCore/thread_signals_test.py | 33 +++++++++++++++ tests/QtGui/CMakeLists.txt | 4 +- tests/QtGui/virtual_pure_override.py | 48 ---------------------- tests/QtGui/virtual_pure_override_test.py | 48 ++++++++++++++++++++++ tests/QtGui/x11_symbols.py | 17 -------- tests/QtGui/x11_symbols_test.py | 17 ++++++++ tests/QtScript/CMakeLists.txt | 1 - tests/QtScript/test_base.py | 4 -- tests/signals/CMakeLists.txt | 2 +- tests/signals/signal_connectiontype_support.py | 28 ------------- .../signals/signal_connectiontype_support_test.py | 28 +++++++++++++ 14 files changed, 133 insertions(+), 138 deletions(-) delete mode 100644 tests/QtCore/thread_signals.py create mode 100644 tests/QtCore/thread_signals_test.py delete mode 100644 tests/QtGui/virtual_pure_override.py create mode 100644 tests/QtGui/virtual_pure_override_test.py delete mode 100644 tests/QtGui/x11_symbols.py create mode 100644 tests/QtGui/x11_symbols_test.py delete mode 100644 tests/QtScript/test_base.py delete mode 100755 tests/signals/signal_connectiontype_support.py create mode 100755 tests/signals/signal_connectiontype_support_test.py diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d87414fda..d446151de 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,8 @@ macro(TEST_QT_MODULE var name) endmacro(TEST_QT_MODULE) macro(PYSIDE_TEST) - set(TEST_NAME ${ARGV0}) + string(REGEX MATCH "/([^/]+)//?([^/]+)\\.py" foo "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}" ) + set(TEST_NAME "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") if (${ARGC} EQUAL 1) set(EXPECT_TO_FAIL 0) elseif(${ARGC} EQUAL 2) @@ -15,7 +16,7 @@ macro(PYSIDE_TEST) else() message(WARNING "Ivalid call of macro PYSIDE_TEST") endif() - set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}") + set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") add_test(${TEST_NAME} ${TEST_CMD}) set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT ${PYSIDE_TIMEOUT} diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 4a78bf6ae..cce1332ce 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -57,10 +57,9 @@ PYSIDE_TEST(qtnamespace_test.py) PYSIDE_TEST(qurl_test.py) PYSIDE_TEST(qvariant_pyobject_test.py) PYSIDE_TEST(qvariant_test.py) -PYSIDE_TEST(resources_mc.py) PYSIDE_TEST(static_method_test.py) PYSIDE_TEST(static_protected_methods_test.py) -PYSIDE_TEST(thread_signals.py) +PYSIDE_TEST(thread_signals_test.py) PYSIDE_TEST(translation_test.py) PYSIDE_TEST(unaryoperator_test.py) PYSIDE_TEST(unicode_test.py) diff --git a/tests/QtCore/thread_signals.py b/tests/QtCore/thread_signals.py deleted file mode 100644 index 9eea82907..000000000 --- a/tests/QtCore/thread_signals.py +++ /dev/null @@ -1,33 +0,0 @@ - -''' Test case for QObject.signalsBlocked() and blockSignal()''' - -import unittest -import os -from tempfile import mkstemp - -from PySide.QtCore import QObject, SIGNAL, QFile, QThread, QTimer, Qt -from helper import UsesQCoreApplication - -class MyThread(QThread): - - def run(self): - self.emit(SIGNAL("test(const QString&)"), "INdT - PySide"); - -class TestThreadSignal(UsesQCoreApplication): - - __called__ = True - def _callback(self, msg): - self.assertEqual(msg, "INdT - PySide") - self.__called__ = True - self.app.quit() - - def testThread(self): - t = MyThread() - QObject.connect(t, SIGNAL("test(const QString&)"), self._callback); - t.start() - - self.app.exec_() - self.assert_(self.__called__); - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtCore/thread_signals_test.py b/tests/QtCore/thread_signals_test.py new file mode 100644 index 000000000..9eea82907 --- /dev/null +++ b/tests/QtCore/thread_signals_test.py @@ -0,0 +1,33 @@ + +''' Test case for QObject.signalsBlocked() and blockSignal()''' + +import unittest +import os +from tempfile import mkstemp + +from PySide.QtCore import QObject, SIGNAL, QFile, QThread, QTimer, Qt +from helper import UsesQCoreApplication + +class MyThread(QThread): + + def run(self): + self.emit(SIGNAL("test(const QString&)"), "INdT - PySide"); + +class TestThreadSignal(UsesQCoreApplication): + + __called__ = True + def _callback(self, msg): + self.assertEqual(msg, "INdT - PySide") + self.__called__ = True + self.app.quit() + + def testThread(self): + t = MyThread() + QObject.connect(t, SIGNAL("test(const QString&)"), self._callback); + t.start() + + self.app.exec_() + self.assert_(self.__called__); + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index fb6d8015b..fa5de4a2c 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -53,6 +53,6 @@ PYSIDE_TEST(reference_count_test.py) PYSIDE_TEST(standardpixmap_test.py) PYSIDE_TEST(timed_app_test.py) PYSIDE_TEST(virtual_protected_inheritance_test.py) -PYSIDE_TEST(virtual_pure_override.py) +PYSIDE_TEST(virtual_pure_override_test.py) PYSIDE_TEST(wrong_return_test.py) -PYSIDE_TEST(x11_symbols.py) +PYSIDE_TEST(x11_symbols_test.py) diff --git a/tests/QtGui/virtual_pure_override.py b/tests/QtGui/virtual_pure_override.py deleted file mode 100644 index c496e4907..000000000 --- a/tests/QtGui/virtual_pure_override.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python - -import unittest - -from PySide.QtGui import QGraphicsScene, QGraphicsRectItem, QGraphicsView, QApplication, QBrush, QColor -from PySide.QtCore import QTimer -from helper import UsesQApplication - -qgraphics_item_painted = False - -class RoundRectItem(QGraphicsRectItem): - - def __init__(self, x, y, w, h): - QGraphicsRectItem.__init__(self, x, y, w, h) - - def paint(self, painter, qstyleoptiongraphicsitem, qwidget): - global qgraphics_item_painted - qgraphics_item_painted = True - - -class QGraphicsItemTest(UsesQApplication): - - def createRoundRect(self, scene): - item = RoundRectItem(10, 10, 100, 100) - item.setBrush(QBrush(QColor(255, 0, 0))) - scene.addItem(item) - return item - - def quit_app(self): - self.app.quit() - - def test_setParentItem(self): - global qgraphics_item_painted - - scene = QGraphicsScene() - scene.addText("test") - view = QGraphicsView(scene) - - rect = self.createRoundRect(scene) - view.show() - QTimer.singleShot(1000, self.quit_app) - self.app.exec_() - self.assert_(qgraphics_item_painted) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/QtGui/virtual_pure_override_test.py b/tests/QtGui/virtual_pure_override_test.py new file mode 100644 index 000000000..c496e4907 --- /dev/null +++ b/tests/QtGui/virtual_pure_override_test.py @@ -0,0 +1,48 @@ +#!/usr/bin/python + +import unittest + +from PySide.QtGui import QGraphicsScene, QGraphicsRectItem, QGraphicsView, QApplication, QBrush, QColor +from PySide.QtCore import QTimer +from helper import UsesQApplication + +qgraphics_item_painted = False + +class RoundRectItem(QGraphicsRectItem): + + def __init__(self, x, y, w, h): + QGraphicsRectItem.__init__(self, x, y, w, h) + + def paint(self, painter, qstyleoptiongraphicsitem, qwidget): + global qgraphics_item_painted + qgraphics_item_painted = True + + +class QGraphicsItemTest(UsesQApplication): + + def createRoundRect(self, scene): + item = RoundRectItem(10, 10, 100, 100) + item.setBrush(QBrush(QColor(255, 0, 0))) + scene.addItem(item) + return item + + def quit_app(self): + self.app.quit() + + def test_setParentItem(self): + global qgraphics_item_painted + + scene = QGraphicsScene() + scene.addText("test") + view = QGraphicsView(scene) + + rect = self.createRoundRect(scene) + view.show() + QTimer.singleShot(1000, self.quit_app) + self.app.exec_() + self.assert_(qgraphics_item_painted) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/x11_symbols.py b/tests/QtGui/x11_symbols.py deleted file mode 100644 index 29cce150e..000000000 --- a/tests/QtGui/x11_symbols.py +++ /dev/null @@ -1,17 +0,0 @@ - -''' Test the presence of X11 symbols in QtGui''' - -import unittest - -from PySide.QtGui import QPixmap - -class X11Test(unittest.TestCase): - - def test(self): - self.assert_('handle' in dir(QPixmap)) - self.assert_('x11Info' in dir(QPixmap)) - self.assert_('x11PictureHandle' in dir(QPixmap)) - self.assert_('x11SetDefaultScreen' in dir(QPixmap)) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtGui/x11_symbols_test.py b/tests/QtGui/x11_symbols_test.py new file mode 100644 index 000000000..29cce150e --- /dev/null +++ b/tests/QtGui/x11_symbols_test.py @@ -0,0 +1,17 @@ + +''' Test the presence of X11 symbols in QtGui''' + +import unittest + +from PySide.QtGui import QPixmap + +class X11Test(unittest.TestCase): + + def test(self): + self.assert_('handle' in dir(QPixmap)) + self.assert_('x11Info' in dir(QPixmap)) + self.assert_('x11PictureHandle' in dir(QPixmap)) + self.assert_('x11SetDefaultScreen' in dir(QPixmap)) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtScript/CMakeLists.txt b/tests/QtScript/CMakeLists.txt index b76a26299..e496591c7 100644 --- a/tests/QtScript/CMakeLists.txt +++ b/tests/QtScript/CMakeLists.txt @@ -1,3 +1,2 @@ PYSIDE_TEST(base_test.py) PYSIDE_TEST(engine_test.py) -PYSIDE_TEST(test_base.py) diff --git a/tests/QtScript/test_base.py b/tests/QtScript/test_base.py deleted file mode 100644 index 6ad27e007..000000000 --- a/tests/QtScript/test_base.py +++ /dev/null @@ -1,4 +0,0 @@ -from PySide import QtScript - - -#only test if the module import works fine bug #278 diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt index 3e5968449..a6d564ff5 100644 --- a/tests/signals/CMakeLists.txt +++ b/tests/signals/CMakeLists.txt @@ -20,7 +20,7 @@ PYSIDE_TEST(self_connect_test.py) PYSIDE_TEST(short_circuit_test.py) PYSIDE_TEST(signal2signal_connect_test.py) PYSIDE_TEST(signal_autoconnect_test.py) -PYSIDE_TEST(signal_connectiontype_support.py) +PYSIDE_TEST(signal_connectiontype_support_test.py) PYSIDE_TEST(signal_emission_gui_test.py) PYSIDE_TEST(signal_emission_test.py) PYSIDE_TEST(signal_func_test.py) diff --git a/tests/signals/signal_connectiontype_support.py b/tests/signals/signal_connectiontype_support.py deleted file mode 100755 index d0c35c53a..000000000 --- a/tests/signals/signal_connectiontype_support.py +++ /dev/null @@ -1,28 +0,0 @@ - -import unittest - -from PySide.QtCore import QObject, SIGNAL, Qt - -class Dummy(QObject): - """Dummy class used in this test.""" - def __init__(self, parent=None): - QObject.__init__(self, parent) - -class TestConnectionTypeSupport(unittest.TestCase): - def callback(self, *args): - if tuple(self.args) == args: - self.called = True - - def testNoArgs(self): - """Connect signal using a Qt.ConnectionType as argument""" - obj1 = Dummy() - - QObject.connect(obj1, SIGNAL('foo'), self.callback, Qt.DirectConnection) - self.args = tuple() - obj1.emit(SIGNAL('foo'), *self.args) - - self.assert_(self.called) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/signals/signal_connectiontype_support_test.py b/tests/signals/signal_connectiontype_support_test.py new file mode 100755 index 000000000..d0c35c53a --- /dev/null +++ b/tests/signals/signal_connectiontype_support_test.py @@ -0,0 +1,28 @@ + +import unittest + +from PySide.QtCore import QObject, SIGNAL, Qt + +class Dummy(QObject): + """Dummy class used in this test.""" + def __init__(self, parent=None): + QObject.__init__(self, parent) + +class TestConnectionTypeSupport(unittest.TestCase): + def callback(self, *args): + if tuple(self.args) == args: + self.called = True + + def testNoArgs(self): + """Connect signal using a Qt.ConnectionType as argument""" + obj1 = Dummy() + + QObject.connect(obj1, SIGNAL('foo'), self.callback, Qt.DirectConnection) + self.args = tuple() + obj1.emit(SIGNAL('foo'), *self.args) + + self.assert_(self.called) + + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3