提交 2c961a46 编写于 作者: L Lukáš Doktor

avocado.core.loader: Use sys.path.remove instead of pop

It's safer to use "remove" in case someone adjusted "sys.path".
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 30e57bce
...@@ -263,8 +263,13 @@ class TestLoaderProxy(object): ...@@ -263,8 +263,13 @@ class TestLoaderProxy(object):
sys.path.insert(0, test_module_dir) sys.path.insert(0, test_module_dir)
f, p, d = imp.find_module(module_name, [test_module_dir]) f, p, d = imp.find_module(module_name, [test_module_dir])
test_module = imp.load_module(module_name, f, p, d) test_module = imp.load_module(module_name, f, p, d)
except ImportError, details:
raise ImportError("Unable to import test's module with "
"sys.path=%s\n\n%s" % (", ".join(sys.path),
details))
finally: finally:
sys.path.pop(0) if test_module_dir in sys.path:
sys.path.remove(test_module_dir)
for _, obj in inspect.getmembers(test_module): for _, obj in inspect.getmembers(test_module):
if (inspect.isclass(obj) and obj.__name__ == test_class and if (inspect.isclass(obj) and obj.__name__ == test_class and
inspect.getmodule(obj) == test_module): inspect.getmodule(obj) == test_module):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册