mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 18:04:31 +02:00
Allow tests to pass without dnspython (#3581)
* move skipUnless to test_util * add skip_unless to acme test_util * Make dns_resolver_tests work with and without dnspython * make acme.challenges_test pass when dns is unavailable
This commit is contained in:
@@ -6,6 +6,8 @@ import sys
|
||||
import mock
|
||||
from six.moves import reload_module # pylint: disable=import-error
|
||||
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
class PathSurgeryTest(unittest.TestCase):
|
||||
"""Tests for certbot.plugins.path_surgery."""
|
||||
@@ -89,28 +91,8 @@ def psutil_available():
|
||||
return True
|
||||
|
||||
|
||||
def skipUnless(condition, reason):
|
||||
"""Skip tests unless a condition holds.
|
||||
|
||||
This implements the basic functionality of unittest.skipUnless
|
||||
which is only available on Python 2.7+.
|
||||
|
||||
:param bool condition: If ``False``, the test will be skipped
|
||||
:param str reason: the reason for skipping the test
|
||||
|
||||
:rtype: callable
|
||||
:returns: decorator that hides tests unless condition is ``True``
|
||||
|
||||
"""
|
||||
if hasattr(unittest, "skipUnless"):
|
||||
return unittest.skipUnless(condition, reason)
|
||||
elif condition:
|
||||
return lambda cls: cls
|
||||
else:
|
||||
return lambda cls: None
|
||||
|
||||
|
||||
@skipUnless(psutil_available(), "optional dependency psutil is not available")
|
||||
@test_util.skip_unless(psutil_available(),
|
||||
"optional dependency psutil is not available")
|
||||
class AlreadyListeningTestPsutil(unittest.TestCase):
|
||||
"""Tests for certbot.plugins.already_listening."""
|
||||
def _call(self, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user