Merge "Fix Python 2.7 compatibility for test_ansible.py"

This commit is contained in:
Zuul 2021-05-21 08:08:08 +00:00 committed by Gerrit Code Review
commit 5cc7fda2f7
1 changed files with 9 additions and 1 deletions

View File

@ -30,6 +30,14 @@ try:
except pkg_resources.DistributionNotFound:
backward_compat = False
# NOTE(cloudnull): This is setting the FileExistsError for py2 environments.
# When we no longer support py2 (centos7) this should be
# removed.
try:
FileExistsError = FileExistsError
except NameError:
FileExistsError = OSError
class TestAnsible(TestCase):
@ -175,7 +183,7 @@ class TestAnsible(TestCase):
self.assertEqual(extra_vars, self.run._get_extra_vars(extra_vars))
@mock.patch('yaml.safe_load', return_value={'fizz': 'buzz'})
@mock.patch('builtins.open', spec=open)
@mock.patch('six.moves.builtins.open', spec=open)
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.path.isfile', return_value=True)
def test_get_extra_vars_path(self, mock_isfile,