Skip to content

Commit 434b424

Browse files
author
Haiko Schol
committed
Only convert test function names to byte strings on Python 2
Signed-off-by: Haiko Schol <ext-haiko.schol@here.com>
1 parent f769ca2 commit 434b424

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test_purl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@
3737
unicode
3838
str = unicode
3939
basestring = basestring
40+
py2 = True
4041
except NameError:
4142
# Python 3
4243
unicode = str
4344
basestring = (bytes, str,)
45+
py2 = False
4446

4547

4648
def create_test_function(description, purl, canonical_purl, is_invalid,
@@ -113,7 +115,7 @@ def python_safe_name(s):
113115
s = s.lower()
114116
s = no_punctuation(' ', s)
115117
s = '_'.join(s.split())
116-
if isinstance(s, unicode):
118+
if py2 and isinstance(s, unicode):
117119
s = s.encode('ascii', 'ignore')
118120
return s
119121

0 commit comments

Comments
 (0)