From c0ff7e6e238fd9b3b7fbc13e55be6c0aa9ff8921 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 17 Jul 2021 23:17:59 +0200 Subject: tests.manpage_completion: Use with This test revealed an exception that wasn't covered in `ranger/__init__.py` due to the refactor to a with-statement. --- ranger/__init__.py | 2 +- tests/manpage_completion_test.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ranger/__init__.py b/ranger/__init__.py index a3b01f9d..cc388d60 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -31,7 +31,7 @@ def version_helper(): ) as git_describe: (git_description, _) = git_describe.communicate() version_string = version_string.format(git_description.strip('\n')) - except (OSError, subprocess.CalledProcessError): + except (OSError, subprocess.CalledProcessError, AttributeError): version_string = version_string.format(__version__) return version_string diff --git a/tests/manpage_completion_test.py b/tests/manpage_completion_test.py index b9504d06..f5e5c335 100755 --- a/tests/manpage_completion_test.py +++ b/tests/manpage_completion_test.py @@ -26,7 +26,8 @@ def get_path_of_man_page(): def read_manpage(): path = get_path_of_man_page() - return open(path, 'r').read() + with open(path, 'r') as man_page: + return man_page.read() def get_sections(): -- cgit 1.4.1-2-gfad0