/usr/lib/python3/dist-packages/nose2/runner.py is in python3-nose2 0.7.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # This module contains some code copied from unittest2/runner.py and other
# code developed in reference to that module and others within unittest2.
# unittest2 is Copyright (c) 2001-2010 Python Software Foundation; All
# Rights Reserved. See: http://docs.python.org/license.html
import time
from nose2 import events, result
__unittest = True
class PluggableTestRunner(object):
"""Test runner that defers most work to plugins.
:param session: Test run session
.. attribute :: resultClass
Class to instantiate to create test result. Default:
:class:`nose2.result.PluggableTestResult`.
"""
resultClass = result.PluggableTestResult
def __init__(self, session):
self.session = session
def run(self, test):
"""Run tests.
:param test: A unittest :class:`TestSuite`` or :class:`TestClass`.
:returns: Test result
Fires :func:`startTestRun` and :func:`stopTestRun` hooks.
"""
result = self._makeResult()
executor = lambda suite, result: suite(result)
startTime = time.time()
event = events.StartTestRunEvent(
self, test, result, startTime, executor)
self.session.hooks.startTestRun(event)
# allows startTestRun to modify test suite
test = event.suite
# ... and test execution
executor = event.executeTests
try:
if not event.handled:
executor(test, result)
finally:
stopTime = time.time()
timeTaken = stopTime - startTime
event = events.StopTestRunEvent(self, result, stopTime, timeTaken)
self.session.hooks.stopTestRun(event)
self.session.hooks.afterTestRun(event)
return result
def _makeResult(self):
result = self.resultClass(self.session)
event = events.ResultCreatedEvent(result)
self.session.hooks.resultCreated(event)
self.session.testResult = event.result
return event.result
def __repr__(self):
return '<%s>' % self.__class__.__name__
|