1
# This file is part of Parti.
2
# Copyright (C) 2008, 2009 Nathaniel Smith <njs@pobox.com>
3
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
4
# later version. See the file COPYING for details.
6
from wimpiggy.test import *
7
from wimpiggy.error import *
8
# Need a way to generate X errors...
9
import wimpiggy.lowlevel
13
class TestError(TestWithSession):
14
def cause_badwindow(self):
15
root = self.display.get_default_screen().get_root_window()
16
win = gtk.gdk.Window(root, width=10, height=10,
17
window_type=gtk.gdk.WINDOW_TOPLEVEL,
18
wclass=gtk.gdk.INPUT_OUTPUT,
21
wimpiggy.lowlevel.XAddToSaveSet(win)
25
assert trap.call(lambda: 0) == 0
26
assert trap.call(lambda: 1) == 1
28
trap.call(self.cause_badwindow)
30
assert e.args == (wimpiggy.lowlevel.const["BadWindow"],)
32
def test_swallow(self):
33
assert trap.swallow(lambda: 0) is None
34
assert trap.swallow(lambda: 1) is None
35
assert trap.swallow(self.cause_badwindow) is None
37
def test_assert_out(self):
39
assert_raises(AssertionError, trap.assert_out)