aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-linux-x86_64.egg/twisted/manhole/ui/test/test_gtk2manhole.py
blob: b59f9370bcc7f52f860fc6d7d83467ddc4bdd2d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright (c) 2009 Twisted Matrix Laboratories.
"""
Tests for GTK2 GUI manhole.
"""

skip = False

try:
    import pygtk
    pygtk.require("2.0")
except:
    skip = "GTK 2.0 not available"
else:
    try:
        import gtk
    except ImportError:
        skip = "GTK 2.0 not available"
    except RuntimeError:
        skip = "Old version of GTK 2.0 requires DISPLAY, and we don't have one."
    else:
        if gtk.gtk_version[0] == 1:
            skip = "Requested GTK 2.0, but 1.0 was already imported."
        else:
            from twisted.manhole.ui.gtk2manhole import ConsoleInput

from twisted.trial.unittest import TestCase

from twisted.python.reflect import prefixedMethodNames

class ConsoleInputTests(TestCase):
    """
    Tests for L{ConsoleInput}.
    """

    def test_reverseKeymap(self):
        """
        Verify that a L{ConsoleInput} has a reverse mapping of the keysym names
        it needs for event handling to their corresponding keysym.
        """
        ci = ConsoleInput(None)
        for eventName in prefixedMethodNames(ConsoleInput, 'key_'):
            keysymName = eventName.split("_")[-1]
            keysymValue = getattr(gtk.keysyms, keysymName)
            self.assertEqual(ci.rkeymap[keysymValue], keysymName)


    skip = skip