我在我的
tests/conftest.py
文件,用于为pytest运行的测试加载numpy数组作为fixture对象:
@pytest.fixture(scope="module")
def my_fixture():
return np.load(os.path.join(os.getcwd(), "fixture", "example.npy")
文件
projectname/tests/fixture/example.npy
存在。
tests
/home/travis/build/username/projectname/tests/fixture/example.npy
/home/travis/build/username/projectname/fixture/example.npy
,就好像它从项目的主目录开始,而不是假定的相对位置tests子目录。
这个
projectname/tests
目录包含所有测试文件,*.npy fixture文件位于
projectname/tests/fixture
.
numpy.load
rootdir
在TravisCI上的设置与在PyCharm中运行测试时的行为不同?