Browse Source

Merge "Fix Python 2.7 compatibility for test_ansible.py"

changes/60/792460/8
Zuul 3 weeks ago
committed by Gerrit Code Review
parent
commit
5cc7fda2f7
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      validations_libs/tests/test_ansible.py

+ 9
- 1
validations_libs/tests/test_ansible.py 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,


Loading…
Cancel
Save