aboutsummaryrefslogtreecommitdiffstats
path: root/packaging-tools/tests
diff options
context:
space:
mode:
authorPatrik Teivonen <patrik.teivonen@qt.io>2022-07-05 13:43:43 +0300
committerPatrik Teivonen <patrik.teivonen@qt.io>2022-09-01 08:28:10 +0000
commit5e7dccd99a8565a1afdaaacad63f90e932a49fd5 (patch)
treead0ff5eadf02700f22e78c2222c3e7994bfee4f5 /packaging-tools/tests
parent158dbfa0117d2eaddccaca41a3a8038e7d821e5a (diff)
pylint: Add missing UTF-8 encoding parameter when opening files
Enable following warning in pylint and use encoding="utf-8" everywhere: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) Change-Id: Iddb885a420b9953ec899c825293a04ed75a2aef0 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'packaging-tools/tests')
-rwxr-xr-xpackaging-tools/tests/test_bld_python.py2
-rw-r--r--packaging-tools/tests/test_bldinstallercommon.py6
-rw-r--r--packaging-tools/tests/test_content_cleaner.py2
-rw-r--r--packaging-tools/tests/test_installer_utils.py2
-rwxr-xr-xpackaging-tools/tests/test_packaging.py2
-rwxr-xr-xpackaging-tools/tests/test_release_repo_meta_update.py2
-rwxr-xr-xpackaging-tools/tests/test_release_repo_updater.py6
-rwxr-xr-xpackaging-tools/tests/test_runner.py4
8 files changed, 13 insertions, 13 deletions
diff --git a/packaging-tools/tests/test_bld_python.py b/packaging-tools/tests/test_bld_python.py
index 693e447d0..8b2866176 100755
--- a/packaging-tools/tests/test_bld_python.py
+++ b/packaging-tools/tests/test_bld_python.py
@@ -45,7 +45,7 @@ class TestBldPython(unittest.TestCase):
tempDir = os.path.join(tmpBaseDir, "foo", "bar", "test", "dir")
os.makedirs(tempDir)
tempFilePath = os.path.join(tempDir, "configure")
- with open(tempFilePath, 'w+') as f:
+ with open(tempFilePath, 'w+', encoding="utf-8") as f:
f.write("\n")
foundDir = locate_source_root(tmpBaseDir)
diff --git a/packaging-tools/tests/test_bldinstallercommon.py b/packaging-tools/tests/test_bldinstallercommon.py
index dba0a8410..32f1a6b2d 100644
--- a/packaging-tools/tests/test_bldinstallercommon.py
+++ b/packaging-tools/tests/test_bldinstallercommon.py
@@ -78,11 +78,11 @@ class TestCommon(unittest.TestCase):
with TemporaryDirectory(dir=os.getcwd()) as tmp_base_dir:
# run tag substitution with data
tmp_file = Path(tmp_base_dir) / "test"
- with open(tmp_file, "a") as f:
+ with open(tmp_file, "a", encoding="utf-8") as f:
f.write(file_contents)
for key, value in replacements:
replace_in_files([tmp_file], key, value)
- with open(tmp_file, "r") as f:
+ with open(tmp_file, "r", encoding="utf-8") as f:
file_contents = f.read()
# check that file contents match
self.assertEqual(file_contents, expected_file_content)
@@ -141,7 +141,7 @@ class TestCommon(unittest.TestCase):
path, content = file
tmp_file = Path(tmp_base_dir) / path
tmp_file.parents[0].mkdir(parents=True, exist_ok=True)
- with open(tmp_file, "a") as f:
+ with open(tmp_file, "a", encoding="utf-8") as f:
f.write(content)
extensions, rgx = params
result = search_for_files(tmp_base_dir, extensions, rgx)
diff --git a/packaging-tools/tests/test_content_cleaner.py b/packaging-tools/tests/test_content_cleaner.py
index 898f04030..5e59e6ed4 100644
--- a/packaging-tools/tests/test_content_cleaner.py
+++ b/packaging-tools/tests/test_content_cleaner.py
@@ -47,7 +47,7 @@ class TestContentCleaner(unittest.TestCase):
test_path = os.path.join(test_base_dir, test_content_path)
os.makedirs(os.path.dirname(test_path), exist_ok=True)
if not test_path.endswith("/"):
- with open(test_path, "w+") as f:
+ with open(test_path, "w+", encoding="utf-8") as f:
f.write("")
@data(
diff --git a/packaging-tools/tests/test_installer_utils.py b/packaging-tools/tests/test_installer_utils.py
index 11ce56f3a..d22a174ac 100644
--- a/packaging-tools/tests/test_installer_utils.py
+++ b/packaging-tools/tests/test_installer_utils.py
@@ -96,7 +96,7 @@ class TestInstallerUtils(unittest.TestCase):
# create tmp file
tempFileName = "foobar.txt"
tempFilePath = os.path.join(absoluteTempPath, tempFileName)
- with open(tempFilePath, 'w+') as f:
+ with open(tempFilePath, 'w+', encoding="utf-8") as f:
f.write("\n")
self.assertTrue(os.path.isfile(tempFilePath))
diff --git a/packaging-tools/tests/test_packaging.py b/packaging-tools/tests/test_packaging.py
index 411b27b71..5fba2b303 100755
--- a/packaging-tools/tests/test_packaging.py
+++ b/packaging-tools/tests/test_packaging.py
@@ -123,7 +123,7 @@ class TestPackaging(unittest.TestCase):
tempFile = os.path.join(tempDir, "qconfig.pri")
try:
- with open(tempFile, "a") as f:
+ with open(tempFile, "a", encoding="utf-8") as f:
f.write("something foo\n")
f.write("QT_EDITION = foobar\n")
f.write("nonsense\n")
diff --git a/packaging-tools/tests/test_release_repo_meta_update.py b/packaging-tools/tests/test_release_repo_meta_update.py
index b098e7ff8..63911ca78 100755
--- a/packaging-tools/tests/test_release_repo_meta_update.py
+++ b/packaging-tools/tests/test_release_repo_meta_update.py
@@ -100,7 +100,7 @@ class TestReleaseRepoMetaUpdate(unittest.TestCase):
tmp = os.path.join(tmp_base_dir, path)
os.makedirs(os.path.dirname(tmp), exist_ok=True)
if tmp.endswith((".xml", ".7z")):
- with open(tmp, 'w+') as f:
+ with open(tmp, 'w+', encoding="utf-8") as f:
f.write("\n")
@asyncio_test
diff --git a/packaging-tools/tests/test_release_repo_updater.py b/packaging-tools/tests/test_release_repo_updater.py
index a496903b2..d92a19dd5 100755
--- a/packaging-tools/tests/test_release_repo_updater.py
+++ b/packaging-tools/tests/test_release_repo_updater.py
@@ -65,13 +65,13 @@ from tests.testhelpers import (
def _write_dummy_file(path: str) -> None:
os.makedirs(os.path.dirname(path), exist_ok=True)
- with open(path, 'w+') as f:
+ with open(path, 'w+', encoding="utf-8") as f:
f.write("\n")
def _write_package_xml(path: str, version: str, releaseDate: str) -> None:
os.makedirs(os.path.dirname(path), exist_ok=True)
- with open(path, 'w+') as f:
+ with open(path, 'w+', encoding="utf-8") as f:
f.write("<?xml version=\"1.0\"?>\n")
f.write("<Package>\n")
f.write(" <Name>qt.foo.bar1</Name>\n")
@@ -84,7 +84,7 @@ def _write_package_xml(path: str, version: str, releaseDate: str) -> None:
def _write_updates_xml(path: str, version: str, releaseDate: str) -> None:
os.makedirs(os.path.dirname(path), exist_ok=True)
- with open(path, 'w+') as f:
+ with open(path, 'w+', encoding="utf-8") as f:
f.write("<Updates>\n")
f.write(" <ApplicationName>{AnyApplication}</ApplicationName>\n")
f.write(" <ApplicationVersion>1.0.0</ApplicationVersion>\n")
diff --git a/packaging-tools/tests/test_runner.py b/packaging-tools/tests/test_runner.py
index 67d245be5..6aa7269ba 100755
--- a/packaging-tools/tests/test_runner.py
+++ b/packaging-tools/tests/test_runner.py
@@ -109,9 +109,9 @@ class TestRunner(unittest.TestCase):
with TemporaryDirectory(dir=os.getcwd()) as tmp_base_dir:
log_file = Path(tmp_base_dir) / "log"
log_file.touch()
- with open(log_file, 'w') as f:
+ with open(log_file, 'w', encoding="utf-8") as f:
do_execute_sub_process(["echo", "TEST"], tmp_base_dir, redirect_output=f)
- with open(log_file, 'r') as f:
+ with open(log_file, 'r', encoding="utf-8") as f:
self.assertEqual(f.read().strip(), "TEST")
@data(