From 2454dcc990da79d52dbfb006c422381d5e9d8ca9 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 1 Oct 2017 15:29:04 +0530 Subject: [PATCH] core: loosen assertion to allow fakessh_test to succeed. --- mitogen/core.py | 2 +- tests/module_finder_test.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/module_finder_test.py diff --git a/mitogen/core.py b/mitogen/core.py index b631ad23..2126af6e 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -763,7 +763,7 @@ class Context(object): def _unpickle_context(router, context_id, name): assert isinstance(router, Router) assert isinstance(context_id, (int, long)) and context_id > 0 - assert type(name) is str and len(name) < 100 + assert isinstance(name, basestring) and len(name) < 100 return Context(router, context_id, name) diff --git a/tests/module_finder_test.py b/tests/module_finder_test.py new file mode 100644 index 00000000..cb55694c --- /dev/null +++ b/tests/module_finder_test.py @@ -0,0 +1,28 @@ + +import unittest +import mitogen.master + + +class CompilerModuleTest(unittest.TestCase): + klass = mitogen.master.ModuleScanner + + @classmethod + def setUpClass(cls): + super(CompilerModuleTest, cls).setUpClass() + #import compiler + #mitogen.master.ast = None + #mitogen.master.compiler = compiler + + def test_simple(self): + for x in range(100): + finder = self.klass() + from pprint import pprint + import time + t0 = time.time() + import mitogen.fakessh + pprint(finder.find_related('mitogen.fakessh')) + print 1000 * (time.time() - t0) + + +if __name__ == '__main__': + unittest.main()