有没有一种简单的方法可以在Django中使用秃ul? [英] Is there a simple way to use vulture with django?
问题描述
我正在尝试清理django中一些复杂的旧代码。 秃鹰看起来不错,但它似乎不知道如何找到引用的视图函数来自urls.py。这并不奇怪,因为大多数函数都包含为字符串:
I'm trying to clean up some tangled legacy code in django. Vulture looks like a good bet, but it doesn't seem to know how to find view functions referenced from urls.py. This isn't too surprising, since most of the functions are included as strings:
...
url(r'^some-url/$', 'my_app.views.some_url_view'),
...
有没有一种简单的方法可以让秃鹰了解视图功能?
Is there a simple way to make vulture aware of the view functions?
我要为我做的一件事:我写的内容相当广泛测试代码。目前,秃鹰错过了这些测试,但是如果有某种方法可以让秃鹰了解这些测试,那么我认为所有的观点也将包括在内。
One thing I've got going for me: I've written fairly extensive tests for the code. Currently, vulture misses these tests, but if there were some way to make vulture aware of these tests, I think all the views would be included as well.
推荐答案
尝试Ned的Batchelder coverage
本身或与 一起使用鼻子
。
Try Ned's Batchelder coverage
by itself or use it with nose
.
只需运行测试用例, coverage html
就会为您提供漂亮的报告,逐行显示您的代码,详细的覆盖范围信息。然后整理/删除未使用/未使用的代码。
Just run through the testcases, and coverage html
will get you a beautiful reporting showing your code line by line, with detailed coverage information. Trim down/remove unused/untested code afterwards.
这篇关于有没有一种简单的方法可以在Django中使用秃ul?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!