use six instead of custom refresh function

This commit is contained in:
Brad Warren 2016-08-18 14:49:11 -07:00
parent 28de5a92b2
commit 702ed89007

View file

@ -4,13 +4,7 @@ import unittest
import sys
import mock
try:
# Python 3.5+
from importlib import reload as refresh # pylint: disable=no-name-in-module
except ImportError:
# Python 2-3.4
from imp import reload as refresh
from six.moves import reload_module # pylint: disable=import-error
class PathSurgeryTest(unittest.TestCase):
@ -50,14 +44,14 @@ class AlreadyListeningTestNoPsutil(unittest.TestCase):
sys.modules['psutil'] = None
# Reload hackery to ensure getting non-psutil version
# loaded to memory
refresh(certbot.plugins.util)
reload_module(certbot.plugins.util)
def tearDown(self):
# Need to reload the module to ensure
# getting back to normal
import certbot.plugins.util
sys.modules["psutil"] = self.psutil
refresh(certbot.plugins.util)
reload_module(certbot.plugins.util)
@mock.patch("certbot.plugins.util.zope.component.getUtility")
def test_ports_available(self, mock_getutil):