提交 0b872f8b 编写于 作者: C Cleber Rosa

test_utils_network.py: skip test when netifaces is not available

netifaces is an external library, that is not trivially installable by
pip (requires a C compiler).  Let's make the test conditional to the
presence of the netifaces library.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 4e7f3df5
import netifaces
import socket
import unittest
......@@ -7,6 +6,12 @@ try:
except ImportError:
import mock
try:
import netifaces
HAS_NETIFACES = True
except ImportError:
HAS_NETIFACES = False
from avocado.utils import network
......@@ -52,6 +57,8 @@ def get_all_local_addrs():
class FreePort(unittest.TestCase):
@unittest.skipUnless(HAS_NETIFACES,
"netifaces library not available")
def test_is_port_free(self):
port = network.find_free_port(sequent=False)
self.assertTrue(network.is_port_free(port, "localhost"))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册