JetBrains / teamcity-messages

Python Unit Test Reporting to TeamCity
https://pypi.python.org/pypi/teamcity-messages
Apache License 2.0
137 stars 81 forks source link

Please provide time for subtests #137

Open throwable-one opened 7 years ago

throwable-one commented 7 years ago
import time
import unittest

class SampleTest(unittest.TestCase):
    def test_sample(self):
        for i in range(10):
            with self.subTest(i=i):
                time.sleep(i/10)
##teamcity[testStarted timestamp='2017-05-05T00:15:53.797' captureStandardOutput='true' flowId='foo.SampleTest.test_sample' name='foo.SampleTest.test_sample']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.299' flowId='foo.SampleTest.test_sample' name='(i=0)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.299' flowId='foo.SampleTest.test_sample' name='(i=0)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.299' flowId='foo.SampleTest.test_sample' name='(i=1)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.299' flowId='foo.SampleTest.test_sample' name='(i=1)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.299' flowId='foo.SampleTest.test_sample' name='(i=2)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.299' flowId='foo.SampleTest.test_sample' name='(i=2)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=3)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=3)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=4)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=4)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=5)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=5)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=6)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=6)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.300' flowId='foo.SampleTest.test_sample' name='(i=7)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.301' flowId='foo.SampleTest.test_sample' name='(i=7)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.301' flowId='foo.SampleTest.test_sample' name='(i=8)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.301' flowId='foo.SampleTest.test_sample' name='(i=8)']
##teamcity[blockOpened timestamp='2017-05-05T00:15:58.301' flowId='foo.SampleTest.test_sample' name='(i=9)' subTestResult='Success']
##teamcity[blockClosed timestamp='2017-05-05T00:15:58.301' flowId='foo.SampleTest.test_sample' name='(i=9)']
##teamcity[testFinished timestamp='2017-05-05T00:15:58.301' duration='4504' flowId='foo.SampleTest.test_sample' name='foo.SampleTest.test_sample']

Duration for whole test is good, but can I have duration for each subtest: https://youtrack.jetbrains.com/issue/PY-23983

shalupov commented 7 years ago

It is impossible with current API provided by unittest