1
在Python中,我有一個劇本叫script.py
和script.py
與測試搜索未經測試的功能
tests
__init__.py
test_set01.py
test_set02.py
用於檢查未經測試的功能的子目錄我用這個bash script
#!/bin/bash
for f in $(egrep "^def" script.py | sed "s/(/\t/" | awk '{print $2}')
do
if [ "" = "$(grep $f tests/*.*)" ]
then
echo $f
fi
done
存在更好的方法找到沒有測試的功能?
肯定。 [獲取模塊中所有功能的列表](http://stackoverflow.com/questions/139180/listing-all-functions-in-a-python-module),然後檢查你的測試模塊。我想知道更多關於您使用'grep'檢查的方式。 'script.py'和'tests'中的模塊的內容是什麼樣的?如果你幫助我,我可以給你一個具體的答案。 – 2rs2ts
此外,python測試覆蓋率的一個小搜索產生了[這個庫叫做'coverage'](http://nedbatchelder.com/code/coverage/),它可能也會完成這項工作。 – 2rs2ts