TeamCity for Python / Django持续集成 [英] TeamCity for Python/Django continuous integration

查看:367
本文介绍了TeamCity for Python / Django持续集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux(Ubuntu)方块中设定了 TeamCity ,并想要使用它为一些Python / Django项目。



问题是,我真的不知道接下来做什么 - 我试图搜索一个Python特定的构建代理

解决方案



好的,所以有如何让它与正确的TeamCity集成工作:



假设您已安装TeamCity至少有一个构建代理可用



1)配置您的构建代理以执行

  manage.py test 

2)为TC下载并安装此插件 http://pypi.python.org/pypi/teamcity-messages



3)必须提供您的自定义测试运行程序插件在(2)工作。它可以直接拷贝来自django.test.simple的run_tests,只有一个小小的修改:用TeamcityTestRunner调用测试运行程序的替换行,因此

  def run_tests(test_labels,verbosity = 1,interactive = True,extra_tests = []):
...
result = unittest.TextTestRunner(verbosity = verbosity).run套件)

使用此:

  def run_tests(test_labels,verbosity = 1,interactive = True,extra_tests = []):
...
result = TeamcityTestRunner $ b

您必须将该函数放入解决方案中的一个文件中,并指定一个客户测试运行器Django的TEST_RUNNER配置属性如下:

  TEST_RUNNER ='my_site.file_name_with_run_tests.run_tests'



请务必在 file_name_with_run_tests



您可以通过运行

  ./ manage.py test 
pre>

,并注意到输出已更改,现在是

  #teamcity .... 


I've set up TeamCity on a Linux (Ubuntu) box and would like to use it for some of Python/Django projects.

The problem is that I don't really see what to do next - I tried searching for a Python specific build agent for TeamCity but without much of the success.

How can I manage that?

解决方案

Ok, so there's how to get it working with proper TeamCity integration:

Presuming you have TeamCity installed with at least 1 build agent available

1) Configure your build agent to execute

manage.py test

2) Download and install this plugin for TC http://pypi.python.org/pypi/teamcity-messages

3) You'll have to provide your custom test runner for plugin in (2) to work. It can be straight copy of run_tests from django.test.simple, with only one slight modification: replace line where test runner is called with TeamcityTestRunner, so insted of

def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]):
    ...
    result = unittest.TextTestRunner(verbosity=verbosity).run(suite)

use this:

def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]):
    ...
    result = TeamcityTestRunner().run(suite)

You'll have to place that function into a file in your solution, and specify a custome test runner, using Django's TEST_RUNNER configuration property like this:

TEST_RUNNER = 'my_site.file_name_with_run_tests.run_tests'

Make sure you reference all required imports in your file_name_with_run_tests

You can test it by running

./manage.py test

from command line and noticing that output has changed and now messages like

#teamcity....

appearing in it.

这篇关于TeamCity for Python / Django持续集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆