<commit_before>import unittest
import warnings

from common import gobject, atk, pango, gtk, gdk

class EnumTest(unittest.TestCase):
    def testEnums(self):
        assert issubclass(gobject.GEnum, int)
        assert isinstance(atk.LAYER_OVERLAY, atk.Layer)
        assert isinstance(atk.LAYER_OVERLAY, int)
        assert 'LAYER_OVERLAY' in repr(atk.LAYER_OVERLAY)
        assert int(atk.LAYER_OVERLAY)
        assert atk.LAYER_INVALID == 0
        assert atk.LAYER_INVALID != 1
        assert atk.LAYER_INVALID != -1
        assert atk.LAYER_INVALID != atk.LAYER_BACKGROUND

    def testComparisionWarning(self):
        warnings.filterwarnings("error", "", Warning, "", 0)
        try:
            assert atk.LAYER_INVALID != atk.RELATION_NULL
        except Warning:
            pass
        else:
            raise AssertionError
        warnings.resetwarnings()

    def testWindowGetState(self):
        win = gtk.Window()
        win.realize()

        state = win.window.get_state()
        assert state == gdk.WINDOW_STATE_WITHDRAWN
        assert isinstance(state, gdk.WindowState)
        assert 'WINDOW_STATE_WITHDRAWN' in repr(state)

    def testProperty(self):
        win = gtk.Window()

        wtype = win.get_property('type')
        assert wtype == gtk.WINDOW_TOPLEVEL
        assert isinstance(wtype, gtk.WindowType)
        assert 'WINDOW_TOPLEVEL' in repr(wtype)

    def testAtkObj(self):
        obj = atk.NoOpObject(gobject.GObject())
        assert obj.get_role() == atk.ROLE_INVALID

    def testGParam(self):
        win = gtk.Window()
        enums = filter(lambda x: gobject.type_is_a(x.value_type, gobject.GEnum),
                       gobject.list_properties(win))
        assert enums
        enum = enums[0]
        assert hasattr(enum, 'enum_class')
        assert issubclass(enum.enum_class, gobject.GEnum)

    def testWeirdEnumValues(self):
        assert int(gdk.NOTHING) == -1
        assert int(gdk.BUTTON_PRESS) == 4

    def testParamSpec(self):
        props = filter(lambda prop: gobject.type_is_a(prop.value_type, gobject.GEnum),
                       gobject.list_properties(gtk.Window))
        assert len(props)>= 6
        props = filter(lambda prop: prop.name == 'type', props)
        assert props
        prop = props[0]
        klass = prop.enum_class
        assert klass == gtk.WindowType
        assert hasattr(klass, '__enum_values__')
        assert isinstance(klass.__enum_values__, dict)
        assert len(klass.__enum_values__) >= 2

    def testOutofBounds(self):
        gtk.icon_size_register('fake', 24, 24)
        
class FlagsTest(unittest.TestCase):
    def testFlags(self):
        assert issubclass(gobject.GFlags, int)
        assert isinstance(gdk.BUTTON_PRESS_MASK, gdk.EventMask)
        assert isinstance(gdk.BUTTON_PRESS_MASK, int)
        assert gdk.BUTTON_PRESS_MASK == 256
        assert gdk.BUTTON_PRESS_MASK != 0
        assert gdk.BUTTON_PRESS_MASK != -256
        assert gdk.BUTTON_PRESS_MASK != gdk.BUTTON_RELEASE_MASK

        assert gdk.EventMask.__bases__[0] == gobject.GFlags
        assert len(gdk.EventMask.__flags_values__) == 22

    def testComparisionWarning(self):
        warnings.filterwarnings("error", "", Warning, "", 0)
        try:
            assert gtk.ACCEL_VISIBLE != gtk.EXPAND
        except Warning:
            pass
        else:
            raise AssertionError
        warnings.resetwarnings()<commit_msg>Use methflags argument for defines instead of discarding it<commit_after>import unittest
import warnings

from common import gobject, atk, pango, gtk, gdk

class EnumTest(unittest.TestCase):
    def testEnums(self):
        assert issubclass(gobject.GEnum, int)
        assert isinstance(atk.LAYER_OVERLAY, atk.Layer)
        assert isinstance(atk.LAYER_OVERLAY, int)
        assert 'LAYER_OVERLAY' in repr(atk.LAYER_OVERLAY)
        assert int(atk.LAYER_OVERLAY)
        assert atk.LAYER_INVALID == 0
        assert atk.LAYER_INVALID != 1
        assert atk.LAYER_INVALID != -1
        assert atk.LAYER_INVALID != atk.LAYER_BACKGROUND

    def testComparisionWarning(self):
        warnings.filterwarnings("error", "", Warning, "", 0)
        try:
            assert atk.LAYER_INVALID != atk.RELATION_NULL
        except Warning:
            pass
        else:
            raise AssertionError
        warnings.resetwarnings()

    def testWindowGetState(self):
        win = gtk.Window()
        win.realize()

        state = win.window.get_state()
        assert state == gdk.WINDOW_STATE_WITHDRAWN
        assert isinstance(state, gdk.WindowState)
        assert 'WINDOW_STATE_WITHDRAWN' in repr(state)

    def testProperty(self):
        win = gtk.Window()

        wtype = win.get_property('type')
        assert wtype == gtk.WINDOW_TOPLEVEL
        assert isinstance(wtype, gtk.WindowType)
        assert 'WINDOW_TOPLEVEL' in repr(wtype)

    def testAtkObj(self):
        obj = atk.NoOpObject(gobject.GObject())
        assert obj.get_role() == atk.ROLE_INVALID

    def testGParam(self):
        win = gtk.Window()
        enums = filter(lambda x: gobject.type_is_a(x.value_type, gobject.GEnum),
                       gobject.list_properties(win))
        assert enums
        enum = enums[0]
        assert hasattr(enum, 'enum_class')
        assert issubclass(enum.enum_class, gobject.GEnum)

    def testWeirdEnumValues(self):
        assert int(gdk.NOTHING) == -1
        assert int(gdk.BUTTON_PRESS) == 4

    def testParamSpec(self):
        props = filter(lambda prop: gobject.type_is_a(prop.value_type, gobject.GEnum),
                       gobject.list_properties(gtk.Window))
        assert len(props)>= 6
        props = filter(lambda prop: prop.name == 'type', props)
        assert props
        prop = props[0]
        klass = prop.enum_class
        assert klass == gtk.WindowType
        assert hasattr(klass, '__enum_values__')
        assert isinstance(klass.__enum_values__, dict)
        assert len(klass.__enum_values__) >= 2

    def testOutofBounds(self):
        assert gtk.icon_size_register('fake', 24, 24) == 7
        
class FlagsTest(unittest.TestCase):
    def testFlags(self):
        assert issubclass(gobject.GFlags, int)
        assert isinstance(gdk.BUTTON_PRESS_MASK, gdk.EventMask)
        assert isinstance(gdk.BUTTON_PRESS_MASK, int)
        assert gdk.BUTTON_PRESS_MASK == 256
        assert gdk.BUTTON_PRESS_MASK != 0
        assert gdk.BUTTON_PRESS_MASK != -256
        assert gdk.BUTTON_PRESS_MASK != gdk.BUTTON_RELEASE_MASK

        assert gdk.EventMask.__bases__[0] == gobject.GFlags
        assert len(gdk.EventMask.__flags_values__) == 22

    def testComparisionWarning(self):
        warnings.filterwarnings("error", "", Warning, "", 0)
        try:
            assert gtk.ACCEL_VISIBLE != gtk.EXPAND
        except Warning:
            pass
        else:
            raise AssertionError
        warnings.resetwarnings()
{'fraction_non_alphanumeric': 0.09467284308048639, 'fraction_numerical': 0.007382744643891141, 'mean_word_length': 2.482358870967742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1593195', 'n_tokens_mistral': 2197, 'n_tokens_neox': 2132, 'n_words': 437}