Exemple #1
0
    def setUp(self):
        self.config = trial.Options()
        # whitebox hack a reporter in, because plugins are CACHED and will
        # only reload if the FILE gets changed.

        parts = reflect.qual(CapturingReporter).split('.')
        package = '.'.join(parts[:-1])
        klass = parts[-1]
        plugins = [
            twisted_trial._Reporter("Test Helper Reporter",
                                    package,
                                    description="Utility for unit testing.",
                                    longOpt="capturing",
                                    shortOpt=None,
                                    klass=klass)
        ]

        # XXX There should really be a general way to hook the plugin system
        # for tests.
        def getPlugins(iface, *a, **kw):
            self.assertEqual(iface, IReporter)
            return plugins + list(self.original(iface, *a, **kw))

        self.original = plugin.getPlugins
        plugin.getPlugins = getPlugins

        self.standardReport = [
            'startTest', 'addSuccess', 'stopTest', 'startTest', 'addSuccess',
            'stopTest', 'startTest', 'addSuccess', 'stopTest', 'startTest',
            'addSuccess', 'stopTest', 'startTest', 'addSuccess', 'stopTest',
            'startTest', 'addSuccess', 'stopTest', 'startTest', 'addSuccess',
            'stopTest'
        ]
    def setUp(self):
        self.runners = []
        self.config = trial.Options()
        # whitebox hack a reporter in, because plugins are CACHED and will
        # only reload if the FILE gets changed.

        parts = reflect.qual(CapturingReporter).split('.')
        package = '.'.join(parts[:-1])
        klass = parts[-1]
        plugins = [twisted_trial._Reporter(
            "Test Helper Reporter",
            package,
            description="Utility for unit testing.",
            longOpt="capturing",
            shortOpt=None,
            klass=klass)]


        # XXX There should really be a general way to hook the plugin system
        # for tests.
        def getPlugins(iface, *a, **kw):
            self.assertEqual(iface, IReporter)
            return plugins + list(self.original(iface, *a, **kw))

        self.original = plugin.getPlugins
        plugin.getPlugins = getPlugins

        self.standardReport = ['startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest',
                               'startTest', 'addSuccess', 'stopTest']
import sys
from teamcity.unittestpy import TeamcityTestResult
from twisted.trial.reporter import Reporter
from twisted.plugins.twisted_trial import _Reporter


class TeamcityReporter(TeamcityTestResult, Reporter):

    def __init__(self,
                 stream=sys.stdout,
                 tbformat='default',
                 realtime=False,
                 publisher=None):
        TeamcityTestResult.__init__(self)
        Reporter.__init__(self,
                          stream=stream,
                          tbformat=tbformat,
                          realtime=realtime,
                          publisher=publisher)

Teamcity = _Reporter("Teamcity Reporter",
                     "twisted.plugins.teamcity_plugin",
                     description="teamcity messages",
                     longOpt="teamcity",
                     shortOpt="teamcity",
                     klass="TeamcityReporter")
        try:
            return self.value[key]
        except (KeyError, TypeError):
            return None


class TeamcityReporter(TeamcityTestResult, Reporter):
    def __init__(self,
                 stream=sys.stdout,
                 tbformat='default',
                 realtime=False,
                 publisher=None):
        TeamcityTestResult.__init__(self)
        Reporter.__init__(self,
                          stream=stream,
                          tbformat=tbformat,
                          realtime=realtime,
                          publisher=publisher)

    def addError(self, test, failure, *k):
        super(TeamcityReporter, self).addError(test, FailureWrapper(failure),
                                               *k)


Teamcity = _Reporter("Teamcity Reporter",
                     "twisted.plugins.teamcity_plugin",
                     description="teamcity messages",
                     longOpt="teamcity",
                     shortOpt="teamcity",
                     klass="TeamcityReporter")