OLD | NEW |
| (Empty) |
1 # Copyright (c) 2008 Twisted Matrix Laboratories. | |
2 # See LICENSE for details. | |
3 | |
4 """ | |
5 Tests for L{twisted.internet.gtk2reactor}. | |
6 """ | |
7 | |
8 from twisted.trial.unittest import TestCase | |
9 | |
10 | |
11 class Gtk2ReactorTests(TestCase): | |
12 """ | |
13 Tests for L{twisted.internet.gtk2reactor.Gtk2Reactor}. | |
14 """ | |
15 def test_stopWhenRunning(self): | |
16 """ | |
17 When C{reactor.stop} is scheduled with C{callWhenRunning}, | |
18 C{reactor.run} will return immediately, and without processing any | |
19 timed events. | |
20 """ | |
21 # This test *should* be part of a general reactor test suite that runs | |
22 # tests cases against all reactor implementations. | |
23 missed = [] | |
24 def calledTooLate(): | |
25 missed.append(True) | |
26 reactor.crash() | |
27 reactor = Gtk2Reactor(useGtk=False) | |
28 reactor.callWhenRunning(reactor.stop) | |
29 reactor.callLater(0, calledTooLate) | |
30 reactor.run(installSignalHandlers=False) | |
31 # XXX This explicit calls to clean up the waker should become obsolete | |
32 # when bug #3063 is fixed. -radix, 2008-02-29. Fortunately it should | |
33 # probably cause an error when bug #3063 is fixed, so it should be | |
34 # removed in the same branch that fixes it. | |
35 reactor.removeReader(reactor.waker) | |
36 reactor.waker.connectionLost(None) | |
37 if missed == [True]: | |
38 self.fail("callWhenRunning reactor.stop did not take effect") | |
39 | |
40 try: | |
41 from twisted.internet.gtk2reactor import Gtk2Reactor | |
42 except ImportError: | |
43 Gtk2ReactorTests.skip = "gtk2reactor is unavailable" | |
OLD | NEW |