Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2020-09-19 12:35:49 +0300
committerGitHub <noreply@github.com>2020-09-19 12:35:49 +0300
commit501df0dc4e289b04e73a9c64ca1ff2fda335536b (patch)
treead839f93b4d1d7d464b09002e4e39904c2af99fc /certbot-apache
parentb551b6ee73632422b7769a6d4a18cb1990307818 (diff)
Use in dict rather than "in dict.keys()". Fix linting warnings about "not in". (#8298)
* Fixed a few linting warnings for if not x in y. These should have been caught by pylint, but weren't. * Replaced "x in y.keys()" with "x in y". It's much faster, and more Pythonic.
Diffstat (limited to 'certbot-apache')
-rw-r--r--certbot-apache/certbot_apache/_internal/parser.py2
-rw-r--r--certbot-apache/tests/centos_test.py10
-rw-r--r--certbot-apache/tests/fedora_test.py10
-rw-r--r--certbot-apache/tests/gentoo_test.py2
4 files changed, 12 insertions, 12 deletions
diff --git a/certbot-apache/certbot_apache/_internal/parser.py b/certbot-apache/certbot_apache/_internal/parser.py
index c9aebae54..3e842dcdf 100644
--- a/certbot-apache/certbot_apache/_internal/parser.py
+++ b/certbot-apache/certbot_apache/_internal/parser.py
@@ -799,7 +799,7 @@ class ApacheParser(object):
def _parsed_by_parser_paths(self, filep, paths):
"""Helper function that searches through provided paths and returns
True if file path is found in the set"""
- for directory in paths.keys():
+ for directory in paths:
for filename in paths[directory]:
if fnmatch.fnmatch(filep, os.path.join(directory, filename)):
return True
diff --git a/certbot-apache/tests/centos_test.py b/certbot-apache/tests/centos_test.py
index 9dc6fa5a7..b7e9c1cb6 100644
--- a/certbot-apache/tests/centos_test.py
+++ b/certbot-apache/tests/centos_test.py
@@ -140,7 +140,7 @@ class MultipleVhostsTestCentOS(util.ApacheTest):
self.assertEqual(mock_get.call_count, 3)
self.assertEqual(len(self.config.parser.modules), 4)
self.assertEqual(len(self.config.parser.variables), 2)
- self.assertTrue("TEST2" in self.config.parser.variables.keys())
+ self.assertTrue("TEST2" in self.config.parser.variables)
self.assertTrue("mod_another.c" in self.config.parser.modules)
def test_get_virtual_hosts(self):
@@ -172,11 +172,11 @@ class MultipleVhostsTestCentOS(util.ApacheTest):
mock_osi.return_value = ("centos", "7")
self.config.parser.update_runtime_variables()
- self.assertTrue("mock_define" in self.config.parser.variables.keys())
- self.assertTrue("mock_define_too" in self.config.parser.variables.keys())
- self.assertTrue("mock_value" in self.config.parser.variables.keys())
+ self.assertTrue("mock_define" in self.config.parser.variables)
+ self.assertTrue("mock_define_too" in self.config.parser.variables)
+ self.assertTrue("mock_value" in self.config.parser.variables)
self.assertEqual("TRUE", self.config.parser.variables["mock_value"])
- self.assertTrue("MOCK_NOSEP" in self.config.parser.variables.keys())
+ self.assertTrue("MOCK_NOSEP" in self.config.parser.variables)
self.assertEqual("NOSEP_VAL", self.config.parser.variables["NOSEP_TWO"])
@mock.patch("certbot_apache._internal.configurator.util.run_script")
diff --git a/certbot-apache/tests/fedora_test.py b/certbot-apache/tests/fedora_test.py
index e0ee603c3..50831802b 100644
--- a/certbot-apache/tests/fedora_test.py
+++ b/certbot-apache/tests/fedora_test.py
@@ -134,7 +134,7 @@ class MultipleVhostsTestFedora(util.ApacheTest):
self.assertEqual(mock_get.call_count, 3)
self.assertEqual(len(self.config.parser.modules), 4)
self.assertEqual(len(self.config.parser.variables), 2)
- self.assertTrue("TEST2" in self.config.parser.variables.keys())
+ self.assertTrue("TEST2" in self.config.parser.variables)
self.assertTrue("mod_another.c" in self.config.parser.modules)
@mock.patch("certbot_apache._internal.configurator.util.run_script")
@@ -172,11 +172,11 @@ class MultipleVhostsTestFedora(util.ApacheTest):
mock_osi.return_value = ("fedora", "29")
self.config.parser.update_runtime_variables()
- self.assertTrue("mock_define" in self.config.parser.variables.keys())
- self.assertTrue("mock_define_too" in self.config.parser.variables.keys())
- self.assertTrue("mock_value" in self.config.parser.variables.keys())
+ self.assertTrue("mock_define" in self.config.parser.variables)
+ self.assertTrue("mock_define_too" in self.config.parser.variables)
+ self.assertTrue("mock_value" in self.config.parser.variables)
self.assertEqual("TRUE", self.config.parser.variables["mock_value"])
- self.assertTrue("MOCK_NOSEP" in self.config.parser.variables.keys())
+ self.assertTrue("MOCK_NOSEP" in self.config.parser.variables)
self.assertEqual("NOSEP_VAL", self.config.parser.variables["NOSEP_TWO"])
@mock.patch("certbot_apache._internal.configurator.util.run_script")
diff --git a/certbot-apache/tests/gentoo_test.py b/certbot-apache/tests/gentoo_test.py
index aa923c367..64f7d1062 100644
--- a/certbot-apache/tests/gentoo_test.py
+++ b/certbot-apache/tests/gentoo_test.py
@@ -91,7 +91,7 @@ class MultipleVhostsTestGentoo(util.ApacheTest):
with mock.patch("certbot_apache._internal.override_gentoo.GentooParser.update_modules"):
self.config.parser.update_runtime_variables()
for define in defines:
- self.assertTrue(define in self.config.parser.variables.keys())
+ self.assertTrue(define in self.config.parser.variables)
@mock.patch("certbot_apache._internal.apache_util.parse_from_subprocess")
def test_no_binary_configdump(self, mock_subprocess):