| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2006 Twisted Matrix Laboratories. | |
| 2 # See LICENSE for details. | |
| 3 | |
| 4 """ | |
| 5 L{twisted.test.test_application.PluggableReactorTestCase.test_qtStub} uses | |
| 6 this helper program to test that when the QT reactor plugin is not | |
| 7 available, an attempt to select it via the deprecated name C{qt} fails | |
| 8 appropriately. | |
| 9 | |
| 10 When installation fails, no output is produced. When it succeeds, a message | |
| 11 is printed. | |
| 12 """ | |
| 13 | |
| 14 import sys | |
| 15 | |
| 16 from twisted.application import reactors | |
| 17 | |
| 18 | |
| 19 class QTNotImporter: | |
| 20 """ | |
| 21 Import hook which unilaterally rejects any attempt to import | |
| 22 C{qtreactor} so that we can reliably test the behavior of attempting to | |
| 23 install it when it is not present. | |
| 24 """ | |
| 25 def find_module(self, fullname, path): | |
| 26 """ | |
| 27 Reject attempts to import C{qtreactor}. Ignore everything else. | |
| 28 """ | |
| 29 if fullname == 'qtreactor': | |
| 30 raise ImportError('qtreactor does not exist!') | |
| 31 | |
| 32 | |
| 33 | |
| 34 def main(): | |
| 35 """ | |
| 36 Try to install the reactor named C{qt}. Expect it to not work. Print | |
| 37 diagnostics to stdout if something goes wrong, print nothing otherwise. | |
| 38 """ | |
| 39 sys.meta_path.insert(0, QTNotImporter()) | |
| 40 try: | |
| 41 reactors.installReactor('qt') | |
| 42 except reactors.NoSuchReactor, e: | |
| 43 if e.args != ('qt',): | |
| 44 print 'Wrong arguments to NoSuchReactor:', e.args | |
| 45 else: | |
| 46 # Do nothing to indicate success. | |
| 47 pass | |
| 48 else: | |
| 49 print 'installed qtreactor succesfully' | |
| 50 sys.stdout.flush() | |
| 51 | |
| 52 if __name__ == '__main__': | |
| 53 main() | |
| OLD | NEW |