<commit_before>#!/usr/bin/python
'''Test cases for QFlags'''

import unittest
from PySide.QtCore import *

class QFLagTest(unittest.TestCase):
    '''Test case for usage of flags'''

    def testCallFunction(self):
        f = QFile("/tmp/t0");
        self.assertEqual(f.open(QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite), True)
        om = f.openMode()
        self.assertEqual(om & QIODevice.Truncate, QIODevice.Truncate)
        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()


if __name__ == '__main__':
    unittest.main()<commit_msg>Adding more tests for QFlags operators<commit_after>#!/usr/bin/python
'''Test cases for QFlags'''

import unittest
from PySide.QtCore import QIODevice, Qt, QFile

class QFLagTest(unittest.TestCase):
    '''Test case for usage of flags'''

    def testCallFunction(self):
        f = QFile("/tmp/t0");
        self.assertEqual(f.open(QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite), True)
        om = f.openMode()
        self.assertEqual(om & QIODevice.Truncate, QIODevice.Truncate)
        self.assertEqual(om & QIODevice.Text, QIODevice.Text)
        self.assertEqual(om & QIODevice.ReadWrite, QIODevice.ReadWrite)
        self.assert_(om == QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite)
        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()
{'fraction_non_alphanumeric': 0.12806539509536785, 'fraction_numerical': 0.0011677695601401323, 'mean_word_length': 3.220032840722496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3800807', 'n_tokens_mistral': 895, 'n_tokens_neox': 876, 'n_words': 160}