From 5f3ba289d6490e8614c1a0f0e4ccab11e44e20c5 Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 24 Jan 2018 20:03:46 +0100 Subject: [PATCH] restore code coverage (decreased in latest "fixes") - no cover for unreachable cases; --- fail2ban/tests/filtertestcase.py | 4 ++-- fail2ban/tests/utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fail2ban/tests/filtertestcase.py b/fail2ban/tests/filtertestcase.py index 59c7820a..b5877b7f 100644 --- a/fail2ban/tests/filtertestcase.py +++ b/fail2ban/tests/filtertestcase.py @@ -673,10 +673,10 @@ class LogFileMonitor(LogCaptureTestCase): failure_was_logged = self._is_logged('Unable to open %s' % self.name) # verify that we cannot access the file. Checking by name of user is not # sufficient since could be a fakeroot or some other super-user + is_root = True try: - with open(self.name) as f: + with open(self.name) as f: # pragma: no cover - normally no root f.read() - is_root = True except IOError: is_root = False diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index 05d8d666..2bcc587b 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -56,7 +56,7 @@ if not CONFIG_DIR: # Use heuristic to figure out where configuration files are if os.path.exists(os.path.join('config','fail2ban.conf')): CONFIG_DIR = 'config' - else: + else: # pragma: no cover - normally unreachable CONFIG_DIR = '/etc/fail2ban' # Indicates that we've stock config: