aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-02-22 18:21:50 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-02-24 10:16:11 -0300
commite78d11c683db8551628d0259f72390cfd930e965 (patch)
treee323abb0408238f6aa72a213b26d58d479060c9e /tests
parentb12189b3de7f63d1d0168d82808b72ce3cb97dc8 (diff)
Adding more tests for QFlags operators
Diffstat (limited to 'tests')
-rw-r--r--tests/qtcore/qflags_test.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/qtcore/qflags_test.py b/tests/qtcore/qflags_test.py
index 6290926d7..3eb767217 100644
--- a/tests/qtcore/qflags_test.py
+++ b/tests/qtcore/qflags_test.py
@@ -2,7 +2,7 @@
'''Test cases for QFlags'''
import unittest
-from PySide.QtCore import *
+from PySide.QtCore import QIODevice, Qt, QFile
class QFLagTest(unittest.TestCase):
'''Test case for usage of flags'''
@@ -15,9 +15,38 @@ class QFLagTest(unittest.TestCase):
self.assertEqual(om & QIODevice.Text, QIODevice.Text)
self.assertEqual(om & QIODevice.ReadWrite, QIODevice.ReadWrite)
self.assert_(om == QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite)
- print (om != QIODevice.ReadOnly)
f.close()
+class QFlagOperatorTest(unittest.TestCase):
+ '''Test case for operators in QFlags'''
+
+ def testInvert(self):
+ '''QFlags ~ (invert) operator'''
+ self.assert_(isinstance(~QIODevice.ReadOnly, QIODevice.OpenMode))
+
+ def testOr(self):
+ '''QFlags | (or) operator'''
+ self.assert_(isinstance(QIODevice.ReadOnly | QIODevice.WriteOnly, QIODevice.OpenMode))
+
+ def testAnd(self):
+ '''QFlags & (and) operator'''
+ self.assert_(isinstance(QIODevice.ReadOnly & QIODevice.WriteOnly, QIODevice.OpenMode))
+
+ def testIOr(self):
+ '''QFlags |= (ior) operator'''
+ flag = Qt.WindowFlags()
+ self.assert_(flag & Qt.Widget == 0)
+ flag |= Qt.WindowMinimizeButtonHint
+ self.assert_(flag & Qt.WindowMinimizeButtonHint)
+
+ def testEqual(self):
+ '''QFlags == operator'''
+ flags = Qt.Window
+ flags |= Qt.WindowMinimizeButtonHint
+ flag_type = (flags & Qt.WindowType_Mask)
+ self.assertEqual(flag_type, Qt.Window)
+
+
if __name__ == '__main__':
unittest.main()