Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add python-related unittest problem in faq document #377

Merged
merged 4 commits into from
Nov 8, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions doc_cn/faq/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,33 @@ PaddlePaddle的参数使用名字 :code:`name` 作为参数的ID,相同名字

pip install --upgrade pip

8. test_PyDataProvider等部分python相关单测过不了
-------------------------------------------------

如果出现以下单测过不了的情况:

.. code-block:: bash

24 - test_PyDataProvider (Failed)
26 - test_RecurrentGradientMachine (Failed)
27 - test_NetworkCompare (Failed)
28 - test_PyDataProvider2 (Failed)
32 - test_Prediction (Failed)
33 - test_Compare (Failed)
34 - test_Trainer (Failed)
35 - test_TrainerOnePass (Failed)
36 - test_CompareTwoNets (Failed)
37 - test_CompareTwoOpts (Failed)
38 - test_CompareSparse (Failed)
39 - test_recurrent_machine_generation (Failed)
40 - test_PyDataProviderWrapper (Failed)
41 - test_config_parser (Failed)
42 - test_swig_api (Failed)
43 - layers_test (Failed)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

并且查询paddle单测日志,提示

paddle package is already in your PYTHONPATH. But unittest need a clean environment.
Please uninstall paddle package before start unittest. Try to 'pip uninstall paddle'

解决办法是:先卸载paddle包 :code:`pip uninstall paddle`,再重新安装 :code:`make install`。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个单测不过也不一定是因为这个原因,有可能就是过不了,还是得看单测的log

然后也不需要重新安装

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是一个单测过不了,是以下这些单测都没过的情况,基本上都是因为paddle包没装对。我改一下标题。


原因是单元测试使用了一个旧版本的python包,而没有测试到代码中实际修改的python包。即单测需要一个干净的环境(unittest need a clean environment):

* 如果paddle包已经在python的site-packages里面了,那么单元测试时使用的paddle包,就是site-packages里面的python包,而不是源码目录里 :code:`/python` 目录下的python包。
* 即便设置了 :code:`PYTHONPATH` 到 :code:`/python` 也没用,因为python的搜索路径是优先已经安装的python包。