Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_outcome_processing_successful_test(self):
test_function = _test_func
ev = events.TestOutcomeEvent(test_function, None, result.PASS)
reporter = create_plugin_instance()
reporter.testOutcome(ev)
self.assertEqual(len(reporter.test_results), 1, 'Actual contents: %s' % reporter.test_results)
test_result = reporter.test_results[0]
self.assertEqual(test_result['result'], result.PASS)
self.assertEqual(test_result['name'], test_function.__name__)
self.assertEqual(test_result['description'], test_function.__doc__)
self.assertIsNone(test_result['traceback'])
def test_summary_stats_increment(self):
ev = events.TestOutcomeEvent(_test_func, None, result.PASS)
reporter = create_plugin_instance()
reporter.summary_stats['passed'] = 10
reporter.testOutcome(ev)
self.assertIn('passed', reporter.summary_stats)
self.assertEqual(reporter.summary_stats['passed'], 11)
def test_summary_stats_total(self):
ev = events.TestOutcomeEvent(_test_func, None, result.PASS)
reporter = create_plugin_instance()
for i in range(0, 20):
reporter.testOutcome(ev)
self.assertIn('passed', reporter.summary_stats)
self.assertEqual(reporter.summary_stats['total'], 20)
def addFailure(self, test, err):
"""Test case resulted in failure.
Fires :func:`setTestOutcome` and :func:`testOutcome` hooks.
"""
event = events.TestOutcomeEvent(test, self, FAIL, err)
self.session.hooks.setTestOutcome(event)
self.session.hooks.testOutcome(event)
def addUnexpectedSuccess(self, test):
"""Test case resulted in unexpected success.
Fires :func:`setTestOutcome` and :func:`testOutcome` hooks.
"""
event = events.TestOutcomeEvent(test, self, PASS)
self.session.hooks.setTestOutcome(event)
self.session.hooks.testOutcome(event)
def __init__(self, test, result, outcome, exc_info=None, reason=None,
expected=False, shortLabel=None, longLabel=None, **kw):
self.test = test
self.result = result
self.outcome = outcome
self.exc_info = exc_info
self.reason = reason
self.expected = expected
self.shortLabel = shortLabel
self.longLabel = longLabel
super(TestOutcomeEvent, self).__init__(**kw)
def addSkip(self, test, reason):
"""Test case was skipped.
Fires :func:`setTestOutcome` and :func:`testOutcome` hooks.
"""
event = events.TestOutcomeEvent(test, self, SKIP, reason=reason)
self.session.hooks.setTestOutcome(event)
self.session.hooks.testOutcome(event)
def addSuccess(self, test):
"""Test case resulted in success.
Fires :func:`setTestOutcome` and :func:`testOutcome` hooks.
"""
event = events.TestOutcomeEvent(test, self, PASS, expected=True)
self.session.hooks.setTestOutcome(event)
self.session.hooks.testOutcome(event)