Noestest包括不需要的父目录

| 我试图将鼻子测试限制为特定目录,但是在测试运行期间,它包括我所针对的dir的父目录,这样做会引发错误。 这是测试运行输出的关键要素:
nose.importer: DEBUG: Add path /projects/myproject/myproject/specs
nose.importer: DEBUG: Add path /projects/myproject/myproject
nose.importer: DEBUG: Add path /projects/myproject
nose.importer: DEBUG: insert /projects/myproject into sys.path
我正在使用
buildout
pbp.recipe.noserunner
。这是相关的“ 3”部分:
[specs]
recipe = pbp.recipe.noserunner
eggs =
    pbp.recipe.noserunner
    ${buildout:eggs}
    figleaf
    pinocchio
working-directory = 
    myproject/specs
defaults =
    -vvv
    --exe
    --include ^(it|ensure|must|should|specs?|examples?)
    --include (specs?(.py)?|examples?(.py)?)$
    --with-spec
    --spec-color
我还尝试将ѭ5设置为
defaults
参数之一,以帮助限制导入,但仍然没有乐趣。 关于我要去哪儿有什么建议吗? 编辑: 我已经尝试过7个父目录,但没有任何乐趣。     
已邀请:
        我想您期望出现以下行为。
nose.importer: DEBUG: Add path /projects/myproject
nose.importer: DEBUG: insert /projects/myproject into sys.path
为什么不尝试使用
--match
--exclude
模式来限制测试集? 尝试:
--exclude myproject/myproject
我检查了nasal.importer的源代码:鼻子递归add_path规格的父母包。 我认为除非您创建特定的导入程序,否则您无法绕过此操作... 我不知道鼻子API是否可行。
def add_path(path, config=None):
    \"\"\"Ensure that the path, or the root of the current package (if
    path is in a package), is in sys.path.
    \"\"\"

    # FIXME add any src-looking dirs seen too... need to get config for that

    log.debug(\'Add path %s\' % path)    
    if not path:
        return []
    added = []
    parent = os.path.dirname(path)
    if (parent
        and os.path.exists(os.path.join(path, \'__init__.py\'))):
        added.extend(add_path(parent, config))
    elif not path in sys.path:
        log.debug(\"insert %s into sys.path\", path)
        sys.path.insert(0, path)
        added.append(path)
    if config and config.srcDirs:
        for dirname in config.srcDirs:
            dirpath = os.path.join(path, dirname)
            if os.path.isdir(dirpath):
                sys.path.insert(0, dirpath)
                added.append(dirpath)
    return added


def remove_path(path):
    log.debug(\'Remove path %s\' % path)
    if path in sys.path:
        sys.path.remove(path)
    

要回复问题请先登录注册