1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-27 19:42:53 +03:00

[#5155] - replaces instances of isinstance(x, str) with isinstance(x, six.string_types)

This commit is contained in:
mvi
2017-10-26 19:09:06 +02:00
parent e2ab940ac0
commit 19a4e6079e
5 changed files with 11 additions and 10 deletions

View File

@@ -142,14 +142,14 @@ def report_config_interaction(modified, modifiers):
between config options.
:param modified: config options that can be modified by modifiers
:type modified: iterable or str
:type modified: iterable or str (string_types)
:param modifiers: config options that modify modified
:type modifiers: iterable or str
:type modifiers: iterable or str (string_types)
"""
if isinstance(modified, str):
if isinstance(modified, six.string_types):
modified = (modified,)
if isinstance(modifiers, str):
if isinstance(modifiers, six.string_types):
modifiers = (modifiers,)
for var in modified:
@@ -477,7 +477,7 @@ class HelpfulArgumentParser(object):
if isinstance(help1, bool) and isinstance(help2, bool):
self.help_arg = help1 or help2
else:
self.help_arg = help1 if isinstance(help1, str) else help2
self.help_arg = help1 if isinstance(help1, six.string_types) else help2
short_usage = self._usage_string(plugins, self.help_arg)

View File

@@ -1,5 +1,6 @@
"""Tests for certbot.plugins.null."""
import unittest
import six
import mock
@@ -12,7 +13,7 @@ class InstallerTest(unittest.TestCase):
self.installer = Installer(config=mock.MagicMock(), name="null")
def test_it(self):
self.assertTrue(isinstance(self.installer.more_info(), str))
self.assertTrue(isinstance(self.installer.more_info(), six.string_types))
self.assertEqual([], self.installer.get_all_names())
self.assertEqual([], self.installer.supported_enhancements())

View File

@@ -50,7 +50,7 @@ class AuthenticatorTest(unittest.TestCase):
def test_more_info(self):
more_info = self.auth.more_info()
self.assertTrue(isinstance(more_info, str))
self.assertTrue(isinstance(more_info, six.string_types))
self.assertTrue(self.path in more_info)
def test_add_parser_arguments(self):

View File

@@ -108,7 +108,7 @@ def _restore_webroot_config(config, renewalparams):
elif "webroot_path" in renewalparams:
logger.debug("Ancient renewal conf file without webroot-map, restoring webroot-path")
wp = renewalparams["webroot_path"]
if isinstance(wp, str): # prior to 0.1.0, webroot_path was a string
if isinstance(wp, six.string_types): # prior to 0.1.0, webroot_path was a string
wp = [wp]
config.webroot_path = wp
@@ -194,7 +194,7 @@ def _restore_pref_challs(unused_name, value):
# If pref_challs has only one element, configobj saves the value
# with a trailing comma so it's parsed as a list. If this comma is
# removed by the user, the value is parsed as a str.
value = [value] if isinstance(value, str) else value
value = [value] if isinstance(value, six.string_types) else value
return cli.parse_preferred_challenges(value)

View File

@@ -258,7 +258,7 @@ class UniqueLineageNameTest(test_util.TempDirTestCase):
for _ in six.moves.range(10):
f, name = self._call("wow")
self.assertTrue(isinstance(f, file_type))
self.assertTrue(isinstance(name, str))
self.assertTrue(isinstance(name, six.string_types))
self.assertTrue("wow-0009.conf" in name)
@mock.patch("certbot.util.os.fdopen")