Skip to content

Commit 2eff74c

Browse files
cclausssam-github
authored andcommitted
Python 3 changes plus automated testing
PR-URL: #5 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matt (IPv4) Cowley <me@mattcowley.co.uk>
1 parent 37aed1d commit 2eff74c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tap2junit/tap13.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@
1414
#
1515
# Author: Josef Skladanka <jskladan@redhat.com>
1616

17+
from __future__ import print_function
18+
1719
import re
20+
try:
21+
from StringIO import StringIO
22+
except ImportError:
23+
from io import StringIO
24+
1825
import yamlish
19-
import StringIO
2026

27+
try:
28+
basestring
29+
except NameError:
30+
basestring = str
2131

2232

2333
RE_VERSION = re.compile(r"^\s*TAP version 13\s*$")
@@ -133,8 +143,8 @@ def _parse(self, source):
133143

134144

135145
def parse(self, source):
136-
if isinstance(source, (str, unicode)):
137-
self._parse(StringIO.StringIO(source))
146+
if isinstance(source, basestring):
147+
self._parse(StringIO(source))
138148
elif hasattr(source, "__iter__"):
139149
self._parse(source)
140150

@@ -178,6 +188,6 @@ def parse(self, source):
178188

179189
import pprint
180190
for test in t.tests:
181-
print test.result, test.id, test.description, "#", test.directive, test.comment
191+
print(test.result, test.id, test.description, "#", test.directive, test.comment)
182192
pprint.pprint(test._yaml_buffer)
183193
pprint.pprint(test.yaml)

0 commit comments

Comments
 (0)