AsyncMock was added in python 3.8. We don't want unit tests to
be failing if somebody tries running them with pytohn 3.7. Our
Jenkins job should be unaffected and still run the test.
Signed-off-by: Adam King <adking@redhat.com>
import json
-from unittest.mock import AsyncMock
+try:
+ # AsyncMock was not added until python 3.8
+ from unittest.mock import AsyncMock
+except ImportError:
+ pass
from contextlib import contextmanager
import pytest
check_execute_command.return_value = ''
execute_command.return_value = '', '', 0
+ if not AsyncMock:
+ # can't run this test if we could not import AsyncMock
+ return
mock_connect = AsyncMock(return_value='')
with mock.patch("asyncssh.connect", new=mock_connect) as asyncssh_connect:
with with_host(cephadm_module, 'test'):