summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-12-13 10:00:38 +0100
committerThomas Haller <thaller@redhat.com>2019-12-13 13:19:31 +0100
commit48225add3a1126a144959ecf82452ad6f8252511 (patch)
tree241eed7685bd3c526f87f0bd4e34f4888d2ea72f
parentffc235c30d40ccf375130a638b2c9cc18f5971c5 (diff)
downloadNetworkManager-48225add3a1126a144959ecf82452ad6f8252511.tar.gz
clients/tests: support string arguments to Util.replace_text()
-rwxr-xr-xclients/tests/test-client.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/clients/tests/test-client.py b/clients/tests/test-client.py
index 7daab013b8..66743233a4 100755
--- a/clients/tests/test-client.py
+++ b/clients/tests/test-client.py
@@ -278,6 +278,9 @@ class Util:
def replace_text(text, replace_arr):
if not replace_arr:
return text
+ needs_encode = Util.python_has_version(3) and Util.is_string(text)
+ if needs_encode:
+ text = text.encode('utf-8')
text = [text]
for replace in replace_arr:
try:
@@ -301,7 +304,11 @@ class Util:
text2.append( (v_replace,) )
text2.append(t3)
text = text2
- return b''.join([(t[0] if isinstance(t, tuple) else t) for t in text])
+ bb = b''.join([(t[0] if isinstance(t, tuple) else t) for t in text])
+ if needs_encode:
+ bb = bb.decode('utf-8')
+ return bb
+
@staticmethod
def debug_dbus_interface():