aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2021-09-11 10:24:53 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2021-09-11 10:54:47 +0200
commit6ff14fe8826bcb0f635319a51032900c862a9728 (patch)
treed152c672a91caf9bce730fb5f105388a1f6db0ae
parente2f255aaaddeb0b7bebd7a158b535aa0ecdf55e0 (diff)
Set encoding utf-8 when opening file
Change-Id: I4e756552173247499ba882bfee4fbe8738fbae3d Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest_kubernetes/cnf_conformance/conformance.py3
-rw-r--r--functest_kubernetes/ims/ims.py6
-rw-r--r--functest_kubernetes/k8stest.py6
-rw-r--r--functest_kubernetes/rally/rally_kubernetes.py7
-rw-r--r--functest_kubernetes/security/security.py3
5 files changed, 16 insertions, 9 deletions
diff --git a/functest_kubernetes/cnf_conformance/conformance.py b/functest_kubernetes/cnf_conformance/conformance.py
index fa174f1a..2cf4baa9 100644
--- a/functest_kubernetes/cnf_conformance/conformance.py
+++ b/functest_kubernetes/cnf_conformance/conformance.py
@@ -76,7 +76,8 @@ class CNFConformance(testcase.TestCase):
lfiles = glob.glob(os.path.join(
self.src_dir, 'results', 'cnf-testsuite-results-*.yml'))
results = max(lfiles, key=os.path.getmtime)
- with open(os.path.join(self.src_dir, 'results', results)) as yfile:
+ with open(os.path.join(
+ self.src_dir, 'results', results), encoding='utf-8') as yfile:
self.details = yaml.safe_load(yfile)
msg = prettytable.PrettyTable(
header_style='upper', padding_width=5,
diff --git a/functest_kubernetes/ims/ims.py b/functest_kubernetes/ims/ims.py
index 18e8c0de..1feeafab 100644
--- a/functest_kubernetes/ims/ims.py
+++ b/functest_kubernetes/ims/ims.py
@@ -220,7 +220,8 @@ class K8sVims(Vims):
for deployment in self.deployment_list:
with open(pkg_resources.resource_filename(
'functest_kubernetes',
- 'ims/{}-depl.yaml'.format(deployment))) as yfile:
+ 'ims/{}-depl.yaml'.format(deployment)),
+ encoding='utf-8') as yfile:
template = Template(yfile.read())
body = yaml.safe_load(template.render(
dockerhub_repo=os.getenv(
@@ -235,7 +236,8 @@ class K8sVims(Vims):
for service in self.deployment_list:
with open(pkg_resources.resource_filename(
'functest_kubernetes',
- 'ims/{}-svc.yaml'.format(service))) as yfile:
+ 'ims/{}-svc.yaml'.format(service)),
+ encoding='utf-8') as yfile:
body = yaml.safe_load(yfile)
resp = self.corev1.create_namespaced_service(
body=body, namespace=self.namespace)
diff --git a/functest_kubernetes/k8stest.py b/functest_kubernetes/k8stest.py
index b450dac4..34c8ab94 100644
--- a/functest_kubernetes/k8stest.py
+++ b/functest_kubernetes/k8stest.py
@@ -78,7 +78,8 @@ class E2ETesting(testcase.TestCase):
cmd_line, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, env=env) as process:
boutput = process.stdout.read()
- with open(os.path.join(self.res_dir, 'e2e.log'), 'wb') as foutput:
+ with open(os.path.join(
+ self.res_dir, 'e2e.log'), 'w', encoding='utf-8') as foutput:
foutput.write(boutput)
grp = re.search(
r'^(FAIL|SUCCESS)!.* ([0-9]+) Passed \| ([0-9]+) Failed \|'
@@ -145,5 +146,6 @@ class E2ETesting(testcase.TestCase):
"GcrReleaseRegistry": "{}/gke-release".format(gcr_repo),
"MicrosoftRegistry": "mcr.microsoft.com",
}
- with open("{}/repositories.yml".format(self.res_dir), 'w') as file:
+ with open("{}/repositories.yml".format(
+ self.res_dir), 'w', encoding='utf-8') as file:
yaml.dump(repo_list, file)
diff --git a/functest_kubernetes/rally/rally_kubernetes.py b/functest_kubernetes/rally/rally_kubernetes.py
index 3543fa99..ef7949ef 100644
--- a/functest_kubernetes/rally/rally_kubernetes.py
+++ b/functest_kubernetes/rally/rally_kubernetes.py
@@ -65,7 +65,8 @@ class RallyKubernetes(testcase.TestCase):
result['existing@kubernetes']['message'])
return
with open(pkg_resources.resource_filename(
- 'functest_kubernetes', 'rally/all-in-one.yaml')) as file:
+ 'functest_kubernetes', 'rally/all-in-one.yaml'),
+ encoding='utf-8') as file:
template = Template(file.read())
task = yaml.safe_load(template.render(
concurrency=kwargs.get("concurrency", self.concurrency),
@@ -90,7 +91,7 @@ class RallyKubernetes(testcase.TestCase):
self.res_dir, "{}.html".format(self.case_name)))
if "files" in result:
for path in result["files"]:
- with open(path, "w+") as output:
+ with open(path, "w+", encoding='utf-8') as output:
output.write(result["files"][path])
result = rapi.task.export(
[task_instance["uuid"]], "junit-xml",
@@ -98,6 +99,6 @@ class RallyKubernetes(testcase.TestCase):
self.res_dir, "{}.xml".format(self.case_name)))
if "files" in result:
for path in result["files"]:
- with open(path, "w+") as output:
+ with open(path, "w+", encoding='utf-8') as output:
output.write(result["files"][path])
self.stop_time = time.time()
diff --git a/functest_kubernetes/security/security.py b/functest_kubernetes/security/security.py
index b6f19c75..3d36679f 100644
--- a/functest_kubernetes/security/security.py
+++ b/functest_kubernetes/security/security.py
@@ -66,7 +66,8 @@ class SecurityTesting(testcase.TestCase):
self.__logger.debug("create_namespace: %s", api_response)
with open(pkg_resources.resource_filename(
"functest_kubernetes",
- "security/{}.yaml".format(self.job_name))) as yfile:
+ "security/{}.yaml".format(self.job_name)),
+ encoding='utf-8') as yfile:
template = Template(yfile.read())
body = yaml.safe_load(template.render(
dockerhub_repo=os.getenv("DOCKERHUB_REPO",