Drop settings for python2
As Ussuri+ we no longer support py2(centos7), Dropping settings for python2 environments. Change-Id: Iadf39b47ebad68b7c6c3502e66984428ccf0bbff
This commit is contained in:
parent
f463fa1e47
commit
8429eaa41b
|
@ -19,13 +19,6 @@ import sys
|
|||
from osc_lib.i18n import _
|
||||
from six.moves import configparser
|
||||
|
||||
# NOTE(cloudnull): Condition exceptions to support PY2, When we drop py2 this
|
||||
# should be simplified.
|
||||
try:
|
||||
FileNotFoundError = FileNotFoundError
|
||||
except NameError:
|
||||
FileNotFoundError = IOError
|
||||
|
||||
TRIPLEO_HEAT_TEMPLATES = "/usr/share/openstack-tripleo-heat-templates/"
|
||||
OVERCLOUD_YAML_NAME = "overcloud.yaml"
|
||||
OVERCLOUD_ROLES_FILE = "roles_data.yaml"
|
||||
|
|
|
@ -19,7 +19,6 @@ import fixtures
|
|||
import json
|
||||
import mock
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from osc_lib import exceptions as oscexc
|
||||
|
@ -542,12 +541,7 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode):
|
|||
}
|
||||
]
|
||||
mock_open = mock.mock_open(read_data=json.dumps(file_return_nodes))
|
||||
# TODO(cloudnull): Remove this when py27 is dropped
|
||||
if sys.version_info >= (3, 0):
|
||||
mock_open_path = 'builtins.open'
|
||||
else:
|
||||
mock_open_path = 'tripleoclient.v1.overcloud_node.open'
|
||||
with mock.patch(mock_open_path, mock_open):
|
||||
with mock.patch('six.moves.builtins.open', mock_open):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
nodes_list = copy.deepcopy(self.nodes_list)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#
|
||||
|
||||
import mock
|
||||
import sys
|
||||
|
||||
from tripleoclient.tests import fakes
|
||||
from tripleoclient.tests.v1.overcloud_deploy import fakes as deploy_fakes
|
||||
|
@ -43,11 +42,6 @@ MOCK_WALK = [
|
|||
("/base/openstack/nova", [], [],),
|
||||
]
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
MOCK_OPEN_PATH = "builtins.open"
|
||||
else:
|
||||
MOCK_OPEN_PATH = "tripleoclient.v2.tripleo_container_image.open"
|
||||
|
||||
|
||||
class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
||||
def setUp(self):
|
||||
|
@ -83,7 +77,7 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
|||
mock_isfile.return_value = True
|
||||
with mock.patch("os.path.isdir", autospec=True) as mock_isdir:
|
||||
mock_isdir.return_value = True
|
||||
with mock.patch(MOCK_OPEN_PATH, mock_open):
|
||||
with mock.patch('six.moves.builtins.open', mock_open):
|
||||
with mock.patch(
|
||||
"tripleoclient.v2.tripleo_container_image.Build"
|
||||
".find_image",
|
||||
|
@ -94,7 +88,7 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
|||
|
||||
def test_find_image(self):
|
||||
mock_open = mock.mock_open(read_data='---\ntcib_option: "data"')
|
||||
with mock.patch(MOCK_OPEN_PATH, mock_open):
|
||||
with mock.patch('six.moves.builtins.open', mock_open):
|
||||
image = self.cmd.find_image("keystone", "some/path", "base-image")
|
||||
self.assertEqual(image, {"tcib_option": "data"})
|
||||
|
||||
|
|
|
@ -66,15 +66,6 @@ from tripleoclient import exceptions
|
|||
LOG = logging.getLogger(__name__ + ".utils")
|
||||
|
||||
|
||||
# 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 Pushd(object):
|
||||
"""Simple context manager to change directories and then return."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue