2013-06-26 104 views
3

在运行时:Django的manage.py测试

./manage.py test appname

如何禁用所有的统计/日志/ “确定” 后输出?

  • 我已经评论了整个日志记录部分 - 没有运气。
  • 还评论了任何print_stat调用 - 没有运气
  • 我的manage.py是相当裸露的,所以它可能不是这样。

我运行了很多测试,并不断滚动上千终端线路查看结果。 显然,我是Python/Django的新手,它是测试框架,所以我很感激任何帮助。

---------------------------------------------------------------------- 
Ran 2 tests in 2.133s 

OK 
    1933736 function calls (1929454 primitive calls) in 2.133 seconds 

    Ordered by: standard name 

    ncalls tottime percall cumtime percall filename:lineno(function) 
     1 0.000 0.000 2.133 2.133 <string>:1(<module>) 
    30 0.000 0.000 0.000 0.000 <string>:8(__new__) 
     4 0.000 0.000 0.000 0.000 Cookie.py:315(_quote) 
    26 0.000 0.000 0.000 0.000 Cookie.py:333(_unquote) 
    10 0.000 0.000 0.000 0.000 Cookie.py:432(__init__) 
    28 0.000 0.000 0.000 0.000 Cookie.py:441(__setitem__) 
     . 
     . 
     . 
     2 0.000 0.000 0.000 0.000 {time.gmtime} 
    18 0.000 0.000 0.000 0.000 {time.localtime} 
    18 0.000 0.000 0.000 0.000 {time.strftime} 
    295 0.000 0.000 0.000 0.000 {time.time} 
    556 0.000 0.000 0.000 0.000 {zip} 

如果有帮助,我输入:

from django.utils import unittest 

class TestEmployeeAdd(unittest.TestCase): 
     def setUp(self): 
+0

我不明白你想要删除什么。 –

+0

“OK”下面的所有内容。基本上我不想看到任何统计数据。我只想看看测试是否通过或失败。 – Brice

+0

你在Linux/Unix或类似的shell? –

回答

2

如果使用unix样壳(苹果机做),你可以使用the head command做这样的伎俩:

python manage.py test appname | head -n 3 

3切换为需要在OK行之后截断输出的那个。

此外,如果您想了解更多通过设置命令的verbosity顺水推舟,最小的像这样的输出可以测试:

python manage.py test appname -v 0 

希望这有助于!

+0

谢谢,这有助于:) – Brice

+0

我很高兴!不客气:)考虑接受答案,如果它是有用的:) –

相关问题