summaryrefslogtreecommitdiffstats
path: root/qa
diff options
context:
space:
mode:
authorJoris Roovers <jroovers@cisco.com>2018-04-15 12:20:28 +0200
committerJoris Roovers <jroovers@cisco.com>2018-04-15 12:20:28 +0200
commit03eec2042d97a4414b45e0f5f7e67fa85ce9f80b (patch)
tree994dfa2eafcc1baba53e25468dd83ad0aa04eefb /qa
parentf0c4acf161a23f37c8af8985d281254822280227 (diff)
Unicode byte decode fixes
Added better handling for decoding bytes to unicode strings in the ustr() function. This fixed the test_stdin_file integration in python 3.6. Also fixed a python 2.6 linting issue.
Diffstat (limited to 'qa')
-rw-r--r--qa/base.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/qa/base.py b/qa/base.py
index c36e69b..acab657 100644
--- a/qa/base.py
+++ b/qa/base.py
@@ -16,12 +16,15 @@ def ustr(obj):
if sys.version_info[0] == 2:
# If we are getting a string, then do an explicit decode
# else, just call the unicode method of the object
- if type(obj) in [str, basestring]: # pragma: no cover # noqa # pylint: disable=unidiomatic-typecheck
+ if type(obj) in [str, basestring]: # pragma: no cover # noqa
return unicode(obj, DEFAULT_ENCODING) # pragma: no cover # noqa
else:
return unicode(obj) # pragma: no cover # noqa
else:
- return str(obj)
+ if type(obj) in [bytes]:
+ return obj.decode(DEFAULT_ENCODING)
+ else:
+ return str(obj)
class BaseTestCase(TestCase):