Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: third_party/twisted_8_1/twisted/test/test_manhole.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1
2 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5
6 from twisted.trial import unittest
7 from twisted.manhole import service
8 from twisted.spread.util import LocalAsRemote
9
10 class Dummy:
11 pass
12
13 class DummyTransport:
14 def getHost(self):
15 return 'INET', '127.0.0.1', 0
16
17 class DummyManholeClient(LocalAsRemote):
18 zero = 0
19 broker = Dummy()
20 broker.transport = DummyTransport()
21
22 def __init__(self):
23 self.messages = []
24
25 def console(self, messages):
26 self.messages.extend(messages)
27
28 def receiveExplorer(self, xplorer):
29 pass
30
31 def setZero(self):
32 self.zero = len(self.messages)
33
34 def getMessages(self):
35 return self.messages[self.zero:]
36
37 # local interface
38 sync_console = console
39 sync_receiveExplorer = receiveExplorer
40 sync_setZero = setZero
41 sync_getMessages = getMessages
42
43 class ManholeTest(unittest.TestCase):
44 """Various tests for the manhole service.
45
46 Both the the importIdentity and importMain tests are known to fail
47 when the __name__ in the manhole namespace is set to certain
48 values.
49 """
50 def setUp(self):
51 self.service = service.Service()
52 self.p = service.Perspective(self.service)
53 self.client = DummyManholeClient()
54 self.p.attached(self.client, None)
55
56 def test_importIdentity(self):
57 """Making sure imported module is the same as one previously loaded.
58 """
59 self.p.perspective_do("from twisted.manhole import service")
60 self.client.setZero()
61 self.p.perspective_do("int(service is sys.modules['twisted.manhole.servi ce'])")
62 msg = self.client.getMessages()[0]
63 self.failUnlessEqual(msg, ('result',"1\n"))
64
65 def test_importMain(self):
66 """Trying to import __main__"""
67 self.client.setZero()
68 self.p.perspective_do("import __main__")
69 if self.client.getMessages():
70 msg = self.client.getMessages()[0]
71 if msg[0] in ("exception","stderr"):
72 self.fail(msg[1])
73
74 #if __name__=='__main__':
75 # unittest.main()
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/test/test_loopback.py ('k') | third_party/twisted_8_1/twisted/test/test_memcache.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698