~jfb-tempo-consulting/unifield-wm/sync-env-py3

« back to all changes in this revision

Viewing changes to unittest27/main.py

  • Committer: jf
  • Date: 2022-03-09 11:07:50 UTC
  • Revision ID: jfb@tempo-consulting.fr-20220309110750-8af5od1jgu92jxy3
py3 migration

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
                    testRunner=None, testLoader=loader.defaultTestLoader,
74
74
                    exit=True, verbosity=1, failfast=None, catchbreak=None,
75
75
                    buffer=None):
76
 
        if isinstance(module, basestring):
 
76
        if isinstance(module, str):
77
77
            self.module = __import__(module)
78
78
            for part in module.split('.')[1:]:
79
79
                self.module = getattr(self.module, part)
96
96
 
97
97
    def usageExit(self, msg=None):
98
98
        if msg:
99
 
            print msg
 
99
            print(msg)
100
100
        usage = {'progName': self.progName, 'catchbreak': '', 'failfast': '',
101
101
                 'buffer': ''}
102
102
        if self.failfast != False:
105
105
            usage['catchbreak'] = CATCHBREAK
106
106
        if self.buffer != False:
107
107
            usage['buffer'] = BUFFEROUTPUT
108
 
        print self.USAGE % usage
 
108
        print(self.USAGE % usage)
109
109
        sys.exit(2)
110
110
 
111
111
    def parseArgs(self, argv):
147
147
            else:
148
148
                self.testNames = (self.defaultTest,)
149
149
            self.createTests()
150
 
        except getopt.error, msg:
 
150
        except getopt.error as msg:
151
151
            self.usageExit(msg)
152
152
 
153
153
    def createTests(self):
215
215
            installHandler()
216
216
        if self.testRunner is None:
217
217
            self.testRunner = runner.TextTestRunner
218
 
        if isinstance(self.testRunner, (type, types.ClassType)):
 
218
        if isinstance(self.testRunner, type):
219
219
            try:
220
220
                testRunner = self.testRunner(verbosity=self.verbosity,
221
221
                                             failfast=self.failfast,