Merge "Fix Python 2.7 compatibility for test_ansible.py"
This commit is contained in:
commit
5cc7fda2f7
@ -30,6 +30,14 @@ try:
|
|||||||
except pkg_resources.DistributionNotFound:
|
except pkg_resources.DistributionNotFound:
|
||||||
backward_compat = False
|
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):
|
class TestAnsible(TestCase):
|
||||||
|
|
||||||
@ -175,7 +183,7 @@ class TestAnsible(TestCase):
|
|||||||
self.assertEqual(extra_vars, self.run._get_extra_vars(extra_vars))
|
self.assertEqual(extra_vars, self.run._get_extra_vars(extra_vars))
|
||||||
|
|
||||||
@mock.patch('yaml.safe_load', return_value={'fizz': 'buzz'})
|
@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.exists', return_value=True)
|
||||||
@mock.patch('os.path.isfile', return_value=True)
|
@mock.patch('os.path.isfile', return_value=True)
|
||||||
def test_get_extra_vars_path(self, mock_isfile,
|
def test_get_extra_vars_path(self, mock_isfile,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user