【发布时间】:2019-05-31 06:07:39
【问题描述】:
我在 falcon 中有一个服务器和一个测试模块,但是在运行测试用例时我无法将服务器模块导入到测试模块中。
这是我的层次结构:
project
|
--__init__.py
--server.py
|
/tests
|
--__init__.py
-- apitest.py
这是我的测试代码
"""
Unit test for Ping api resource
"""
from falcon import testing
import pytest
import server
@pytest.fixture(scope='module')
def client():
return testing.TestClient(server.api)
def test_get_message(client):
result = client.simulate_get('/api/ping')
assert result.status_code == 200
但是当我运行它时它显示:
Traceback:
apiTest.py:7: in <module>
import server
E ImportError: No module named 'server'
我在这里做错了什么。
【问题讨论】:
标签: python python-3.x pytest python-module falconframework