linter: Test run on str, unicode, bytes and stream

Previously it was not tested, and broke on Python 2 `unicode` inputs.
This commit is contained in:
Adrien Vergé
2016-02-25 10:39:46 +01:00
parent ca0ebe4583
commit 73d9322813
2 changed files with 47 additions and 1 deletions

View File

@@ -128,7 +128,7 @@ def run(input, conf):
:param input: buffer, string or stream to read from
:param conf: yamllint configuration object
"""
if type(input) == str:
if type(input) in (type(b''), type(u'')): # compat with Python 2 & 3
return _run(input, conf)
elif hasattr(input, 'read'): # Python 2's file or Python 3's io.IOBase
# We need to have everything in memory to parse correctly