2017-12-22 1 views
1

테스트 용 황금 데이터가있는 다른 디렉토리가 포함 된 테스트 디렉토리를 갖고 싶습니다.테스트 디렉토리에있는 디렉토리가 unittest에서 가져 오기 오류를 일으켰습니다.

을 감안할 때이 :

Traceback (most recent call last): 
    File "./verify.py", line 12, in <module> 
    tests.append(loader.discover(test_dir, pattern="test*.py",top_level_dir=os.environ['BASE_DIR']+"/tb")) 
    File "/Users/raysalemi/anaconda3/lib/python3.6/unittest/loader.py", line 338, in discover 
    raise ImportError('Start directory is not importable: %r' % start_dir) 
ImportError: Start directory is not importable: '/Users/raysalemi/workspaces/scripts/tb/test_install/golden_repos' 

가 어떻게 발견되는 디렉토리를 제외 할 수

% ls 
__init__.py golden_repos release_dir test_install.py 

나는 golden_repos를로드하려고하기 때문에이 오류가?

답변

2

__init__.py 파일을 모든 디렉토리에 넣으면 검사되고 무시됩니다.

이것은 제외하는 것과 같지 않으며 지금은 가짜 __init__.py 파일이 있지만 작동했습니다.

+1

실제로 빈 __init__.py 파일은 오류를 해결하는 방법입니다. 파이썬은 가져 오기에서 어떤 것을 제외시키는 메커니즘을 제공하지 않습니다. –

관련 문제