2015-05-25 64 views
1

我有一套的Python 3单元测试中,当被使用此命令行执行:我怎样才能找出哪一行Python代码产生PendingDeprecationWarning?

python3 -m unittest discover -f -v 

...正在生成PendingDeprecationWarning

/usr/local/Cellar/python3/3.4.2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py:32: 
    PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses 

有没有一种简单的方法我跟踪哪个代码最终使用imp.py,也许通过打开某种形式的堆栈跟踪?我已经缩小了一点;它似乎只在我使用freezegun时触发。然而,freezegun本身似乎并没有使用imp

回答

4

当在命令行上调用蟒,传递选项-Werror到它。这会将所有警告转化为错误,并且当警告/错误未得到处理时,它将显示一个回溯,该回溯将为您提供行号和源文件,用于每个步骤以发出警告/错误。

+1

完美!这帮助我确定它是依赖的图书馆“六”。 –

+0

FWIW,这是错误:https://bitbucket.org/gutworth/six/issue/112/sixmovesreload_module-uses-deprecated-imp –