From 40ddcf310ca8398000ab730e48042efe7b80847c Mon Sep 17 00:00:00 2001 From: toonn Date: Fri, 27 Aug 2021 19:25:12 +0200 Subject: tests: Pylint complains about open and literals So let's use our new open23 to circumvent the lint. Updating the function to default to UTF-8. This is not the greatest solution but changing to `io.open` has performance repercussions and using `codecs.open` might change semantics so it would need thorough testing. --- tests/manpage_completion_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/manpage_completion_test.py b/tests/manpage_completion_test.py index f5e5c335..f6ce87de 100755 --- a/tests/manpage_completion_test.py +++ b/tests/manpage_completion_test.py @@ -6,6 +6,8 @@ import os.path import re import sys +from ranger.ext.open23 import open23 + # Add relevant ranger module to PATH... there surely is a better way to do this... sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) @@ -26,14 +28,14 @@ def get_path_of_man_page(): def read_manpage(): path = get_path_of_man_page() - with open(path, 'r') as man_page: + with open23(path, 'r') as man_page: return man_page.read() def get_sections(): manpage = read_manpage() parts = manpage.split('=head1 ') - sections = dict() + sections = {} for part in parts: if '\n' in part: section_name, section_content = part.split('\n', 1) -- cgit 1.4.1-2-gfad0 From 1df7a7e4865790e907be86f84e52dc6125436b05 Mon Sep 17 00:00:00 2001 From: toonn Date: Fri, 27 Aug 2021 20:25:59 +0200 Subject: tests: Ignore encoding in manpage test --- tests/manpage_completion_test.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/manpage_completion_test.py b/tests/manpage_completion_test.py index f6ce87de..1a01f944 100755 --- a/tests/manpage_completion_test.py +++ b/tests/manpage_completion_test.py @@ -6,8 +6,6 @@ import os.path import re import sys -from ranger.ext.open23 import open23 - # Add relevant ranger module to PATH... there surely is a better way to do this... sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) @@ -28,7 +26,8 @@ def get_path_of_man_page(): def read_manpage(): path = get_path_of_man_page() - with open23(path, 'r') as man_page: + # pylint: disable=unspecified-encoding + with open(path, 'r') as man_page: return man_page.read() -- cgit 1.4.1-2-gfad0