diff options
Diffstat (limited to 'sources/pyside2/tests/QtCore/qflags_test.py')
-rw-r--r-- | sources/pyside2/tests/QtCore/qflags_test.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sources/pyside2/tests/QtCore/qflags_test.py b/sources/pyside2/tests/QtCore/qflags_test.py index 7d558424e..e1e989c1e 100644 --- a/sources/pyside2/tests/QtCore/qflags_test.py +++ b/sources/pyside2/tests/QtCore/qflags_test.py @@ -30,7 +30,15 @@ '''Test cases for QFlags''' +import operator +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import Qt, QTemporaryFile, QFile, QIODevice, QObject class QFlagTest(unittest.TestCase): @@ -110,12 +118,13 @@ class QFlagsOnQVariant(unittest.TestCase): class QFlagsWrongType(unittest.TestCase): def testWrongType(self): '''Wrong type passed to QFlags binary operators''' + for op in operator.or_, operator.and_, operator.xor: + for x in '43', 'jabba', QObject, object: + self.assertRaises(TypeError, op, Qt.NoItemFlags, x) + self.assertRaises(TypeError, op, x, Qt.NoItemFlags) + # making sure this actually does not fail all the time + self.assertEqual(operator.or_(Qt.NoItemFlags, 43), 43) - self.assertRaises(TypeError, Qt.NoItemFlags | '43') - self.assertRaises(TypeError, Qt.NoItemFlags & '43') - self.assertRaises(TypeError, 'jabba' & Qt.NoItemFlags) - self.assertRaises(TypeError, 'hut' & Qt.NoItemFlags) - self.assertRaises(TypeError, Qt.NoItemFlags & QObject()) if __name__ == '__main__': unittest.main() |