Skip to content

Commit

Permalink
Python 3 support
Browse files Browse the repository at this point in the history
Floating patch for Python 3 support.

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>
  • Loading branch information
cclauss authored and sam-github committed Oct 4, 2019
1 parent b2248c0 commit cd0342e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tap2junit/tap13.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@
#
# Author: Josef Skladanka <jskladan@redhat.com>

from __future__ import print_function

import re
try:
from StringIO import StringIO
except ImportError:
from io import StringIO

import yamlish
import StringIO

try:
basestring
except NameError:
basestring = str


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


def parse(self, source):
if isinstance(source, (str, unicode)):
self._parse(StringIO.StringIO(source))
if isinstance(source, basestring):
self._parse(StringIO(source))
elif hasattr(source, "__iter__"):
self._parse(source)

Expand Down Expand Up @@ -178,6 +188,6 @@ def parse(self, source):

import pprint
for test in t.tests:
print test.result, test.id, test.description, "#", test.directive, test.comment
print(test.result, test.id, test.description, "#", test.directive, test.comment)
pprint.pprint(test._yaml_buffer)
pprint.pprint(test.yaml)

0 comments on commit cd0342e

Please sign in to comment.