tests: importer fixes
This commit is contained in:
parent
8d45e609ee
commit
f7d2eace08
|
@ -864,7 +864,7 @@ class Stream(BasicStream):
|
|||
self._router = router
|
||||
self.remote_id = remote_id
|
||||
self.name = 'default'
|
||||
self.sent_modules = set()
|
||||
self.sent_modules = set(['mitogen', 'mitogen.core'])
|
||||
self.construct(**kwargs)
|
||||
self._input_buf = collections.deque()
|
||||
self._output_buf = collections.deque()
|
||||
|
|
|
@ -593,6 +593,7 @@ class ModuleResponder(object):
|
|||
mitogen.core.Message(
|
||||
data='%s\x00%s' % (context.context_id, fullname),
|
||||
handle=mitogen.core.FORWARD_MODULE,
|
||||
dst_id=stream.remote_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -1231,7 +1231,7 @@ class ModuleForwarder(object):
|
|||
if msg.is_dead:
|
||||
return
|
||||
|
||||
context_id_s, fullname = msg.data.partition('\x00')
|
||||
context_id_s, _, fullname = msg.data.partition('\x00')
|
||||
context_id = int(context_id_s)
|
||||
stream = self.router.stream_by_id(context_id)
|
||||
if stream.remote_id == mitogen.parent_id:
|
||||
|
@ -1239,15 +1239,18 @@ class ModuleForwarder(object):
|
|||
self, context_id, fullname)
|
||||
return
|
||||
|
||||
if fullname in stream.sent_modules:
|
||||
return
|
||||
|
||||
LOG.debug('%r._on_forward_module() sending %r to %r via %r',
|
||||
self, fullname, context_id, stream.remote_id)
|
||||
self._send_module_and_related(stream, fullname)
|
||||
if stream.remote_id != context_id:
|
||||
stream._send(
|
||||
mitogen.core.Message(
|
||||
dst_id=stream.remote_id,
|
||||
handle=mitogen.core.FORWARD_MODULE,
|
||||
data=msg.data,
|
||||
handle=mitogen.core.FORWARD_MODULE,
|
||||
dst_id=stream.remote_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import unittest2
|
||||
|
||||
from mitogen.parent import minimize_source
|
||||
|
||||
import mitogen.minify
|
||||
import testlib
|
||||
|
||||
|
||||
|
@ -14,40 +13,42 @@ def read_sample(fname):
|
|||
|
||||
|
||||
class MinimizeSource(unittest2.TestCase):
|
||||
func = staticmethod(mitogen.minify.minimize_source)
|
||||
|
||||
def test_class(self):
|
||||
original = read_sample('class.py')
|
||||
expected = read_sample('class_min.py')
|
||||
self.assertEqual(expected, minimize_source(original))
|
||||
self.assertEqual(expected, self.func(original))
|
||||
|
||||
def test_comment(self):
|
||||
original = read_sample('comment.py')
|
||||
expected = read_sample('comment_min.py')
|
||||
self.assertEqual(expected, minimize_source(original))
|
||||
self.assertEqual(expected, self.func(original))
|
||||
|
||||
def test_def(self):
|
||||
original = read_sample('def.py')
|
||||
expected = read_sample('def_min.py')
|
||||
self.assertEqual(expected, minimize_source(original))
|
||||
self.assertEqual(expected, self.func(original))
|
||||
|
||||
def test_hashbang(self):
|
||||
original = read_sample('hashbang.py')
|
||||
expected = read_sample('hashbang_min.py')
|
||||
self.assertEqual(expected, minimize_source(original))
|
||||
self.assertEqual(expected, self.func(original))
|
||||
|
||||
def test_mod(self):
|
||||
original = read_sample('mod.py')
|
||||
expected = read_sample('mod_min.py')
|
||||
self.assertEqual(expected, minimize_source(original))
|
||||
self.assertEqual(expected, self.func(original))
|
||||
|
||||
def test_pass(self):
|
||||
original = read_sample('pass.py')
|
||||
expected = read_sample('pass_min.py')
|
||||
self.assertEqual(expected, minimize_source(original))
|
||||
self.assertEqual(expected, self.func(original))
|
||||
|
||||
def test_obstacle_course(self):
|
||||
original = read_sample('obstacle_course.py')
|
||||
expected = read_sample('obstacle_course_min.py')
|
||||
self.assertEqual(expected, minimize_source(original))
|
||||
self.assertEqual(expected, self.func(original))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -200,6 +200,7 @@ class FindRelatedTest(testlib.TestCase):
|
|||
'mitogen.compat.functools',
|
||||
'mitogen.core',
|
||||
'mitogen.master',
|
||||
'mitogen.minify',
|
||||
'mitogen.parent',
|
||||
])
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ class BrokenModulesTest(unittest2.TestCase):
|
|||
|
||||
responder = mitogen.master.ModuleResponder(router)
|
||||
responder._on_get_module(msg)
|
||||
self.assertEquals(1, len(router.route.mock_calls))
|
||||
self.assertEquals(1, len(router._async_route.mock_calls))
|
||||
|
||||
call = router.route.mock_calls[0]
|
||||
call = router._async_route.mock_calls[0]
|
||||
msg, = call[1]
|
||||
self.assertEquals(mitogen.core.LOAD_MODULE, msg.handle)
|
||||
self.assertEquals(('non_existent_module', None, None, None, ()),
|
||||
|
@ -81,9 +81,9 @@ class BrokenModulesTest(unittest2.TestCase):
|
|||
|
||||
responder = mitogen.master.ModuleResponder(router)
|
||||
responder._on_get_module(msg)
|
||||
self.assertEquals(1, len(router.route.mock_calls))
|
||||
self.assertEquals(1, len(router._async_route.mock_calls))
|
||||
|
||||
call = router.route.mock_calls[0]
|
||||
call = router._async_route.mock_calls[0]
|
||||
msg, = call[1]
|
||||
self.assertEquals(mitogen.core.LOAD_MODULE, msg.handle)
|
||||
self.assertIsInstance(msg.unpickle(), tuple)
|
||||
|
|
Loading…
Reference in New Issue