From 1f041f1a47cb9862bcc26dc9a2273529eb7b9e31 Mon Sep 17 00:00:00 2001 From: perl-Git-CPAN-Patch Owner Date: Fri, 16 Aug 2019 12:43:18 +0200 Subject: [PATCH] Port other tests to Python 3 --- tests/pytest | 8 ++++---- tests/t50_methods.py | 8 ++++---- tests/t90_bigauto.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/pytest b/tests/pytest index 4489592..8e39d2a 100755 --- a/tests/pytest +++ b/tests/pytest @@ -41,7 +41,7 @@ least one such failed test, the return status of this program is non-zero. __metaclass__ = type import inspect, os, sys, time, traceback -from StringIO import StringIO +from io import StringIO # How many displayable characters in an output line. WIDTH = 79 @@ -155,7 +155,7 @@ class Main: else: text = u' ' + text write(text + u'\n') - except Exit, exception: + except Exit as exception: if not self.verbose: write(u'\n') write(u'\n* %s *\n' % str(exception)) @@ -270,7 +270,7 @@ class Main: if minimum is not None: collection.append((minimum, name, objet, False)) elif name.startswith(u'test_') and inspect.isfunction(objet): - code = objet.func_code + code = objet.__code__ collection.append((code.co_firstlineno, name, objet, bool(code.co_flags & 32))) if not collection: @@ -316,7 +316,7 @@ class Main: # FIXME: Should likely do class setup here. try: for counter, arguments in enumerate(function()): - collection.append((prefix + u'/' + unicode(counter + 1), + collection.append((prefix + u'/' + str(counter + 1), arguments[0], arguments[1:])) except Skipped: return diff --git a/tests/t50_methods.py b/tests/t50_methods.py index 66da2e6..f0d5b6f 100644 --- a/tests/t50_methods.py +++ b/tests/t50_methods.py @@ -5,7 +5,7 @@ from __main__ import py import os, sys input_name = '%s/../COPYING' % os.path.dirname(sys.argv[0]) -input = file(input_name, 'rb').read() +input = open(input_name, 'rb').read() def test_1(): @@ -65,7 +65,7 @@ def validate(request, sequence, mode): command = ('$R --quiet --force --sequence=%s < %s %s' '| $R --quiet --force --sequence=%s %s..%s' % (sequence, input_name, request, sequence, after, before)) - print command + print(command) output = common.external_output(command) elif mode == 'squash': file(common.run.work, 'wb').write(input) @@ -74,8 +74,8 @@ def validate(request, sequence, mode): command2 = ('$R --quiet --force --sequence=%s %s..%s %s' % (sequence, after, before, common.run.work)) - print command1 - print command2 + print(command1) + print(command2) common.external_output(command1) common.external_output(command2) output = file(common.run.work, 'rb').read() diff --git a/tests/t90_bigauto.py b/tests/t90_bigauto.py index 861cce6..46d4cd4 100644 --- a/tests/t90_bigauto.py +++ b/tests/t90_bigauto.py @@ -57,7 +57,7 @@ class Test: # consider as a single test, one "before" against all "after"s. # However, without a Recode module, we do not know how many # "before"s exist, and the skip count is then rather small. - print before + print(before) for after in self.charsets: if after is not before: request = Recode.Request(self.outer) @@ -97,7 +97,7 @@ class Report: line = readline() if line: if len(line[:-lensep].split(':', 1)) != 2: - print '*', line, + print('*', line) type, shrunk_to = line[:-lensep].split(':', 1) if type == 'Shrunk to': steps = self.get_steps(shrunk_to) -- 2.23.0.rc2