jetbrains / teamcity-messages Goto Github PK
View Code? Open in Web Editor NEWPython Unit Test Reporting to TeamCity
Home Page: https://pypi.python.org/pypi/teamcity-messages
License: Apache License 2.0
Python Unit Test Reporting to TeamCity
Home Page: https://pypi.python.org/pypi/teamcity-messages
License: Apache License 2.0
Current test.id() looks like testa.test_evens(0, 0, '.'). '.' breaks test hierarchy on TeamCity.
Possible solution is replacing . with , so it will look like testa.test_evens(0, 0, '')
The fixture setup is reported as a separate (additional) test.
When the base test is expanded in the build log, the fixture setup line also appears, indented under the base test, but expanding does nothing except display "Loading..." indefinitely.
The fixture setup should NOT be registered as a separate test.
The fixture setup should be expandable under the base test.
Thanks for taking a look,
-Shawn
platform win32 -- Python 2.7.3, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
TeamCity 9.1.5 (build 37377), teamcity-messages 1.17
build log collapsed:
[13:03:23][Step 1/13] Test_pytest.TestClass.test_brie
[13:03:23][Step 1/13]
[13:03:23][Step 1/13] Test_pytest.TestClass.test_brie_setup
[13:03:23][Step 1/13]
[13:03:23][Step 1/13]
[13:03:23][Step 1/13] .
build log expanded:
[13:03:23][Step 1/13] Test_pytest.TestClass.test_brie
[13:03:23] [Test_pytest.TestClass.test_brie]
[13:03:23] [Test_pytest.TestClass.test_brie] Test_pytest.TestClass.test_brie_setup
Loading...
[13:03:23] [Test_pytest.TestClass.test_brie]
[13:03:23] [Test_pytest.TestClass.test_brie]
[13:03:23] [Test_pytest.TestClass.test_brie] .
[13:03:23]
[Test_pytest.TestClass.test_brie] [Test Output]
in test_brie()
[13:03:23] [Test_pytest.TestClass.test_brie]
[13:03:23][Step 1/13]
[13:03:23][Step 1/13] Test_pytest.TestClass.test_brie_setup
[13:03:23] [Test_pytest.TestClass.test_brie_setup]
[13:03:23]
[Test_pytest.TestClass.test_brie_setup] [Test Output]
[setup] cheese_db, connect to db
[13:03:23] [Test_pytest.TestClass.test_brie_setup]
[13:03:23][Step 1/13]
[13:03:23][Step 1/13]
[13:03:23][Step 1/13] .
test code
class TestClass:
@pytest.fixture()
def cheese_db(self, request):
print('\n[setup] cheese_db, connect to db')
# code to connect to your db
a_dictionary_for_now = {'Brie': 'No.', 'Camenbert': 'We do!'}
def fin():
print('\n[teardown] cheese_db finalizer, disconnect from db')
request.addfinalizer(fin)
return a_dictionary_for_now
def test_brie(self, cheese_db):
print('in test_brie()')
assert cheese_db['Brie'] == 'No.'
If you use the simple.py style of modifying the test runner, the build step does not fail if a test fails
It is now nearly impossible to use any other suffix except ".py" for py.test tests with teamcity messages.
There should be a way to set desired file extension or may be it is possible to use re.split by r".\w{1,4}" instead of regular split by ".py" in teamcity.pytest_plugin.EchoTeamCityMessages.format_names
Maybe it's a good time to put out a 1.15 release?
I need the fix in #57 because I get UnicodeEncodeError
s with 1.14.
[10:55:51][Executing: `tox -e py27 -r`] INTERNALERROR> File "/home/teamcity/work/37154a10dc0882b2/.tox/py27/local/lib/python2.7/site-packages/teamcity/messages.py", line 30, in message
[10:55:51][Executing: `tox -e py27 -r`] INTERNALERROR> self.output.write(message)
[10:55:51][Executing: `tox -e py27 -r`] INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode character u'\xf8' in position 3985: ordinal not in range(128)
[10:55:51][Executing: `tox -e py27 -r`]
Cc: @shalupov, @sudarkoff, @djeebus
On the TeamCity build tests page, the test name display has an extra space after the period after the class, and before the test name function name.
This is visually distracting.
TestClass. test_brie(cheese_db)
TestClass. test_cheddar(cheese_db)
This would be less confusing since the package is called teamcity-messages
on PyPI:
https://pypi.python.org/pypi/teamcity-messages
Cc: @sudarkoff, @djeebus
It seems this code is not resilient against race conditions caused by parallel test execution, is it possible to get that fixed?
The readme states that we can install with pip install teamcity-messages
and then use the runner for django TEST_RUNNER = "teamcity.django.TeamcityDjangoRunner"
but the django.py module does not exist in the 1.8 version that is currently in PyPi
If you skip or ignore a test, any information in the skipped message is discarded. I would like this information to be displayed in the UI.
I believe I can make the requisite changes to teamcity messages to make this happen.
test it for each framework
Starting in Django 1.7, the default Django DiscoverRunner introduced support for overriding the test runner (see https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#attributes).
To fully support this, I suggest allowing the __init__
method of the TeamcityTestRunner
to accept more arguments (i.e. adding *args
and **kwargs
), or accepting the verbosity and failfast arguments (perhaps not a bad idea to support these anyway).
An extension of the DiscoverRunner
could then be created as follows
class TeamcityDjangoRunner(DiscoverRunner):
test_runner = TeamcityTestRunner
While at it, this package could add full support for earlier versions by adding a smiple class as follows:
class TeamcityDjangoRunner(DiscoverRunner):
def run_suite(self, suite, **kwargs):
return TeamcityTestRunner().run(suite)
This final class could be provided with this package anyway, perhaps as teamcity.django.DiscoverRunner
.
The plugin API seems to have changed quite a bit in 3.0
One example of a build failure resulting for this: https://teamcity.mesosphere.io/viewLog.html?buildId=343692&buildTypeId=DcosIo_Dcos_CodeQuality&tab=buildLog#_focus=503
Temporary workaround is to pin flake8 to 2.6.2
Sampe backtrace:
flake8.plugins.manager MainProcess 104 INFO Loading entry-points for "flake8.extension".
flake8.plugins.manager MainProcess 152 INFO Loading entry-points for "flake8.listen".
flake8.plugins.manager MainProcess 152 INFO Loading entry-points for "flake8.report".
flake8.plugins.manager MainProcess 152 INFO Loading plugin "pycodestyle.python_3000_has_key" from entry-point.
flake8.plugins.manager MainProcess 158 INFO Loading plugin "pycodestyle.trailing_blank_lines" from entry-point.
flake8.plugins.manager MainProcess 158 INFO Loading plugin "pycodestyle.break_around_binary_operator" from entry-point.
flake8.plugins.manager MainProcess 158 INFO Loading plugin "pycodestyle.explicit_line_join" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.module_imports_on_top_of_file" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.extraneous_whitespace" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.imports_on_separate_lines" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.indentation" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.whitespace_before_parameters" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.python_3000_not_equal" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.python_3000_backticks" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.whitespace_around_named_parameter_equals" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "pycodestyle.python_3000_raise_comma" from entry-point.
flake8.plugins.manager MainProcess 159 INFO Loading plugin "F" from entry-point.
flake8.plugins.manager MainProcess 173 INFO Loading plugin "pycodestyle.missing_whitespace_around_operator" from entry-point.
flake8.plugins.manager MainProcess 173 INFO Loading plugin "pycodestyle.whitespace_around_keywords" from entry-point.
flake8.plugins.manager MainProcess 173 INFO Loading plugin "pycodestyle.comparison_negative" from entry-point.
flake8.plugins.manager MainProcess 173 INFO Loading plugin "pycodestyle.compound_statements" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.continued_indentation" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.maximum_line_length" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.whitespace_before_comment" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.comparison_type" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.missing_whitespace_after_import_keyword" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.tabs_or_spaces" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.missing_whitespace" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.trailing_whitespace" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.whitespace_around_comma" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.comparison_to_singleton" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.blank_lines" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.whitespace_around_operator" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "pycodestyle.tabs_obsolete" from entry-point.
flake8.plugins.manager MainProcess 174 INFO Loading plugin "P999" from entry-point.
flake8.plugins.manager MainProcess 175 INFO Loading plugin "C90" from entry-point.
flake8.plugins.manager MainProcess 175 INFO Loading plugin "pylint" from entry-point.
flake8.plugins.manager MainProcess 176 INFO Loading plugin "default" from entry-point.
Traceback (most recent call last):
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/plugins/manager.py", line 184, in provide_options
parse_options(optmanager, options, extra_args)
TypeError: parse_options() takes 1 positional argument but 3 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".tox/py34-syntax/bin/flake8", line 11, in <module>
sys.exit(main())
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/main/application.py", line 299, in run
self._run(argv)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/main/application.py", line 285, in _run
self.initialize(argv)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/main/application.py", line 277, in initialize
self.parse_configuration_and_cli(argv)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/main/application.py", line 172, in parse_configuration_and_cli
self.args)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/plugins/manager.py", line 395, in provide_options
list(self.manager.map(call_provide_options))
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/plugins/manager.py", line 261, in map
yield func(self.plugins[name], *args, **kwargs)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/plugins/manager.py", line 357, in generated_function
return method(optmanager, *args, **kwargs)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/flake8/plugins/manager.py", line 186, in provide_options
parse_options(options)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/teamcity/flake8_plugin.py", line 33, in parse_options
options.report = TeamcityReport(options)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/pycodestyle.py", line 1756, in __init__
super(StandardReport, self).__init__(options)
File "/teamcity/work/19ad0dff41587ee6/.tox/py34-syntax/lib/python3.4/site-packages/pycodestyle.py", line 1662, in __init__
self._benchmark_keys = options.benchmark_keys
AttributeError: 'Values' object has no attribute 'benchmark_keys'
I get a UnicodeEncodeError
in Python 2.7 when sys.stdout.encoding
is None
and Unicode is sent -- e.g.:
Traceback (most recent call last):
File "/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmp5eApc3", line 7, in <module>
messages.message(bjork)
File "/Users/marca/dev/git-repos/teamcity-python/teamcity/messages.py", line 30, in message
self.output.write(message)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 14: ordinal not in range(128)
PR #57 fixes this for me.
Using TC Enterprise 7.15 (build 24400), teamcity-message 1.7, pytest 2.4,2 and python 2.7.5.
While py.test tets failures are correctly picked up and reported, py.test errors (e.g. a runtime error outside of an assert statement) - though correctly marked with an E in the messages received in the TC build log - are ignored and the test is treated as successful.
Hi,
Is it possible to use teamcity-messages to report coverage with the django test runner? I see in the code that it is indeed possible with nose and pytest, however I don't see any code that would allow the same thing for the django test runner.
If I understand the current code correctly the only option to include coverage reports in teamcity is to do that via artefacts. Am I right, or am I missing something?
or maybe Python >= 2.6, but please nothing older than that.
Python 2.5.6 was released in May of 2011.
under the current release policy, no security issues in Python 2.5 will be fixed anymore.
Bumping to teamcity-messages 2.0 would allow dropping these old versions of Python. This would make development and testing easier and would make for cleaner code. Also then teamcity-messages
could support newer Python features like context managers. Imagine something like:
with TeamcityServiceMessages.block('<blockName>'):
do_stuff()
do_more_stuff()
oh_one_more_thing()
Folks using Python 2.4 or 2.5 could use the old versions of teamcity-messages.
Cc: @djeebus, @sudarkoff
I want to run different python configurations in one teamcity build. But tests squashed, because they have the same name (the same nodeid
). Is it possible to implement functionality allowing differ tests with same name based on current build configuration (python version, Django version, some-other-package version)?
If you don't mind, I can try to implement this myself for pytest
plugin and open pull-request. I think, that it may be additional cli-option and specific environ-variable, which I can set up before running tests.
In teamcity.django there's an import
from django.test.runner import DiscoverRunner
which works fine if you're on python 3 and absolute imports are the default. If you're on python 2 and this isn't the case... then this will fail with a
ImportError: No module named test.runner
Since it's attempting a relative import first, finding itself as the 'django' module (teamcity/django.py), and then unable to import test.runner from itself.
A fix is to add a from __future__ import absolute_import
here. This is compatible with python 2.5 and forward. I'll open a pull request that does this.
I had a problem with encoding on teamcity agent.
encoding set's auromcatically to cp1252 so I got
[16:02:09][Step 4/6] INTERNALERROR> File "c:\python35\lib\site-packages\teamcity\messages.py", line 104, in testStarted
[16:02:09][Step 4/6] INTERNALERROR> self.message('testStarted', name=testName, captureStandardOutput=captureStandardOutput, flowId=flowId)
[16:02:09][Step 4/6] INTERNALERROR> File "c:\python35\lib\site-packages\teamcity\messages.py", line 57, in message
[16:02:09][Step 4/6] INTERNALERROR> message = message.encode(self.encoding)
[16:02:09][Step 4/6] INTERNALERROR> File "c:\python35\lib\encodings\cp1252.py", line 12, in encode
[16:02:09][Step 4/6] INTERNALERROR> return codecs.charmap_encode(input,errors,encoding_table)
[16:02:09][Step 4/6] INTERNALERROR> UnicodeEncodeError: 'charmap' codec can't encode characters in position 139-145: character maps to
This looks's like a windows problem, not python or teamcity-messages.
To solve this I tried to unregister plugin and register again with
def fixed_configure(config):
if config.option.no_teamcity >= 1:
enabled = False
elif config.option.teamcity >= 1:
enabled = True
else:
enabled = is_running_under_teamcity()
if enabled:
output_capture_enabled = getattr(config.option, 'capture', 'fd') != 'no'
coverage_controller = _get_coverage_controller(config)
config._teamcityReporting = EchoTeamCityMessages(output_capture_enabled,
coverage_controller)
config._teamcityReporting.teamcity.encoding = 'utf8'
config.pluginmanager.register(config._teamcityReporting)
function
But unconfiguring didn't work as I expected. Info about plugin deletes from pluginmanager attributes but messages for teamcity stiil printing to stdout. (So if I both unregister and register patched version it's prints all messages twice - with old and new encoding).
Code to unregister module:
plugin = config.pluginmanager.getplugin("pytest-teamcity")
plugin.pytest_unconfigure(config)
Or more manually
plugin = config.pluginmanager.getplugin("pytest-teamcity")
config.pluginmanager.unregister(plugin)
config.pluginmanager._plugin2hookcallers.pop(sys.modules['teamcity.pytest_plugin'])
Both doesn't work as expected.
P.S. I create pull request that solves original problem, but this behaviour with unregistering looks like a bug, so I decide to create this issue.
teamcity-messages for flake8 pulls in pep8 directly:
But flake8 2.6.0 (recently released) swiced to pycodestyle
instead of pep8
as the binary to run.
This makes it so that CI jobs fail since pep8
can't be imported (And isn't dependend upon by teamcity-messages).
doing a try/catch around import pycodestyle as pep8
or something similar will likely fix this.
Sample failed build (use guest login):
https://teamcity.mesosphere.io/viewLog.html?buildId=298303&buildTypeId=DcosIo_Dcos_CodeQuality&tab=buildLog#_focus=413
I'm running into quite a serious issue after upgrading an Anaconda installation. I'm running Python 2.7. In this case, it is Python running on a TeamCity build agent, which is 32-bit. I'm using the latest stable versions of all packages, including teamcity-messages 1.8.
Here is an example of the error:
[19:09:16][unit] test_data_frame_serializer
[19:09:16] [test_data_frame_serializer]
[19:09:16] [test_data_frame_serializer] TestDataFrameSerializer
[19:09:16] [TestDataFrameSerializer]
[19:09:16] [TestDataFrameSerializer] test_serialize_deserialize (platform.tests.unit.test_data_frame_serializer.TestDataFrameSerializer)
[19:09:16] [test_serialize_deserialize (platform.tests.unit.test_data_frame_serializer.TestDataFrameSerializer)] ok
[19:09:16] [test_serialize_deserialize (platform.tests.unit.test_data_frame_serializer.TestDataFrameSerializer)] INTERNAL ERROR: stopTest(Test that we can encode and decode all the data types we are interested in.) after startTest(test_serialize_deserialize (platform.tests.unit.test_data_frame_serializer.TestDataFrameSerializer))
[19:09:16] [TestDataFrameSerializer]
[19:09:16] [test_data_frame_serializer]
[19:09:16][unit]
This happens for every single test in the project. It seems like the problem is related to #24, #25 and #26, but also this quite old issue, and occurs at line 84 in the project.
In the example above, Test that we can encode and decode all the data types we are interested in.
is actually the short description for test_serialize_deserialize (platform.tests.unit.test_data_frame_serializer.TestDataFrameSerializer)
, so the internal error is a false positive.
It seems like the error is due to a Python unittest API change, but I am unable to find the information. Even so, it seems like this is an issue that must be fixed in teamcity-messages.
What really gets me, is that the same getTestName
returns two different results when invoked from startTest
and stopTest
respectively: Clearly unittest.getShortDescription
returns None
during the execution of stopTest
, which to me is bizarre.
Is anybody able to shed some light on the issue?
Doesn't work with Python 3.2
I have appium/selenium pytests running on a teamcity build agent. When ran with pytest-xdist with the -n2
argument. It will triple the test count. I can see in teamcity the test names collected and the setup/teardown for each test is being counted as a test.
Without the -n2
is counts correctly.
So my pytest command looks like py.test -n2 -v -s
and I have tried without the -v -s
and a sample of my build log in teamcity looks like
[13:00:33][Step 3/4] [gw0] darwin Python 3.4.3 cwd: /Applications/buildAgent/work/afcaa9d3bd472074/skywalker/SeleniumTests
[13:00:33][Step 3/4] [gw1] darwin Python 3.4.3 cwd: /Applications/buildAgent/work/afcaa9d3bd472074/skywalker/SeleniumTests
[13:00:34][Step 3/4] [gw1] Python 3.4.3 (default, Apr 27 2015, 19:08:17) -- [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)]
[13:00:34][Step 3/4] [gw0] Python 3.4.3 (default, Apr 27 2015, 19:08:17) -- [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)]
[13:00:35][Step 3/4] gw0 [49] / gw1 [49]
[13:00:35][Step 3/4]
[13:00:35][Step 3/4] scheduling tests via LoadScheduling
[13:00:35][Step 3/4]
[13:00:35][Step 3/4] mobile_apps/modi/test_ipad_modi.py::TestIpad2::test_admin_login <- mobile_apps/modi/tests_common_modi.py
[13:00:35][Step 3/4] mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login (50s)
[13:00:35][Step 3/4]
[13:00:35][Step 3/4] mobile_apps/modi/test_ipad_modi.py::TestIpad2::test_football_athlete_menu <- mobile_apps/modi/tests_common_modi.py
[13:00:35][Step 3/4] mobile_apps.modi.test_ipad_modi.TestIpad2.test_football_athlete_menu (52s)
[13:01:19][Step 3/4]
[13:01:19][Step 3/4] mobile_apps.modi.test_ipad_modi.TestIpad2.test_football_athlete_menu_setup
[13:01:19][Step 3/4]
[13:01:19]
[mobile_apps.modi.test_ipad_modi.TestIpad2.test_football_athlete_menu_setup] [Test Output]
[13:01:19][Step 3/4]
[13:01:19]
[mobile_apps.modi.test_ipad_modi.TestIpad2.test_football_athlete_menu_setup] [Test Error Output]
[13:01:19][Step 3/4]
[13:01:20][Step 3/4]
[13:01:20][Step 3/4] mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login_setup
[13:01:20][Step 3/4]
[13:01:20]
[mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login_setup] [Test Output]
[13:01:20][Step 3/4]
[13:01:20]
[mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login_setup] [Test Error Output]
[13:01:20][Step 3/4]
[13:01:25][Step 3/4]
[13:01:25][Step 3/4] [gw1] PASSED mobile_apps/modi/test_ipad_modi.py::TestIpad2::test_admin_login <- mobile_apps/modi/tests_common_modi.py
[13:01:25]
[mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login] [Test Error Output]
INFO 2015-09-14 13:01:04,999 base:803:log_page_load: Page Loaded: LoginScreenView
INFO 2015-09-14 13:01:07,721 base:803:log_page_load: Page Loaded: HomePageView
INFO 2015-09-14 13:01:09,720 base_modi:66:open_menu: Menu already open, skipping...
INFO 2015-09-14 13:01:09,722 base:803:log_page_load: Page Loaded: MainMenuView
[13:01:25][Step 3/4]
[13:01:26][Step 3/4]
[13:01:26][Step 3/4] mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login_teardown
[13:01:26][Step 3/4]
[13:01:26]
[mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login_teardown] [Test Output]
[13:01:26][Step 3/4]
[13:01:26]
[mobile_apps.modi.test_ipad_modi.TestIpad2.test_admin_login_teardown] [Test Error Output]
INFO 2015-09-14 13:01:10,703 base_modi:66:open_menu: Menu already open, skipping...
INFO 2015-09-14 13:01:10,703 base:803:log_page_load: Page Loaded: MainMenuView
[13:01:26][Step 3/4]
[13:01:26][Step 3/4]
Has anybody seen a situation like this?
Python3.4
pytest = 2.7.2
teamcity-messages = 1.16
TeamCity = 8.1.4
The current team city reporters do not yet include a plugin that supports nose2: https://github.com/nose-devs/nose2
Hi,
So I'm using this plugin and loving it. Tried to upgrade our testing to multiproccess (runs locally without a problem)
And the build fails with
AttributeError: 'NoSharedFixtureContextSuite' object has no attribute 'test'
When I manually go to the the server and run nosetests with this command, it works
nosetests --processes=1 --process-timeout=520 tests
But the same build step fails inside teamcity
I use teamcity-python with nose.
I had the following problem after upgrade package from v1.8 to v1.12:
Traceback (most recent call last):
File "/envs/local/lib/python2.7/site-packages/nose/case.py", line 133, in run
self.runTest(result)
File "/envs/local/lib/python2.7/site-packages/nose/case.py", line 151, in runTest
test(result)
File "/envs/local/lib/python2.7/site-packages/django/test/testcases.py", line 184, in __call__
super(SimpleTestCase, self).__call__(result)
File "/usr/lib/python2.7/unittest/case.py", line 391, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
result.addFailure(self, sys.exc_info())
File "/envs/local/lib/python2.7/site-packages/nose/proxy.py", line 146, in addFailure
plugins.addFailure(self.test, err)
File "/envs/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__
return self.call(*arg, **kw)
File "/envs/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple
result = meth(*arg, **kw)
File "/envs/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 346, in addFailure
return self.plugin.addFailure(test.test, err, capt, tbinfo)
TypeError: addFailure() takes exactly 3 arguments (5 given)
and
Traceback (most recent call last):
[01:59:50][Step 1/1] File "manage.py", line 18, in <module>
[01:59:50][Step 1/1] execute_from_command_line(sys.argv)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
[01:59:50][Step 1/1] utility.execute()
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
[01:59:50][Step 1/1] self.fetch_command(subcommand).run_from_argv(self.argv)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
[01:59:50][Step 1/1] super(Command, self).run_from_argv(argv)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
[01:59:50][Step 1/1] self.execute(*args, **options.__dict__)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 71, in execute
[01:59:50][Step 1/1] super(Command, self).execute(*args, **options)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
[01:59:50][Step 1/1] output = self.handle(*args, **options)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/south/management/commands/test.py", line 8, in handle
[01:59:50][Step 1/1] super(Command, self).handle(*args, **kwargs)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 88, in handle
[01:59:50][Step 1/1] failures = test_runner.run_tests(test_labels)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django_nose/runner.py", line 218, in run_tests
[01:59:50][Step 1/1] result = self.run_suite(nose_argv)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/django_nose/runner.py", line 165, in run_suite
[01:59:50][Step 1/1] addplugins=plugins_to_add)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
[01:59:50][Step 1/1] **extra_args)
[01:59:50][Step 1/1] File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
[01:59:50][Step 1/1] self.runTests()
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/core.py", line 207, in runTests
[01:59:50][Step 1/1] result = self.testRunner.run(self.test)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/core.py", line 62, in run
[01:59:50][Step 1/1] test(result)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/suite.py", line 177, in __call__
[01:59:50][Step 1/1] return self.run(*arg, **kw)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/suite.py", line 224, in run
[01:59:50][Step 1/1] test(orig)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/suite.py", line 177, in __call__
[01:59:50][Step 1/1] return self.run(*arg, **kw)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/suite.py", line 224, in run
[01:59:50][Step 1/1] test(orig)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/case.py", line 45, in __call__
[01:59:50][Step 1/1] return self.run(*arg, **kwarg)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/case.py", line 138, in run
[01:59:50][Step 1/1] result.addError(self, err)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/proxy.py", line 131, in addError
[01:59:50][Step 1/1] plugins.addError(self.test, err)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__
[01:59:50][Step 1/1] return self.call(*arg, **kw)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple
[01:59:50][Step 1/1] result = meth(*arg, **kw)
[01:59:50][Step 1/1] File "/envs/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 334, in addError
[01:59:50][Step 1/1] return self.plugin.addError(test.test, err, capt)
[01:59:50][Step 1/1] TypeError: addError() takes exactly 3 arguments (4 given)
I think the problem is there: ac26258
TeamCity 8.1.5
teamcity-python 1.12
nose 1.3.0, 1.3.4
django-nose 1.2, 1.3
I`ve created pull request #41.
testStdOut
and testStdErr
service messages are not printed by pytest_plugin. Without these service messages, stdout and stderr are not visible in the test details on TeamCity.
In messages.py, there is the following line:
self.output.write("\n##teamcity[%s timestamp='%s'" % (messageName, self.now().isoformat()[:-3]))
This should take a standard datetime string, e.g. 2014-09-15T12:31:55.123456 and generate 2014-09-15T12:31:55.123, i.e. microseconds truncated to become milliseconds.
However, this doesn't always work. At time 12:31:55.000000, isoformat() drops the microseconds field completely. Then we get a timestamp of 2014-09-15T12:31, which is missing the seconds.
The fix for this seems to be to replace the output line with
self.output.write("\n##teamcity[%s timestamp='%s'" % (messageName, self.now().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]))
This guarantees the string will always be the correct format for TeamCity.
When using the xfail (expected failure) mark on a test, teamcity-messages treats an XPASS result (when the test unexpectedly passes) as a failure state even though PyTest only considers an unexpected pass to be a failure of the test when strict is set to True in the xfail mark.
Can some one please provide detailed insight on how to run 'nosetests' with python unit tests in team city.
Note: I have gotten this working like a champ outside of teamcity.
Thanks
Zine
When I run py.test -n 8 teamcity
to parallelize my test; testSuiteStarted, testStarted, and testSuiteFinished messages are missing.
Without xdist:
##teamcity[testSuiteStarted timestamp='2013-09-15T16:46:48.153' name='test_hello.py']
##teamcity[testStarted timestamp='2013-09-15T16:46:48.168' name='test_eval[3+5-8|]']
.
##teamcity[testFinished timestamp='2013-09-15T16:46:48.169' duration='0' name='test_eval[3+5-8|]']
With xdist:
scheduling tests via LoadScheduling
.
##teamcity[testFinished timestamp='2013-09-15T16:47:01.311' duration='1' name='test_eval[2+4-6|]']
.
##teamcity[testFinished timestamp='2013-09-15T16:47:01.311' duration='0' name='test_eval[3+5-8|]']
F
Hey, sorry to not have a lot of details, but I see the appveyor built haven't run in the last 4 months. Since we've bumped pytest, teamcity-message doesn't seems to work with pytest messages.
Successful tests seems to be counted correctly, but failures are reported in the Build errors
section outside of the usual teamcity test failure reporting.
From the Teamcity log, I can see that the FAILED
status is not of the same line as the test name for some result, so this might be related:
[14:37:58][Step 4/8] test.test_name
[14:37:59][test.test_name]
[14:37:59][Step 4/8]
[14:37:59][Step 4/8]
[14:37:59][Step 4/8]
[14:37:59][Step 4/8] FAILED
This might also be related to the pytest flaky
plugin as it'll retry failing tests 4 times in our settings.
When using with dynamic tests, suites with random names are produced. It causes that TeamCity treats all failures as new because they are always in different suites.
Example:
case_data = [1,2,3]
def checkValue(value):
assert value == 2
def test_cases():
for case in case_data:
yield checkValue, case
The output produces messages like the following:
##teamcity[testSuiteStarted name='<function test_cases at 0x00000000029ADBA8>']
...
##teamcity[testSuiteFinished name='<function test_cases at 0x00000000029ADBA8>']
it happens, cause their nodeid are same (file path is used)
so
def pytest_runtest_logstart(self, nodeid, location):
self.ensure_test_start_reported(self.format_test_id(nodeid))
will skip the slowest one from pep8/pylint
Here is nodeid + location in both cases:
['PATH/file.py', ('PATH\\file.py', None, '[pylint] PATH/file.py')]
['PATH/file.py', ('PATH\\file.py', -1, 'PEP8-check(ignoring E731 W601 E721)')]
Hi there!
We started using teamcity-messages
recently and had noticed that names of tests are formatted differently from XML report generated by pytest
. This mismatch could lead to 2 issues:
Example. If we had test test_check_foo
in test_bar.py
module, then
XML report would show name of the test as test_bar.test_check_foo
, but teamcity-messages
would format name of the test to test_bar_py.test_check_foo
.
Is it possible to fix this issue?
The line
package init file 'twisted/plugins/init.py' not found (or not a regular file)
Is on stderr during installation, is this intentional?
The version number in flake8_plugin.py
is out of date at 1.9
, which is several versions ago.
https://github.com/JetBrains/teamcity-messages/blob/master/teamcity/flake8_plugin.py#L8
Clearly, it's a burden to have to remember to update the version number in both setup.py
and here, so it probably makes sense to move to something like setuptools_scm
. See #81
Instead of using str
to get the name of a test, the unittestpy test runner should use id()
to obtain the test name. This ensures that TeamCity is able to understand the hierarchy of the tests.
Rewriting getTestName
to the following produces the desired result:
def getTestName(self, test):
desc = test.shortDescription()
if desc:
return "%s (%s)" % (test.id(), desc)
return test.id()
Including the description with the test (which is done currently) may however be undesirable, as the test description could change while the method signature could remain the same.
See 9a13433
Without it all test output will be serialized in one testFailed service message (in details field). Which is way too big for service messages.
Hey guys,
I'm running my python tests under TeamCity with the teamcity-messages plugin. It all works great but it overrides the coverage reports.
If I unset the TEAMCITY_PROJECT_NAME variable it generates the coverage reports if I have it enabled it fails to do so.
My command is:
nosetests . --nocapture --with-coverage --cover-package=resources --cover-erase --cover-html-dir=coverage --cover-html
My guess is that you don't let any other plugin run after teamcity-messages.
Thanks in advance,
Bogdan
It seems that this uses a function that existed in coverage 3.7.1 called find_code_units
and that function no longer exists in coverage 4.0.
I couldn't quite figure out what the equivalent would be in coverage 4.0 but didn't spend much time on it. I wonder if @nedbat might be able to advise.
Tests fail in 4 build configurations from 7, we could not continue to develop or merge pull requests.
Tests must be fixed or rewritten (if fix is impossible).
teamcity/messages.py#63
Problem: Method "_single_value_message" has no argument "flowId"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.