我正在为Keras框架开发一个自定义层,并希望扩展现有的testsuite。在
由于我正在开发keras源代码,因此我将其安装为:
pip install keras-preprocessing
pip install keras-applications
git clone https://github.com/keras-team/keras
cd keras
export PYTHONPATH=$PWD:$PYTHONPATH
在这些命令之后,您进入了克隆的keras存储库,这是下面代码示例的工作目录。在
首先,我想运行现有的测试,看看它们能做些什么。It looks like它们可以简单地作为python文件运行:
if __name__ == '__main__':
pytest.main([__file__])
但是这个:
^{pr2}$生成以下输出,并且不运行任何测试
Using TensorFlow backend.
usage: wrappers_test.py [options] [file_or_dir] [file_or_dir] [...]
wrappers_test.py: error: unrecognized arguments: -n tests/keras/layers/wrappers_test.py
inifile: /home/lhk/programming/keras/pytest.ini
rootdir: /home/lhk/programming/keras
所以我尝试显式地调用pytest next:
pytest tests/keras/layers/wrappers_test.py
完全相同的响应(没有tensorflow日志):
usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: -n tests/keras/layers/wrappers_test.py
inifile: /home/lhk/programming/keras/pytest.ini
rootdir: /home/lhk/programming/keras
我使用的是PyCharm,如果我从PyCharm内部运行测试(我承认是首先尝试过的),它只会产生上面的消息。在
显然,我没有正确配置它。Pytest无法获取测试套件。为了找到参考配置,我查看了Keras CI设置。他们使用Travis,配置是开源的:https://travis-ci.org/keras-team/keras/jobs/442252422/config
看起来我已经安装了所有的依赖项。实际的测试命令基本上是我已经尝试过的:
PYTHONPATH=$PWD:$PYTHONPATH py.test tests/ --ignore=tests/integration_tests --ignore=tests/test_documentation.py --ignore=tests/keras/legacy/layers_test.py --cov-config .coveragerc --cov=keras tests/
它产生与上述完全相同的输出。在
我认为问题出在pytest。但是他们的自动化测试的安装部分只显示pip install pytest pytest-pip8
。我运行了这个,但果然,requirement already satisfied
。在
如何执行keras pytests。 我在运行Ubuntu18.04.1,Python3.6.5和64位的Python。在
在Contributing页面中提到了运行
keras
测试:如果不想在可编辑模式下安装包,只需显式安装所有测试依赖项。Looking at ^{}' setup script ,命令是:
相关问题 更多 >
编程相关推荐