Pycharm控制台吃掉django-nose覆盖输出

时间:2013-11-08 16:55:13

标签: django code-coverage pycharm nose

我正在尝试使用pycharm本身的django应用程序进行覆盖测试。我正在使用django-nose / nose作为测试运行器,我在test_settings.py中有这些设置

# nose settings
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
    '--with-coverage',
    '--cover-package=myapp',
]

如果我去命令行(或内置的pycharm终端)激活我的virtualenv并运行... django-admin.py test --settings=myapp.tests.test_settings,这一切都非常好用...我得到了我期望的输出。

然而,当我尝试在Pycharm中使用我的测试运行配置时,我不再获得覆盖输出,我得到的是:

Testing started at 16:37 ...
There is no such manage file manage
nosetests --with-coverage --cover-package=dynamicbanners --verbosity=1
Creating test database for alias 'default'...
..
Process finished with exit code 0

(我没有manage.py,因为它是一个独立的应用程序,因此我假设管理文件消息。)

测试仍然“通过”,但没有输出,也没有创建.coverage文件。我暂时在Windows上运行,是否有可能Windows拒绝写入.coverage文件,因此没有显示任何内容?或者是Pycharm正在吃输出但没有显示它?

我会使用内置pycharm“Run with coverage”选项,但它似乎有问题

NOSE_ARGS = [
    '--with-coverage',
    '--cover-package=myapp',
]

因为当我使用这些选项运行它时会发出一个错误,我认为这是由于两个覆盖实例被初始化而导致

Testing started at 16:41 ...
There is no such manage file manage
nosetests --with-coverage --cover-package=myapp --verbosity=1
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 3.0.1\helpers\run_coverage.py", line 34, in <module>
    main()
  File "C:\Users\ptinkler\venvs\myapp_venv\lib\site-packages\coverage\cmdline.py", line 720, in main
    status = CoverageScript().command_line(argv)
  File "C:\Users\ptinkler\venvs\myapp_venv\lib\site-packages\coverage\cmdline.py", line 438, in command_line
     self.do_execute(options, args)
  File "C:\Users\ptinkler\venvs\myapp_venv\lib\site-packages\coverage\cmdline.py", line 580, in do_execute
     self.coverage.stop()
  File "C:\Users\ptinkler\venvs\myapp_venv\lib\site-packages\coverage\control.py", line 410, in stop
     self.collector.stop()
  File "C:\Users\ptinkler\venvs\myapp_venv\lib\site-packages\coverage\collector.py", line 294, in stop
     assert self._collectors[-1] is self
AssertionError

Process finished with exit code 1

尽管我在设置中取消选中“使用捆绑的coverage.py” - >覆盖

感谢任何帮助,我宁愿不必创建一个本地设置文件来摆脱那些NOSE_ARGS只是为了在pycharm中显示覆盖范围。如果我只能在pycharm testrunner控制台中以标准覆盖输出结束,而不是世界末日。否则我想我必须坚持使用命令行。

0 个答案:

没有答案