Skip to main content

Send test results to TeamCity continuous integration server from unittest, nose, py.test, twisted trial, behave (Python 2.6+)

Project description

Official JetBrains project Apache 2.0 license PyPI version
Python versions supported TeamCity Build Status

This package integrates Python with the TeamCity Continuous Integration (CI) server. It allows sending “service messages” from Python code. Additionally, it provides integration with the following testing frameworks and tools:

Installation

Install using pip:

pip install teamcity-messages

or from source:

python setup.py install

Usage

This package uses service messages to report the build status to TeamCity. See https://confluence.jetbrains.com/display/TCDL/Build+Script+Interaction+with+TeamCity for more details

unittest

If you wish to use the Python default unittest framework, you should modify the Test runner, e.g.:

import unittest
from teamcity import is_running_under_teamcity
from teamcity.unittestpy import TeamcityTestRunner

class Test(unittest.TestCase):
    ...

if __name__ == '__main__':
    if is_running_under_teamcity():
        runner = TeamcityTestRunner()
    else:
        runner = unittest.TextTestRunner()
    unittest.main(testRunner=runner)

See examples/simple.py for a full example.

If you are used to running unittest from the command line, instead of using python -m unittest, you could use python -m teamcity.unittestpy.

nose

Test status reporting is enabled automatically under TeamCity build.

py.test

Test status reporting is enabled automatically under TeamCity build.

Django

For Django 1.6+: Use the TeamcityDjangoRunner runner instead of the default DiscoverRunner by changing the following setting in your settings.py:

TEST_RUNNER = "teamcity.django.TeamcityDjangoRunner"

If you are using another test runner, you should override the run_suite method or use the DiscoverRunner.test_runner property introduced in Django 1.7.

flake8

Test status reporting is enabled automatically under TeamCity build.

PyLint

Add --output-format=teamcity.pylint_reporter.TeamCityReporter to the pylint command line.

tox

Pass TEAMCITY_VERSION environment variable inside your test virtenv. TEAMCITY_VERSION environment variable exists during build on TeamCity. teamcity-messages uses it in order to enable reporting to TeamCity.

[testenv]
passenv = TEAMCITY_VERSION

Twisted trial

Add --reporter=teamcity option to trial command line

Behave

For Behave 1.2.6:

from behave.formatter import _registry
from behave.configuration import Configuration
from behave.runner import Runner
from teamcity.jb_behave_formatter import TeamcityFormatter

_registry.register_as("TeamcityFormatter", TeamcityFormatter)
configuration = Configuration()
configuration.format = ["TeamcityFormatter"]
configuration.stdout_capture = False
configuration.stderr_capture = False
Runner(configuration).run()

Python version compatibility

See https://pypi.org/project/teamcity-messages for Python version compatibility

Contact information

https://github.com/JetBrains/teamcity-messages

TeamCity support: http://www.jetbrains.com/support/teamcity

License

Apache, version 2.0 http://www.apache.org/licenses/LICENSE-2.0

Change Log

Version 1.32 Tue Sep 27 2022
  • flake8: fix flake8 >= 5 by @itsb #266 #264

Version 1.31 Tue Feb 22 2022
  • python: supported Python 3.10

  • escape unencodable messages by @kri-k #261

Version 1.30 Fri Dec 17 2021
  • support pylint >= 2.12 by @Tirzono #259

  • pytest: fix assert diffs by @ikonst #247

  • pytest: support swapdiff as option by @throwable-one #244

Version 1.29 Fri Jun 25 2021
  • python: supported Python 3.9

  • support pylint >= 2.8 by @Tirzono #242

  • pytest: add an option to swap actual/expected in diff

Version 1.28 Thu Apr 30 2020
  • support coverage >= 5.0.1 by @enkelli #225 #218

  • python: dropped Python 2.6, 3.5 support. Latest version to support them is 1.27

  • python: supported Python 3.8

Version 1.27 Fri Nov 8 2019
  • pylint: more compatibility fixes #215

Version 1.26 Tue Nov 5 2019
  • drop Python 3.4 support

  • pylint: support pylint >= 2.3 by @PetrWolf #215

  • unittest: fix test hierarchy for subtests in tests with doc comments by @throwable-one #221

Version 1.25 Mon Apr 15 2019
  • pytest: fix comparing asserts by @ikonst #210

  • Retry writes to stream on a EAGAIN IOError by @morganwahl #213

Version 1.24 Mon Mar 18 2019
  • pylint: initial support by @PetrWolf #171 #200

Version 1.23 Sun Mar 10 2019
  • Correct supported python versions, description, keywords

Version 1.22 Sun Mar 10 2019

  • python: dropped Python 2.4, 2.5, 3.2, 3.3 support. Latest version to support them is 1.21

  • python: supported Python 3.6, 3.7

  • behave: initial support

  • unittest: subtests support

  • various unicode fixes

  • nose, unittest: correctly capture stdout to provide better test output

  • twisted: format twisted Failure objects by @jackrobison

  • various test infrastructure fixes by @sambrightman

  • flake8: correctly initialize options by @sambrightman

  • various fixes to use teamcity-messages code in JetBrains PyCharm IDE

Version 1.21 Mon Jan 2 2017

  • pytest: internal Error during test collection with pytest and teamcity-messages plugin #112

  • nose: support capturing test output from successful tests, #113

  • Fix possible error when joining bytes and unicode (Victor Makarov, https://github.com/vitek)

Version 1.20 Wed Aug 3 2016

Version 1.19 Sun Jun 26 2016

Version 1.18 Fri May 27 2016

Version 1.17 Sat Oct 17 2015

  • support coverage >= 4.0

  • automatically detect TeamCity in flake8 plugin (Marc Abramowitz, https://github.com/msabramo)

  • more messages support (Marc Abramowitz, https://github.com/msabramo) buildProblem, buildStatus, setParameter, importData, enableServiceMessages, disableServiceMessages etc

Version 1.16 Sat Sep 12 2015

Version 1.15 Fri Aug 28 2015

Version 1.14 Sat May 23 2015

Version 1.13 Sun Mar 29 2015

Version 1.12 Fri Jan 16 2015

  • unittest: fix 2.6 compat

Version 1.11 Fri Jan 16 2015

  • nose: handle errors/failures in teardown/setup

  • nose: support multiprocess mode

  • nose: correctly report captured output

  • unittest: support skipped tests in Python 2.6 (by unittest2)

  • unittest: support subtests (Python 3.4+)

Version 1.10 Fri Jan 09 2015

Version 1.9 Thu Jan 08 2015

  • Django support (Ralph Broenink, https://github.com/ralphje)

  • Fix test hierarchies on nose and py.test

  • py.test: report errors in setup and teardown

  • py.test: report collect errors

  • py.test: support xfail

  • nose: support skipped tests

  • unittest: support skip, expected failure and unexpected success

  • Totally rewritten integration tests * Thanks to Ralph Broenink (https://github.com/ralphje) and Leonid Bushuev (https://github.com/leo-from-spb)

Version 1.8 Sat Feb 08 2014

  • extensive tests for nose integration (James Carpenter)

  • added timestamps to TeamCity service messages (James Carpenter)

Version 1.7 Sun Feb 03 2013

  • py.test support (Aaron Buchanan)

  • official Python 3 support

Version 1.6 Tue Dec 06 2011

  • Bundle forgotten examples/simple.py

Version 1.4 Tue Apr 27 2010

Version 1.3 Fri Apr 11 2008

Version 1.2 Thu Apr 10 2008

  • Fixed tests gold data

Version 1.1 Thu Apr 10 2008

  • Fixed README

Version 1.0 Tue Apr 08 2008

  • initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teamcity-messages-1.32.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

teamcity_messages-1.32-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file teamcity-messages-1.32.tar.gz.

File metadata

  • Download URL: teamcity-messages-1.32.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.5

File hashes

Hashes for teamcity-messages-1.32.tar.gz
Algorithm Hash digest
SHA256 6991d95642c8d067524c90985b650d89caab6ac0bf47b721b931b04951abbfc1
MD5 e10ae91784a32a7904741a6f40b9d445
BLAKE2b-256 10f36d8eac4e4ed39855a902672cac33a2441f2c3942a9730f93b3c1025d4e21

See more details on using hashes here.

File details

Details for the file teamcity_messages-1.32-py3-none-any.whl.

File metadata

File hashes

Hashes for teamcity_messages-1.32-py3-none-any.whl
Algorithm Hash digest
SHA256 1dbd30e24e80ee80083a5ce01d8898c8157a974fd7cd13ee219834b918f4ab8c
MD5 ec26ecbdcf3978f741734c71b8c82552
BLAKE2b-256 f8df4cb483b445845fbb6dad26ea824c9afbda0080cd74ca01efc4d8f38f8676

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page