提交 1a22c6e4 编写于 作者: C Cleber Rosa

Safeloader: handle add_import_object ImportFrom alias statement

A "from <module> import <symbol>" statement will not always have
a module name set, one example is:

   from . import BASEDIR

In these situations, the statement's module attribute will be None.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 eec874f6
......@@ -88,7 +88,7 @@ class AvocadoModule(object):
Keeps track of objects names and importable entities
"""
path = os.path.abspath(os.path.dirname(self.path))
if hasattr(statement, 'module'):
if getattr(statement, 'module', None) is not None:
module_path = statement.module.replace('.', os.path.sep)
path = os.path.join(path, module_path)
for name in statement.names:
......
......@@ -203,6 +203,8 @@ class Second(avocado.Test):
PYTHON_UNITTEST = """#!/usr/bin/env python
from unittest import TestCase
from . import something
class SampleTest(TestCase):
def test(self):
pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册