Issue #19804: The test_find_mac test in test_uuid is now skipped if the
ifconfig executable is not available.
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index e623417..5ba6845 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -358,6 +358,17 @@
def mock_popen(cmd):
return io.BytesIO(data)
+ path = os.environ.get("PATH", os.defpath).split(os.pathsep)
+ path.extend(('/sbin', '/usr/sbin'))
+ for dir in path:
+ executable = os.path.join(dir, 'ifconfig')
+ if (os.path.exists(executable) and
+ os.access(executable, os.F_OK | os.X_OK) and
+ not os.path.isdir(executable)):
+ break
+ else:
+ self.skipTest('requires ifconfig')
+
with test_support.swap_attr(os, 'popen', mock_popen):
mac = uuid._find_mac(
command='ifconfig',