Ticket #5965: runner_port3.patch

File runner_port3.patch, 1.8 KB (added by realcr, 2 years ago)

minor changes to runner.py for python3 porting.

  • twisted/trial/runner.py

    diff --git twisted/trial/runner.py twisted/trial/runner.py
    index 4275c24..12f93c6 100644
    A miscellany of code used to run Trial tests. 
    88Maintainer: Jonathan Lange
    99"""
    1010
     11from __future__ import print_function,division,absolute_import
     12from twisted.python.compat import _PY3
     13
    1114__all__ = [
    1215    'TestSuite',
    1316
    from twisted.trial.reporter import _ExitWrapper, UncleanWarningsReporterWrapper 
    3336# These are imported so that they remain in the public API for t.trial.runner
    3437from twisted.trial.unittest import TestSuite
    3538
    36 from zope.interface import implements
     39from zope.interface import implementer
    3740
    3841pyunit = __import__('unittest')
    3942
    def isTestCase(obj): 
    252255
    253256
    254257
     258@implementer(ITestCase)
    255259class TestHolder(object):
    256260    """
    257261    Placeholder for a L{TestCase} inside a reporter. As far as a L{TestResult}
    258262    is concerned, this looks exactly like a unit test.
    259263    """
    260264
    261     implements(ITestCase)
    262 
    263265    failureException = None
    264266
    265267    def __init__(self, description):
    class TrialRunner(object): 
    652654    def _setUpTestdir(self):
    653655        self._tearDownLogFile()
    654656        currentDir = os.getcwd()
    655         base = filepath.FilePath(self.workingDirectory)
     657        base = filepath.FilePath(self.workingDirectory.encode('utf-8'))
    656658        testdir, self._testDirLock = util._unusedTestDirectory(base)
    657659        os.chdir(testdir.path)
    658660        return currentDir
    class TrialRunner(object): 
    715717        if self.logfile == '-':
    716718            logFile = sys.stdout
    717719        else:
    718             logFile = file(self.logfile, 'a')
     720            logFile = open(self.logfile, 'a')
    719721        self._logFileObject = logFile
    720722        self._logFileObserver = log.FileLogObserver(logFile)
    721723        log.startLoggingWithObserver(self._logFileObserver.emit, 0)