From 80fba68edda2539f3da0029ed111237d0415aff1 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Tue, 20 Mar 2018 21:24:15 -0400 Subject: [PATCH] Avocado: add a default encoding setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And use it when running tests. Note: this is a partial implementation, to satisfy the following use case: $ echo "#!/bin/sh" > a.sh $ echo "echo ěčřž" >> a.sh $ chmod +x a.sh $ avocado run a.sh Signed-off-by: Cleber Rosa --- avocado/core/defaults.py | 20 ++++++++++++++++++++ avocado/core/test.py | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 avocado/core/defaults.py diff --git a/avocado/core/defaults.py b/avocado/core/defaults.py new file mode 100644 index 00000000..b84eeb75 --- /dev/null +++ b/avocado/core/defaults.py @@ -0,0 +1,20 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See LICENSE for more details. +# +# Copyright: Red Hat Inc. 2018 +# Author: Cleber Rosa + +""" +The Avocado core defaults +""" + +#: The encoding used by default on all data input +ENCODING = 'utf-8' diff --git a/avocado/core/test.py b/avocado/core/test.py index 4ab33b43..d59bf397 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -32,6 +32,7 @@ from difflib import unified_diff from six import string_types, iteritems from . import data_dir +from . import defaults from . import exceptions from . import output from . import parameters @@ -1133,7 +1134,7 @@ class SimpleTest(Test): # process.run uses shlex.split(), the self.path needs to be escaped result = process.run(self._command, verbose=True, - env=test_params) + env=test_params, encoding=defaults.ENCODING) self._log_detailed_cmd_info(result) except process.CmdError as details: -- GitLab