2017-09-20 4 views
2

client_fixture.py오류 가져 오기 응용 프로그램

import pytest 

from app.apis import api 
from app import create_app 


@pytest.fixture 
def app_client(credentials, redis_cred_setup): 
    app = create_app(credentials['app_config_name']) 
    api.init_app(app) 

    client = app.test_client() 
    return client 

내가 app 패키지

__init__.py 내부의기구와 기능 create_app()을 가지고 있지만,이기구는 오류가 발생

ImportError: Error importing plugin "client_fixtures": No module named 'app'

패키지 구조 어쩌면

Core 
    app- 
     ... 
     __init__.py 

    tests- 
     client_fixture.py 

내가 다 난 그냥 테스트 폴더에 마우스 오른쪽 버튼을 클릭하고 실행 작업, PyCharm를 사용하여 테스트를 실행

`실행 py.test 도움이 될 것입니다 에서 테스트 '당신은 같은 pytest 호출 할 필요가

+0

테스트를 시작한 방법과 작업 디렉토리는 어디에서 시작 했습니까? –

+0

편집 됨 @KlausD. Core dir에서'pytest' 명령을 사용하여 프로그램을 실행합니다. –

+0

'Core' 디렉토리에서 테스트를 실행해야합니다. –

답변

2

:

documentation에서3210

:

이것은 또한 sys.path에 현재 디렉토리를 추가 것이다 파이썬을 제외하고, 직접 명령 줄 스크립트 pytest tests/를 호출 거의 동일합니다.

+0

감사합니다 :) Gitlab 스팸 메일을 저장합니다))) –