Ejemplo n.º 1
0
    def __init__(self,
                 test_id,
                 short_description=None,
                 details=None,
                 outcome='addSuccess',
                 error=None,
                 tags=None,
                 timestamps=(None, None)):
        """Construct a `PlaceHolder`.

        :param test_id: The id of the placeholder test.
        :param short_description: The short description of the place holder
            test. If not provided, the id will be used instead.
        :param details: Outcome details as accepted by addSuccess etc.
        :param outcome: The outcome to call. Defaults to 'addSuccess'.
        :param tags: Tags to report for the test.
        :param timestamps: A two-tuple of timestamps for the test start and
            finish. Each timestamp may be None to indicate it is not known.
        """
        self._test_id = test_id
        self._short_description = short_description
        self._details = details or {}
        self._outcome = outcome
        if error is not None:
            self._details['traceback'] = content.TracebackContent(error, self)
        tags = tags or frozenset()
        self._tags = frozenset(tags)
        self._timestamps = timestamps
Ejemplo n.º 2
0
 def _report_traceback(self, exc_info, tb_label='traceback'):
     id_gen = self._traceback_id_gens.setdefault(
         tb_label, itertools.count(0))
     tb_id = advance_iterator(id_gen)
     if tb_id:
         tb_label = '%s-%d' % (tb_label, tb_id)
     self.addDetail(tb_label, content.TracebackContent(exc_info, self))
Ejemplo n.º 3
0
 def test_add_xfail(self):
     self.result.startTest(self)
     try:
         raise ZeroDivisionError('Math is hard!')
     except ZeroDivisionError:
         error = sys.exc_info()
     self.result.addExpectedFailure(self, error)
     self.result.stopTest(self)
     self.assertCalled(
         status='xfail',
         details={'traceback': content.TracebackContent(error, self)})
Ejemplo n.º 4
0
 def test_add_failure(self):
     self.result.startTest(self)
     try:
         self.fail("intentional failure")
     except self.failureException:
         failure = sys.exc_info()
     self.result.addFailure(self, failure)
     self.result.stopTest(self)
     self.assertCalled(
         status='failure',
         details={'traceback': content.TracebackContent(failure, self)})
Ejemplo n.º 5
0
 def _report_traceback(self, exc_info, tb_label='traceback'):
     id_gen = self._traceback_id_gens.setdefault(
         tb_label, itertools.count(0))
     while True:
         tb_id = next(id_gen)
         if tb_id:
             tb_label = '%s-%d' % (tb_label, tb_id)
         if tb_label not in self.getDetails():
             break
     self.addDetail(tb_label, content.TracebackContent(
         exc_info, self, capture_locals=getattr(
             self, '__testtools_tb_locals__', False)))
Ejemplo n.º 6
0
 def _report_traceback(self, exc_info, tb_label="traceback"):
     id_gen = self._traceback_id_gens.setdefault(tb_label,
                                                 itertools.count(0))
     while True:
         tb_id = advance_iterator(id_gen)
         if tb_id:
             tb_label = "%s-%d" % (tb_label, tb_id)
         if tb_label not in self.getDetails():
             break
     self.addDetail(
         tb_label,
         content.TracebackContent(exc_info,
                                  self,
                                  capture_locals=getattr(
                                      self, "__testtools_tb_locals__",
                                      False)),
     )
Ejemplo n.º 7
0
    def __init__(self,
                 test_id,
                 short_description=None,
                 details=None,
                 outcome='addSuccess',
                 error=None):
        """Construct a `PlaceHolder`.

        :param test_id: The id of the placeholder test.
        :param short_description: The short description of the place holder
            test. If not provided, the id will be used instead.
        :param details: Outcome details as accepted by addSuccess etc.
        :param outcome: The outcome to call. Defaults to 'addSuccess'.
        """
        self._test_id = test_id
        self._short_description = short_description
        self._details = details or {}
        self._outcome = outcome
        if error is not None:
            self._details['traceback'] = content.TracebackContent(error, self)