From ad982b111aaeb960d7790f16b58cb41be5dcf72e Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Mon, 23 Mar 2020 18:35:09 +0200 Subject: [PATCH] Stop supporting python < 3.6 * remove six and mock usage * temporary turn off rally-docker-check Change-Id: I8582ef236917b3a0239f047ed9763134899d2d56 --- .zuul.d/zuul.yaml | 6 +-- .../contexts/ceilometer/samples.py | 3 +- rally_openstack/contexts/monasca/metrics.py | 4 +- .../sahara/sahara_input_data_sources.py | 5 +- rally_openstack/contexts/vm/custom_image.py | 5 +- .../contexts/watcher/audit_templates.py | 4 +- rally_openstack/osclients.py | 7 +-- rally_openstack/scenarios/ceilometer/utils.py | 3 +- .../scenarios/mistral/executions.py | 3 +- rally_openstack/scenarios/vm/utils.py | 9 ++-- rally_openstack/validators.py | 6 +-- .../verification/tempest/config.py | 7 ++- .../verification/tempest/context.py | 5 +- rally_openstack/wrappers/network.py | 4 +- setup.cfg | 1 + test-requirements.txt | 2 +- tests/ci/osresources.py | 4 +- tests/functional/test_task_samples.py | 4 +- tests/functional/utils.py | 3 +- tests/hacking/checks.py | 52 +++++++++---------- tests/unit/cleanup/test_base.py | 2 +- tests/unit/cleanup/test_manager.py | 3 +- tests/unit/cleanup/test_resources.py | 2 +- .../unit/contexts/ceilometer/test_samples.py | 6 +-- .../unit/contexts/cinder/test_volume_types.py | 2 +- tests/unit/contexts/cinder/test_volumes.py | 3 +- tests/unit/contexts/cleanup/test_admin.py | 4 +- tests/unit/contexts/cleanup/test_user.py | 4 +- tests/unit/contexts/dataplane/test_heat.py | 3 +- tests/unit/contexts/designate/test_zones.py | 3 +- tests/unit/contexts/ec2/test_servers.py | 3 +- tests/unit/contexts/glance/test_images.py | 2 +- tests/unit/contexts/heat/test_stacks.py | 2 +- tests/unit/contexts/keystone/test_roles.py | 2 +- tests/unit/contexts/keystone/test_users.py | 3 +- tests/unit/contexts/magnum/test_ca_certs.py | 2 +- .../contexts/magnum/test_cluster_templates.py | 2 +- tests/unit/contexts/magnum/test_clusters.py | 4 +- .../manila/test_manila_security_services.py | 10 ++-- .../manila/test_manila_share_networks.py | 9 ++-- .../contexts/manila/test_manila_shares.py | 5 +- tests/unit/contexts/monasca/test_metrics.py | 7 ++- .../murano/test_murano_environments.py | 2 +- .../contexts/murano/test_murano_packages.py | 2 +- tests/unit/contexts/network/test_allow_ssh.py | 2 +- tests/unit/contexts/network/test_network.py | 3 +- tests/unit/contexts/network/test_routers.py | 2 +- .../contexts/neutron/test_existing_network.py | 2 +- tests/unit/contexts/neutron/test_lbaas.py | 2 +- .../neutron/test_networking_agents.py | 2 +- tests/unit/contexts/nova/test_flavors.py | 2 +- tests/unit/contexts/nova/test_keypairs.py | 2 +- tests/unit/contexts/nova/test_servers.py | 3 +- .../contexts/quotas/test_cinder_quotas.py | 2 +- .../contexts/quotas/test_designate_quotas.py | 2 +- .../contexts/quotas/test_manila_quotas.py | 2 +- .../contexts/quotas/test_neutron_quotas.py | 2 +- .../unit/contexts/quotas/test_nova_quotas.py | 2 +- tests/unit/contexts/quotas/test_quotas.py | 2 +- .../contexts/sahara/test_sahara_cluster.py | 2 +- .../unit/contexts/sahara/test_sahara_image.py | 2 +- .../sahara/test_sahara_input_data_sources.py | 2 +- .../sahara/test_sahara_job_binaries.py | 2 +- .../sahara/test_sahara_output_data_sources.py | 2 +- tests/unit/contexts/senlin/test_profiles.py | 2 +- tests/unit/contexts/swift/test_objects.py | 2 +- tests/unit/contexts/swift/test_utils.py | 2 +- tests/unit/contexts/test_api_versions.py | 4 +- tests/unit/contexts/vm/test_custom_image.py | 3 +- .../vm/test_image_command_customizer.py | 3 +- .../contexts/watcher/test_audit_templates.py | 2 +- tests/unit/doc/test_docstrings.py | 1 + tests/unit/doc/test_jsonschemas.py | 1 + tests/unit/doc/test_task_samples.py | 5 +- .../unit/embedcharts/test_osprofilerchart.py | 3 +- tests/unit/fakes.py | 22 ++++---- tests/unit/hook/test_fault_injection.py | 3 +- tests/unit/platforms/test_existing.py | 3 +- tests/unit/rally_jobs/test_jobs.py | 2 +- .../authenticate/test_authenticate.py | 4 +- .../scenarios/barbican/test_containers.py | 2 +- tests/unit/scenarios/barbican/test_orders.py | 2 +- tests/unit/scenarios/barbican/test_secrets.py | 2 +- tests/unit/scenarios/barbican/test_utils.py | 2 +- .../unit/scenarios/ceilometer/test_alarms.py | 2 +- .../unit/scenarios/ceilometer/test_events.py | 2 +- .../unit/scenarios/ceilometer/test_meters.py | 2 +- .../unit/scenarios/ceilometer/test_queries.py | 3 +- .../scenarios/ceilometer/test_resources.py | 2 +- .../unit/scenarios/ceilometer/test_samples.py | 2 +- tests/unit/scenarios/ceilometer/test_stats.py | 2 +- .../unit/scenarios/ceilometer/test_traits.py | 2 +- tests/unit/scenarios/ceilometer/test_utils.py | 2 +- tests/unit/scenarios/cinder/test_qos_specs.py | 2 +- tests/unit/scenarios/cinder/test_utils.py | 2 +- .../scenarios/cinder/test_volume_backups.py | 2 +- .../scenarios/cinder/test_volume_types.py | 2 +- tests/unit/scenarios/cinder/test_volumes.py | 3 +- tests/unit/scenarios/designate/test_basic.py | 2 +- tests/unit/scenarios/designate/test_utils.py | 3 +- tests/unit/scenarios/ec2/test_servers.py | 2 +- tests/unit/scenarios/ec2/test_utils.py | 3 +- tests/unit/scenarios/glance/test_images.py | 2 +- .../scenarios/gnocchi/test_archive_policy.py | 2 +- .../gnocchi/test_archive_policy_rule.py | 2 +- .../scenarios/gnocchi/test_capabilities.py | 2 +- tests/unit/scenarios/gnocchi/test_metric.py | 2 +- tests/unit/scenarios/gnocchi/test_resource.py | 2 +- .../scenarios/gnocchi/test_resource_type.py | 2 +- tests/unit/scenarios/gnocchi/test_status.py | 2 +- tests/unit/scenarios/gnocchi/test_utils.py | 2 +- tests/unit/scenarios/heat/test_stacks.py | 3 +- tests/unit/scenarios/heat/test_utils.py | 3 +- tests/unit/scenarios/ironic/test_nodes.py | 3 +- tests/unit/scenarios/ironic/test_utils.py | 2 +- tests/unit/scenarios/keystone/test_basic.py | 3 +- .../loadbalancer/test_loadbalancers.py | 2 +- .../unit/scenarios/loadbalancer/test_pools.py | 2 +- .../unit/scenarios/loadbalancer/test_utils.py | 2 +- .../magnum/test_cluster_templates.py | 3 +- tests/unit/scenarios/magnum/test_clusters.py | 3 +- tests/unit/scenarios/magnum/test_k8s_pods.py | 3 +- tests/unit/scenarios/magnum/test_utils.py | 4 +- tests/unit/scenarios/manila/test_shares.py | 3 +- tests/unit/scenarios/manila/test_utils.py | 3 +- .../unit/scenarios/mistral/test_executions.py | 2 +- .../unit/scenarios/mistral/test_workbooks.py | 2 +- tests/unit/scenarios/monasca/test_metrics.py | 3 +- .../scenarios/murano/test_environments.py | 2 +- tests/unit/scenarios/murano/test_packages.py | 2 +- tests/unit/scenarios/murano/test_utils.py | 3 +- tests/unit/scenarios/neutron/test_bgpvpn.py | 3 +- .../scenarios/neutron/test_loadbalancer_v1.py | 3 +- .../scenarios/neutron/test_loadbalancer_v2.py | 3 +- tests/unit/scenarios/neutron/test_network.py | 3 +- .../scenarios/neutron/test_security_groups.py | 3 +- tests/unit/scenarios/neutron/test_trunk.py | 2 +- tests/unit/scenarios/neutron/test_utils.py | 3 +- tests/unit/scenarios/nova/test_agents.py | 2 +- tests/unit/scenarios/nova/test_aggregates.py | 3 +- .../scenarios/nova/test_availability_zones.py | 2 +- tests/unit/scenarios/nova/test_flavors.py | 3 +- tests/unit/scenarios/nova/test_hypervisors.py | 2 +- tests/unit/scenarios/nova/test_keypairs.py | 2 +- .../unit/scenarios/nova/test_server_groups.py | 3 +- tests/unit/scenarios/nova/test_servers.py | 3 +- tests/unit/scenarios/nova/test_services.py | 2 +- tests/unit/scenarios/nova/test_utils.py | 3 +- tests/unit/scenarios/quotas/test_quotas.py | 2 +- tests/unit/scenarios/quotas/test_utils.py | 2 +- tests/unit/scenarios/sahara/test_clusters.py | 2 +- tests/unit/scenarios/sahara/test_jobs.py | 2 +- .../sahara/test_node_group_templates.py | 2 +- tests/unit/scenarios/sahara/test_utils.py | 6 ++- tests/unit/scenarios/senlin/test_clusters.py | 2 +- tests/unit/scenarios/senlin/test_utils.py | 3 +- tests/unit/scenarios/swift/test_objects.py | 3 +- tests/unit/scenarios/swift/test_utils.py | 3 +- tests/unit/scenarios/vm/test_utils.py | 5 +- tests/unit/scenarios/vm/test_vmtasks.py | 3 +- tests/unit/scenarios/watcher/test_basic.py | 2 +- tests/unit/scenarios/watcher/test_utils.py | 2 +- tests/unit/scenarios/zaqar/test_basic.py | 2 +- tests/unit/scenarios/zaqar/test_utils.py | 2 +- tests/unit/services/barbican/test_secrets.py | 2 +- tests/unit/services/gnocchi/test_metric.py | 2 +- tests/unit/services/heat/test_main.py | 2 +- tests/unit/services/identity/test_identity.py | 3 +- .../services/identity/test_keystone_common.py | 2 +- .../services/identity/test_keystone_v2.py | 2 +- .../services/identity/test_keystone_v3.py | 3 +- .../unit/services/image/test_glance_common.py | 3 +- tests/unit/services/image/test_glance_v1.py | 3 +- tests/unit/services/image/test_glance_v2.py | 3 +- tests/unit/services/image/test_image.py | 3 +- .../services/loadbalancer/test_octavia.py | 4 +- tests/unit/services/storage/test_block.py | 2 +- .../services/storage/test_cinder_common.py | 3 +- tests/unit/services/storage/test_cinder_v1.py | 3 +- tests/unit/services/storage/test_cinder_v2.py | 3 +- tests/unit/services/storage/test_cinder_v3.py | 4 +- tests/unit/test.py | 3 +- tests/unit/test_credential.py | 2 +- tests/unit/test_hacking.py | 46 +++++++--------- tests/unit/test_mock.py | 26 +++++----- tests/unit/test_osclients.py | 3 +- tests/unit/test_pytest_launcher.py | 3 +- tests/unit/test_scenario.py | 3 +- tests/unit/test_test_mock.py | 38 ++++++++++---- tests/unit/test_types.py | 3 +- tests/unit/test_validators.py | 2 +- .../unit/verification/tempest/test_config.py | 7 +-- .../unit/verification/tempest/test_context.py | 15 +++--- .../unit/verification/tempest/test_manager.py | 8 +-- tests/unit/workload/test_siege.py | 3 +- tests/unit/wrappers/test_network.py | 5 +- tox.ini | 24 +++------ 197 files changed, 401 insertions(+), 372 deletions(-) diff --git a/.zuul.d/zuul.yaml b/.zuul.d/zuul.yaml index 1fa22e85..e3333f71 100644 --- a/.zuul.d/zuul.yaml +++ b/.zuul.d/zuul.yaml @@ -14,11 +14,10 @@ jobs: - rally-tox-cover - rally-tox-pep8 - - rally-tox-py27 - rally-tox-py36 - rally-tox-py37 - rally-dsvm-tox-functional - - rally-docker-check + #- rally-docker-check - rally-task-basic-with-existing-users: # use_existing_users key did not trigger proper ansible tasks voting: false @@ -74,11 +73,10 @@ jobs: - rally-tox-cover - rally-tox-pep8 - - rally-tox-py27 - rally-tox-py36 - rally-tox-py37 - rally-dsvm-tox-functional - - rally-docker-check + #- rally-docker-check - rally-task-simple-job - rally-task-cinder #- rally-task-heat diff --git a/rally_openstack/contexts/ceilometer/samples.py b/rally_openstack/contexts/ceilometer/samples.py index 884fbb65..1351bf43 100644 --- a/rally_openstack/contexts/ceilometer/samples.py +++ b/rally_openstack/contexts/ceilometer/samples.py @@ -19,7 +19,6 @@ from rally.common import utils as rutils from rally.common import validation from rally import exceptions from rally.task import context -from six import moves from rally_openstack import consts from rally_openstack.scenarios.ceilometer import utils as ceilo_utils @@ -136,7 +135,7 @@ class CeilometerSampleGenerator(context.Context): scenario = ceilo_utils.CeilometerScenario( context={"user": user, "task": self.context["task"]} ) - for i in moves.xrange(self.config["resources_per_tenant"]): + for _ in range(self.config["resources_per_tenant"]): samples_to_create = scenario._make_samples( count=self.config["samples_per_resource"], interval=self.config["timestamp_interval"], diff --git a/rally_openstack/contexts/monasca/metrics.py b/rally_openstack/contexts/monasca/metrics.py index 56a0684c..49f07599 100644 --- a/rally_openstack/contexts/monasca/metrics.py +++ b/rally_openstack/contexts/monasca/metrics.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from six import moves - from rally.common import utils as rutils from rally.common import validation from rally.task import context @@ -92,7 +90,7 @@ class MonascaMetricGenerator(context.Context): scenario = monasca_utils.MonascaScenario( context={"user": user, "task": self.context["task"]} ) - for i in moves.xrange(self.config["metrics_per_tenant"]): + for i in range(self.config["metrics_per_tenant"]): scenario._create_metrics(**new_metric) rutils.interruptable_sleep(0.001) rutils.interruptable_sleep( diff --git a/rally_openstack/contexts/sahara/sahara_input_data_sources.py b/rally_openstack/contexts/sahara/sahara_input_data_sources.py index 52f014c1..fa0de223 100644 --- a/rally_openstack/contexts/sahara/sahara_input_data_sources.py +++ b/rally_openstack/contexts/sahara/sahara_input_data_sources.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from urllib.parse import urlparse + import requests -from six.moves.urllib import parse from rally.common import utils as rutils from rally.common import validation @@ -97,7 +98,7 @@ class SaharaInputDataSources(context.Context): swift_scenario = swift_utils.SwiftScenario(clients=clients, context=self.context) # TODO(astudenov): use self.generate_random_name() - container_name = "rally_" + parse.urlparse(input_url).netloc.rstrip( + container_name = "rally_" + urlparse(input_url).netloc.rstrip( ".sahara") self.context["sahara"]["container_name"] = ( swift_scenario._create_container(container_name=container_name)) diff --git a/rally_openstack/contexts/vm/custom_image.py b/rally_openstack/contexts/vm/custom_image.py index 27e439b5..d0ef71fd 100644 --- a/rally_openstack/contexts/vm/custom_image.py +++ b/rally_openstack/contexts/vm/custom_image.py @@ -15,8 +15,6 @@ import abc -import six - from rally.common import broker from rally.common import logging from rally.common import utils @@ -32,8 +30,7 @@ from rally_openstack import types LOG = logging.getLogger(__name__) -@six.add_metaclass(abc.ABCMeta) -class BaseCustomImageGenerator(context.Context): +class BaseCustomImageGenerator(context.Context, metaclass=abc.ABCMeta): """Base plugin for the contexts providing customized image with. Every context plugin for the specific customization must implement diff --git a/rally_openstack/contexts/watcher/audit_templates.py b/rally_openstack/contexts/watcher/audit_templates.py index fecedf4e..c45dc878 100644 --- a/rally_openstack/contexts/watcher/audit_templates.py +++ b/rally_openstack/contexts/watcher/audit_templates.py @@ -14,8 +14,6 @@ import random -import six - from rally.common import validation from rally.task import context @@ -85,7 +83,7 @@ class AuditTemplateGenerator(context.Context): }) self.context["audit_templates"] = [] - for i in six.moves.range(self.config["audit_templates_per_admin"]): + for i in range(self.config["audit_templates_per_admin"]): cfg_size = len(self.config["params"]) if self.config["fill_strategy"] == "round_robin": audit_params = self.config["params"][i % cfg_size] diff --git a/rally_openstack/osclients.py b/rally_openstack/osclients.py index 217d6933..853e9f06 100644 --- a/rally_openstack/osclients.py +++ b/rally_openstack/osclients.py @@ -15,12 +15,13 @@ import abc import os +from urllib.parse import urlparse +from urllib.parse import urlunparse from rally.common import cfg from rally.common import logging from rally.common.plugin import plugin from rally import exceptions -from six.moves.urllib import parse from rally_openstack import consts from rally_openstack import credential as oscred @@ -342,13 +343,13 @@ class Keystone(OSClient): The keystone Client code requires that auth_url be the root url if a version override is used. """ - url = parse.urlparse(self.credential.auth_url) + url = urlparse(self.credential.auth_url) path = url.path.rstrip("/") if path.endswith("v2.0") or path.endswith("v3"): path = os.path.join(*os.path.split(path)[:-1]) parts = (url.scheme, url.netloc, path, url.params, url.query, url.fragment) - return parse.urlunparse(parts) + return urlunparse(parts) return self.credential.auth_url def create_client(self, version=None): diff --git a/rally_openstack/scenarios/ceilometer/utils.py b/rally_openstack/scenarios/ceilometer/utils.py index 8c35f39d..97fc3fc8 100644 --- a/rally_openstack/scenarios/ceilometer/utils.py +++ b/rally_openstack/scenarios/ceilometer/utils.py @@ -18,7 +18,6 @@ import uuid from rally import exceptions from rally.task import atomic from rally.task import utils as bench_utils -import six from rally_openstack import scenario @@ -67,7 +66,7 @@ class CeilometerScenario(scenario.OpenStackScenario): len_meta = len(metadata_list) if metadata_list else 0 now = timestamp or dt.datetime.utcnow() samples = [] - for i in six.moves.xrange(count): + for i in range(count): if i and not (i % batch_size): yield samples samples = [] diff --git a/rally_openstack/scenarios/mistral/executions.py b/rally_openstack/scenarios/mistral/executions.py index c0440d42..46b8d519 100644 --- a/rally_openstack/scenarios/mistral/executions.py +++ b/rally_openstack/scenarios/mistral/executions.py @@ -16,7 +16,6 @@ import json from rally.task import types from rally.task import validation -import six import yaml from rally_openstack import consts @@ -91,7 +90,7 @@ class CreateExecutionFromWorkbook(utils.MistralScenario): wb_def = yaml.safe_load(wb.definition) if not workflow_name: - workflow_name = six.next(six.iterkeys(wb_def["workflows"])) + workflow_name = next(iter(wb_def["workflows"].keys())) workflow_identifier = ".".join([wb.name, workflow_name]) diff --git a/rally_openstack/scenarios/vm/utils.py b/rally_openstack/scenarios/vm/utils.py index f0bf7702..ceaa4ec9 100644 --- a/rally_openstack/scenarios/vm/utils.py +++ b/rally_openstack/scenarios/vm/utils.py @@ -13,17 +13,18 @@ # License for the specific language governing permissions and limitations # under the License. +import io import os.path import subprocess import sys import netaddr + from rally.common import cfg from rally.common import logging from rally.common import sshutils from rally.task import atomic from rally.task import utils -import six from rally_openstack.scenarios.nova import utils as nova_utils from rally_openstack.wrappers import network as network_wrapper @@ -107,7 +108,7 @@ class VMScenario(nova_utils.NovaScenario): interpreter = command.get("interpreter") or [] if interpreter: - if isinstance(interpreter, six.string_types): + if isinstance(interpreter, str): interpreter = [interpreter] elif type(interpreter) != list: raise ValueError("command 'interpreter' value must be str " @@ -116,7 +117,7 @@ class VMScenario(nova_utils.NovaScenario): remote_path = command.get("remote_path") or [] if remote_path: - if isinstance(remote_path, six.string_types): + if isinstance(remote_path, str): remote_path = [remote_path] elif type(remote_path) != list: raise ValueError("command 'remote_path' value must be str " @@ -131,7 +132,7 @@ class VMScenario(nova_utils.NovaScenario): stdin = open(os.path.expanduser(command["script_file"]), "rb") elif command.get("script_inline"): - stdin = six.moves.StringIO(command["script_inline"]) + stdin = io.StringIO(command["script_inline"]) cmd.extend(command.get("command_args") or []) diff --git a/rally_openstack/validators.py b/rally_openstack/validators.py index 6434cf43..ab5f62fe 100644 --- a/rally_openstack/validators.py +++ b/rally_openstack/validators.py @@ -16,8 +16,6 @@ import inspect import os import re -import six - from rally.common import logging from rally.common import validation @@ -556,8 +554,8 @@ class RequiredCinderServicesValidator(validation.Validator): clients = context["admin"]["credential"].clients() for service in clients.cinder().services.list(): - if (service.binary == six.text_type(self.services) - and service.state == six.text_type("up")): + if (service.binary == str(self.services) + and service.state == str("up")): return self.fail("%s service is not available" % self.services) diff --git a/rally_openstack/verification/tempest/config.py b/rally_openstack/verification/tempest/config.py index 0ba568f0..94026fba 100644 --- a/rally_openstack/verification/tempest/config.py +++ b/rally_openstack/verification/tempest/config.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +import configparser import inspect +import io import os -import six -from six.moves import configparser - from rally.common import cfg from rally.common import logging from rally import exceptions @@ -216,7 +215,7 @@ class TempestConfigfileManager(object): with open(conf_path, "w") as configfile: self.conf.write(configfile) - raw_conf = six.StringIO() + raw_conf = io.StringIO() raw_conf.write("# Some empty values of options will be replaced while " "creating required resources (images, flavors, etc).\n") self.conf.write(raw_conf) diff --git a/rally_openstack/verification/tempest/context.py b/rally_openstack/verification/tempest/context.py index 554b15b1..ed82dcc9 100644 --- a/rally_openstack/verification/tempest/context.py +++ b/rally_openstack/verification/tempest/context.py @@ -13,16 +13,17 @@ # License for the specific language governing permissions and limitations # under the License. +import configparser import os import re +import requests + from rally.common import logging from rally import exceptions from rally.task import utils as task_utils from rally.verification import context from rally.verification import utils -import requests -from six.moves import configparser from rally_openstack.services.image import image from rally_openstack.verification.tempest import config as conf diff --git a/rally_openstack/wrappers/network.py b/rally_openstack/wrappers/network.py index 5e89b2fd..f8bba394 100644 --- a/rally_openstack/wrappers/network.py +++ b/rally_openstack/wrappers/network.py @@ -16,7 +16,6 @@ import abc import itertools import netaddr -import six from neutronclient.common import exceptions as neutron_exceptions from rally.common import cfg @@ -58,8 +57,7 @@ class NetworkWrapperException(exceptions.RallyException): msg_fmt = "%(message)s" -@six.add_metaclass(abc.ABCMeta) -class NetworkWrapper(object): +class NetworkWrapper(object, metaclass=abc.ABCMeta): """Base class for network service implementations. We actually have two network services implementations, with different API: diff --git a/setup.cfg b/setup.cfg index 4fd45264..423cd8f0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,6 +7,7 @@ author = OpenStack author-email = openstack-discuss@lists.openstack.org home-page = https://docs.openstack.org/rally/latest/ license = Apache License, Version 2.0 +python-requires = >=3.6 classifier = Environment :: OpenStack Intended Audience :: Developers diff --git a/test-requirements.txt b/test-requirements.txt index 3e068100..c003adda 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,7 +4,7 @@ hacking>=0.12.0,!=0.13.0 # Apache Software License -pytest>=2.7 # MIT +pytest<=5.3 # MIT # py.test plugin for measuring coverage. pytest-cov>=2.2.1 # MIT # py.test plugin for generating HTML reports diff --git a/tests/ci/osresources.py b/tests/ci/osresources.py index 8b5637bc..22f4b3ae 100755 --- a/tests/ci/osresources.py +++ b/tests/ci/osresources.py @@ -15,7 +15,6 @@ """List and compare most used OpenStack cloud resources.""" - import argparse import json import os @@ -25,7 +24,6 @@ import sys from rally.cli import cliutils from rally.common.plugin import discover from rally import plugins -import six from rally_openstack import consts from rally_openstack import credential @@ -569,7 +567,7 @@ def main(): else: out = subprocess.check_output(["rally", "deployment", "config", "--deployment", "devstack"]) - config = json.loads(out if six.PY2 else out.decode("utf-8")) + config = json.loads(out.decode("utf-8")) config = config["openstack"] config.update(config.pop("admin")) if "users" in config: diff --git a/tests/functional/test_task_samples.py b/tests/functional/test_task_samples.py index 3dbf8819..5f830897 100644 --- a/tests/functional/test_task_samples.py +++ b/tests/functional/test_task_samples.py @@ -21,8 +21,6 @@ import re import traceback import unittest -import six - from rally import api from rally.common import broker from rally.common import yamlutils as yaml @@ -127,7 +125,7 @@ class TestTaskSamples(unittest.TestCase): rapi.task.validate(deployment="MAIN", config=task_config) except Exception as e: - if not self._skip(six.text_type(e)): + if not self._skip(str(e)): failed_samples[full_path] = traceback.format_exc() broker.run(publisher, consumer, self.NUMBER_OF_THREADS) diff --git a/tests/functional/utils.py b/tests/functional/utils.py index cfeec677..f96d9783 100644 --- a/tests/functional/utils.py +++ b/tests/functional/utils.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import configparser import copy import errno import inspect @@ -22,9 +23,7 @@ import shutil import subprocess import tempfile - from oslo_utils import encodeutils -from six.moves import configparser class RallyCliError(Exception): diff --git a/tests/hacking/checks.py b/tests/hacking/checks.py index 519258be..d2d67e3c 100644 --- a/tests/hacking/checks.py +++ b/tests/hacking/checks.py @@ -83,8 +83,12 @@ def skip_ignored_lines(func): line = physical_line.strip() if not line or line.startswith("#") or line.endswith("# noqa"): return - for value in func(logical_line, physical_line, filename): - yield value + try: + for res in func(logical_line, physical_line, filename): + yield res + except StopIteration: + return + return wrapper @@ -211,9 +215,9 @@ def no_use_conf_debug_check(logical_line, physical_line, filename): point = logical_line.find("CONF.debug") if point != -1 and filename not in excluded_files: - yield(point, "N312 Don't use `CONF.debug`. " - "Function `rally.common.logging.is_debug` " - "should be used instead.") + yield (point, "N312 Don't use `CONF.debug`. " + "Function `rally.common.logging.is_debug` " + "should be used instead.") @skip_ignored_lines @@ -409,7 +413,7 @@ def check_quotes(logical_line, physical_line, filename): i += 1 if single_quotas_are_used: - yield (i, "N350 Remove Single quotes") + yield i, "N350 Remove Single quotes" @skip_ignored_lines @@ -421,10 +425,10 @@ def check_no_constructor_data_struct(logical_line, physical_line, filename): match = re_no_construct_dict.search(logical_line) if match: - yield (0, "N351 Remove dict() construct and use literal {}") + yield 0, "N351 Remove dict() construct and use literal {}" match = re_no_construct_list.search(logical_line) if match: - yield (0, "N351 Remove list() construct and use literal []") + yield 0, "N351 Remove list() construct and use literal []" def check_dict_formatting_in_string(logical_line, tokens): @@ -503,10 +507,10 @@ def check_using_unicode(logical_line, physical_line, filename): if re.search(r"\bunicode\(", logical_line): yield (0, "N353 'unicode' function is absent in python3. Please " - "use 'six.text_type' instead.") + "use 'str' instead.") -def check_raises(physical_line, filename): +def check_raises(logical_line, physical_line, filename): """Check raises usage N354 @@ -516,8 +520,8 @@ def check_raises(physical_line, filename): "./tests/hacking/checks.py"] if filename not in ignored_files: if re_raises.search(physical_line): - return (0, "N354 ':Please use ':raises Exception: conditions' " - "in docstrings.") + yield (0, "N354 ':Please use ':raises Exception: conditions' " + "in docstrings.") @skip_ignored_lines @@ -540,17 +544,7 @@ def check_datetime_alias(logical_line, physical_line, filename): N356 """ if re_datetime_alias.search(logical_line): - yield (0, "N356 Please use ``dt`` as alias for ``datetime``.") - - -@skip_ignored_lines -def check_no_six_iteritems(logical_line, physical_line, filename): - """Check no six.iteritems - - N357 - """ - if re.search(r"\six.iteritems\(\)", logical_line): - yield (0, "N357 Use dict.items() instead of six.iteritems()") + yield 0, "N356 Please use ``dt`` as alias for ``datetime``." @skip_ignored_lines @@ -583,7 +577,7 @@ def check_objects_imports_in_cli(logical_line, physical_line, filename): @skip_ignored_lines def check_log_warn(logical_line, physical_line, filename): if re_log_warn.search(logical_line): - yield(0, "N313 LOG.warn is deprecated, please use LOG.warning") + yield 0, "N313 LOG.warn is deprecated, please use LOG.warning" @skip_ignored_lines @@ -592,15 +586,18 @@ def check_opts_import_path(logical_line, physical_line, filename): N342 """ - excluded_files = ["./rally_openstack/__init__.py", - "./rally_openstack/embedcharts/osprofilerchart.py"] + excluded_files = ["./rally/task/engine.py", + "./rally/task/context.py", + "./rally/task/scenario.py", + "./rally/common/opts.py"] forbidden_methods = [".register_opts("] if filename not in excluded_files: for forbidden_method in forbidden_methods: if logical_line.find(forbidden_method) != -1: yield (0, "N342 All options should be loaded from correct " - "paths only - rally_openstack.cfg module.") + "paths only. For 'openstack' " + "its './rally/plugin/openstack/cfg'") def factory(register): @@ -625,6 +622,5 @@ def factory(register): register(check_db_imports_in_cli) register(check_objects_imports_in_cli) register(check_old_type_class) - register(check_no_six_iteritems) register(check_log_warn) register(check_opts_import_path) diff --git a/tests/unit/cleanup/test_base.py b/tests/unit/cleanup/test_base.py index d629dee9..e52a1e16 100644 --- a/tests/unit/cleanup/test_base.py +++ b/tests/unit/cleanup/test_base.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.cleanup import base from tests.unit import test diff --git a/tests/unit/cleanup/test_manager.py b/tests/unit/cleanup/test_manager.py index f0c30770..8e4970e4 100644 --- a/tests/unit/cleanup/test_manager.py +++ b/tests/unit/cleanup/test_manager.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import utils + from rally_openstack.cleanup import base from rally_openstack.cleanup import manager from tests.unit import test diff --git a/tests/unit/cleanup/test_resources.py b/tests/unit/cleanup/test_resources.py index d7497ea0..fa905088 100644 --- a/tests/unit/cleanup/test_resources.py +++ b/tests/unit/cleanup/test_resources.py @@ -14,10 +14,10 @@ # under the License. import copy +from unittest import mock from boto import exception as boto_exception import ddt -import mock from neutronclient.common import exceptions as neutron_exceptions from novaclient import exceptions as nova_exc from watcherclient.common.apiclient import exceptions as watcher_exceptions diff --git a/tests/unit/contexts/ceilometer/test_samples.py b/tests/unit/contexts/ceilometer/test_samples.py index a324b5e2..f8de38de 100644 --- a/tests/unit/contexts/ceilometer/test_samples.py +++ b/tests/unit/contexts/ceilometer/test_samples.py @@ -13,9 +13,7 @@ # under the License. import copy - -import mock -import six +from unittest import mock from rally import exceptions from rally_openstack.contexts.ceilometer import samples @@ -158,7 +156,7 @@ class CeilometerSampleGeneratorTestCase(test.TestCase): for id_ in tenants.keys(): new_context["tenants"][id_].setdefault("samples", []) new_context["tenants"][id_].setdefault("resources", []) - for i in six.moves.xrange(resources_per_tenant): + for _ in range(resources_per_tenant): for sample in samples_to_create: new_context["tenants"][id_]["samples"].append(sample) new_context["tenants"][id_]["resources"].append( diff --git a/tests/unit/contexts/cinder/test_volume_types.py b/tests/unit/contexts/cinder/test_volume_types.py index c06f7fc3..8dc11274 100644 --- a/tests/unit/contexts/cinder/test_volume_types.py +++ b/tests/unit/contexts/cinder/test_volume_types.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.cinder import volume_types from tests.unit import test diff --git a/tests/unit/contexts/cinder/test_volumes.py b/tests/unit/contexts/cinder/test_volumes.py index ec0c652c..b9a2b102 100644 --- a/tests/unit/contexts/cinder/test_volumes.py +++ b/tests/unit/contexts/cinder/test_volumes.py @@ -13,9 +13,10 @@ # under the License. import copy +from unittest import mock import ddt -import mock + from rally.task import context from rally_openstack.contexts.cinder import volumes diff --git a/tests/unit/contexts/cleanup/test_admin.py b/tests/unit/contexts/cleanup/test_admin.py index 7971815e..0385cfc4 100644 --- a/tests/unit/contexts/cleanup/test_admin.py +++ b/tests/unit/contexts/cleanup/test_admin.py @@ -13,8 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock + from rally.common import utils from rally.task import context diff --git a/tests/unit/contexts/cleanup/test_user.py b/tests/unit/contexts/cleanup/test_user.py index 4c7106fa..ddc5c49d 100644 --- a/tests/unit/contexts/cleanup/test_user.py +++ b/tests/unit/contexts/cleanup/test_user.py @@ -13,8 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock + from rally.common import utils from rally.task import context diff --git a/tests/unit/contexts/dataplane/test_heat.py b/tests/unit/contexts/dataplane/test_heat.py index 558bd5a4..a908ec3d 100644 --- a/tests/unit/contexts/dataplane/test_heat.py +++ b/tests/unit/contexts/dataplane/test_heat.py @@ -14,8 +14,7 @@ # under the License. import functools - -import mock +from unittest import mock from rally_openstack.contexts.dataplane import heat as heat_dataplane from tests.unit import test diff --git a/tests/unit/contexts/designate/test_zones.py b/tests/unit/contexts/designate/test_zones.py index e18c9da6..11d90c81 100644 --- a/tests/unit/contexts/designate/test_zones.py +++ b/tests/unit/contexts/designate/test_zones.py @@ -14,8 +14,7 @@ import copy - -import mock +from unittest import mock from rally_openstack.contexts.designate import zones from rally_openstack.scenarios.designate import utils diff --git a/tests/unit/contexts/ec2/test_servers.py b/tests/unit/contexts/ec2/test_servers.py index 60fcd789..d3cfc68c 100644 --- a/tests/unit/contexts/ec2/test_servers.py +++ b/tests/unit/contexts/ec2/test_servers.py @@ -13,8 +13,7 @@ # under the License. import copy - -import mock +from unittest import mock from rally_openstack.contexts.ec2 import servers from rally_openstack.scenarios.ec2 import utils as ec2_utils diff --git a/tests/unit/contexts/glance/test_images.py b/tests/unit/contexts/glance/test_images.py index 9c0562a9..1f6366a7 100644 --- a/tests/unit/contexts/glance/test_images.py +++ b/tests/unit/contexts/glance/test_images.py @@ -14,9 +14,9 @@ import copy +from unittest import mock import ddt -import mock from rally_openstack.contexts.glance import images from tests.unit import test diff --git a/tests/unit/contexts/heat/test_stacks.py b/tests/unit/contexts/heat/test_stacks.py index d708d7a2..27f4c8a0 100644 --- a/tests/unit/contexts/heat/test_stacks.py +++ b/tests/unit/contexts/heat/test_stacks.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.heat import stacks from rally_openstack.scenarios.heat import utils as heat_utils diff --git a/tests/unit/contexts/keystone/test_roles.py b/tests/unit/contexts/keystone/test_roles.py index 02cfe544..0ce1c751 100644 --- a/tests/unit/contexts/keystone/test_roles.py +++ b/tests/unit/contexts/keystone/test_roles.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.contexts.keystone import roles diff --git a/tests/unit/contexts/keystone/test_users.py b/tests/unit/contexts/keystone/test_users.py index c34b69cb..abc7cfc0 100644 --- a/tests/unit/contexts/keystone/test_users.py +++ b/tests/unit/contexts/keystone/test_users.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions + from rally_openstack.contexts.keystone import users from rally_openstack import credential as oscredential from tests.unit import test diff --git a/tests/unit/contexts/magnum/test_ca_certs.py b/tests/unit/contexts/magnum/test_ca_certs.py index 32781e18..f228a9ec 100644 --- a/tests/unit/contexts/magnum/test_ca_certs.py +++ b/tests/unit/contexts/magnum/test_ca_certs.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.magnum import ca_certs from tests.unit import test diff --git a/tests/unit/contexts/magnum/test_cluster_templates.py b/tests/unit/contexts/magnum/test_cluster_templates.py index e3733680..9cba28d8 100644 --- a/tests/unit/contexts/magnum/test_cluster_templates.py +++ b/tests/unit/contexts/magnum/test_cluster_templates.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.magnum import cluster_templates from rally_openstack.scenarios.magnum import utils as magnum_utils diff --git a/tests/unit/contexts/magnum/test_clusters.py b/tests/unit/contexts/magnum/test_clusters.py index 676afacc..d30c0e70 100644 --- a/tests/unit/contexts/magnum/test_clusters.py +++ b/tests/unit/contexts/magnum/test_clusters.py @@ -12,10 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. - import copy - -import mock +from unittest import mock from rally_openstack.contexts.magnum import clusters from rally_openstack.scenarios.magnum import utils as magnum_utils diff --git a/tests/unit/contexts/manila/test_manila_security_services.py b/tests/unit/contexts/manila/test_manila_security_services.py index e118df17..57664d5f 100644 --- a/tests/unit/contexts/manila/test_manila_security_services.py +++ b/tests/unit/contexts/manila/test_manila_security_services.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock -import six from rally_openstack.contexts.manila import consts from rally_openstack.contexts.manila import manila_security_services @@ -45,15 +45,15 @@ class SecurityServicesTestCase(test.ScenarioTestCase): security_services = self.SECURITY_SERVICES tenants = {} for t_id in range(self.TENANTS_AMOUNT): - tenants[six.text_type(t_id)] = {"name": six.text_type(t_id)} - tenants[six.text_type(t_id)]["networks"] = [] + tenants[str(t_id)] = {"name": str(t_id)} + tenants[str(t_id)]["networks"] = [] for i in range(networks_per_tenant): network = {"id": "fake_net_id_%s" % i} if neutron_network_provider: network["subnets"] = ["fake_subnet_id_of_net_%s" % i] else: network["cidr"] = "101.0.5.0/24" - tenants[six.text_type(t_id)]["networks"].append(network) + tenants[str(t_id)]["networks"].append(network) users = [] for t_id in tenants.keys(): for i in range(self.USERS_PER_TENANT): diff --git a/tests/unit/contexts/manila/test_manila_share_networks.py b/tests/unit/contexts/manila/test_manila_share_networks.py index c3766e39..3687e9e8 100644 --- a/tests/unit/contexts/manila/test_manila_share_networks.py +++ b/tests/unit/contexts/manila/test_manila_share_networks.py @@ -14,10 +14,9 @@ # under the License. import copy +from unittest import mock import ddt -import mock -import six from rally import exceptions from rally_openstack.contexts.manila import consts @@ -61,15 +60,15 @@ class ShareNetworksTestCase(test.TestCase): neutron_network_provider=True): tenants = {} for t_id in range(self.TENANTS_AMOUNT): - tenants[six.text_type(t_id)] = {"name": six.text_type(t_id)} - tenants[six.text_type(t_id)]["networks"] = [] + tenants[str(t_id)] = {"name": str(t_id)} + tenants[str(t_id)]["networks"] = [] for i in range(networks_per_tenant): network = {"id": "fake_net_id_%s" % i} if neutron_network_provider: network["subnets"] = ["fake_subnet_id_of_net_%s" % i] else: network["cidr"] = "101.0.5.0/24" - tenants[six.text_type(t_id)]["networks"].append(network) + tenants[str(t_id)]["networks"].append(network) users = [] for t_id in tenants.keys(): for i in range(self.USERS_PER_TENANT): diff --git a/tests/unit/contexts/manila/test_manila_shares.py b/tests/unit/contexts/manila/test_manila_shares.py index c7602068..96f317f3 100644 --- a/tests/unit/contexts/manila/test_manila_shares.py +++ b/tests/unit/contexts/manila/test_manila_shares.py @@ -14,10 +14,9 @@ # under the License. import copy +from unittest import mock import ddt -import mock -import six from rally_openstack import consts as rally_consts from rally_openstack.contexts.manila import consts @@ -52,7 +51,7 @@ class SharesTestCase(test.TestCase): share_size=1, share_proto="fake_proto", share_type=None): tenants = {} for t_id in range(self.TENANTS_AMOUNT): - tenants[six.text_type(t_id)] = {"name": six.text_type(t_id)} + tenants[str(t_id)] = {"name": str(t_id)} users = [] for t_id in sorted(list(tenants.keys())): for i in range(self.USERS_PER_TENANT): diff --git a/tests/unit/contexts/monasca/test_metrics.py b/tests/unit/contexts/monasca/test_metrics.py index 662421b1..2490ec83 100644 --- a/tests/unit/contexts/monasca/test_metrics.py +++ b/tests/unit/contexts/monasca/test_metrics.py @@ -12,8 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock -import six +from unittest import mock from rally_openstack.contexts.monasca import metrics from rally_openstack.scenarios.monasca import utils as monasca_utils @@ -26,7 +25,7 @@ class MonascaMetricGeneratorTestCase(test.TestCase): def _gen_tenants(self, count): tenants = {} - for id in six.moves.range(count): + for id in range(count): tenants[str(id)] = {"name": str(id)} return tenants @@ -35,7 +34,7 @@ class MonascaMetricGeneratorTestCase(test.TestCase): tenants = self._gen_tenants(tenants_count) users = [] for id in tenants.keys(): - for i in six.moves.range(users_per_tenant): + for i in range(users_per_tenant): users.append({"id": i, "tenant_id": id, "endpoint": mock.MagicMock()}) context = test.get_test_context() diff --git a/tests/unit/contexts/murano/test_murano_environments.py b/tests/unit/contexts/murano/test_murano_environments.py index f5b1151e..0771ae1a 100644 --- a/tests/unit/contexts/murano/test_murano_environments.py +++ b/tests/unit/contexts/murano/test_murano_environments.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.murano import murano_environments from rally_openstack.scenarios.murano import utils as murano_utils diff --git a/tests/unit/contexts/murano/test_murano_packages.py b/tests/unit/contexts/murano/test_murano_packages.py index 8805b88f..6beffc0b 100644 --- a/tests/unit/contexts/murano/test_murano_packages.py +++ b/tests/unit/contexts/murano/test_murano_packages.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.murano import murano_packages from tests.unit import test diff --git a/tests/unit/contexts/network/test_allow_ssh.py b/tests/unit/contexts/network/test_allow_ssh.py index 9ef6804d..9f306ba8 100644 --- a/tests/unit/contexts/network/test_allow_ssh.py +++ b/tests/unit/contexts/network/test_allow_ssh.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.network import allow_ssh from tests.unit import test diff --git a/tests/unit/contexts/network/test_network.py b/tests/unit/contexts/network/test_network.py index 4237a6be..82bfcd6f 100644 --- a/tests/unit/contexts/network/test_network.py +++ b/tests/unit/contexts/network/test_network.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock import netaddr from rally_openstack.contexts.network import networks as network_context diff --git a/tests/unit/contexts/network/test_routers.py b/tests/unit/contexts/network/test_routers.py index 034b7060..08839697 100644 --- a/tests/unit/contexts/network/test_routers.py +++ b/tests/unit/contexts/network/test_routers.py @@ -14,7 +14,7 @@ # under the License. import copy -import mock +from unittest import mock from rally_openstack.contexts.network import routers as router_context from rally_openstack.scenarios.neutron import utils as neutron_utils diff --git a/tests/unit/contexts/neutron/test_existing_network.py b/tests/unit/contexts/neutron/test_existing_network.py index 96b51c1e..6a1451e9 100644 --- a/tests/unit/contexts/neutron/test_existing_network.py +++ b/tests/unit/contexts/neutron/test_existing_network.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.network import existing_network from tests.unit import test diff --git a/tests/unit/contexts/neutron/test_lbaas.py b/tests/unit/contexts/neutron/test_lbaas.py index bc35fdc3..97321e5a 100644 --- a/tests/unit/contexts/neutron/test_lbaas.py +++ b/tests/unit/contexts/neutron/test_lbaas.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.neutron import lbaas as lbaas_context from tests.unit import test diff --git a/tests/unit/contexts/neutron/test_networking_agents.py b/tests/unit/contexts/neutron/test_networking_agents.py index 2cbbefc1..565a2113 100644 --- a/tests/unit/contexts/neutron/test_networking_agents.py +++ b/tests/unit/contexts/neutron/test_networking_agents.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.network import networking_agents from tests.unit import test diff --git a/tests/unit/contexts/nova/test_flavors.py b/tests/unit/contexts/nova/test_flavors.py index b1e43ac4..f8e9a5d4 100644 --- a/tests/unit/contexts/nova/test_flavors.py +++ b/tests/unit/contexts/nova/test_flavors.py @@ -14,8 +14,8 @@ # under the License. import copy +from unittest import mock -import mock from novaclient import exceptions as nova_exceptions from rally_openstack.contexts.nova import flavors diff --git a/tests/unit/contexts/nova/test_keypairs.py b/tests/unit/contexts/nova/test_keypairs.py index 0b612cf2..c5303bdd 100644 --- a/tests/unit/contexts/nova/test_keypairs.py +++ b/tests/unit/contexts/nova/test_keypairs.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.nova import keypairs from tests.unit import test diff --git a/tests/unit/contexts/nova/test_servers.py b/tests/unit/contexts/nova/test_servers.py index ac07980f..72240813 100755 --- a/tests/unit/contexts/nova/test_servers.py +++ b/tests/unit/contexts/nova/test_servers.py @@ -14,8 +14,7 @@ import copy - -import mock +from unittest import mock from rally_openstack.contexts.nova import servers from rally_openstack.scenarios.nova import utils as nova_utils diff --git a/tests/unit/contexts/quotas/test_cinder_quotas.py b/tests/unit/contexts/quotas/test_cinder_quotas.py index 3bdcb700..6e7bdbb1 100644 --- a/tests/unit/contexts/quotas/test_cinder_quotas.py +++ b/tests/unit/contexts/quotas/test_cinder_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.quotas import cinder_quotas from tests.unit import test diff --git a/tests/unit/contexts/quotas/test_designate_quotas.py b/tests/unit/contexts/quotas/test_designate_quotas.py index 4d2feb5d..f471c65f 100644 --- a/tests/unit/contexts/quotas/test_designate_quotas.py +++ b/tests/unit/contexts/quotas/test_designate_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.quotas import designate_quotas from tests.unit import test diff --git a/tests/unit/contexts/quotas/test_manila_quotas.py b/tests/unit/contexts/quotas/test_manila_quotas.py index 9c7c4087..11a24e17 100644 --- a/tests/unit/contexts/quotas/test_manila_quotas.py +++ b/tests/unit/contexts/quotas/test_manila_quotas.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.quotas import manila_quotas from tests.unit import test diff --git a/tests/unit/contexts/quotas/test_neutron_quotas.py b/tests/unit/contexts/quotas/test_neutron_quotas.py index c24acb74..d4eafabc 100644 --- a/tests/unit/contexts/quotas/test_neutron_quotas.py +++ b/tests/unit/contexts/quotas/test_neutron_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.quotas import neutron_quotas from tests.unit import test diff --git a/tests/unit/contexts/quotas/test_nova_quotas.py b/tests/unit/contexts/quotas/test_nova_quotas.py index 2c3f13a3..31fc51ba 100644 --- a/tests/unit/contexts/quotas/test_nova_quotas.py +++ b/tests/unit/contexts/quotas/test_nova_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.quotas import nova_quotas from tests.unit import test diff --git a/tests/unit/contexts/quotas/test_quotas.py b/tests/unit/contexts/quotas/test_quotas.py index d5d6beb4..8a758b20 100644 --- a/tests/unit/contexts/quotas/test_quotas.py +++ b/tests/unit/contexts/quotas/test_quotas.py @@ -14,9 +14,9 @@ # under the License. import copy +from unittest import mock import ddt -import mock from rally.common import logging from rally.task import context diff --git a/tests/unit/contexts/sahara/test_sahara_cluster.py b/tests/unit/contexts/sahara/test_sahara_cluster.py index 1fe354d1..ae802dee 100644 --- a/tests/unit/contexts/sahara/test_sahara_cluster.py +++ b/tests/unit/contexts/sahara/test_sahara_cluster.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg from rally import exceptions diff --git a/tests/unit/contexts/sahara/test_sahara_image.py b/tests/unit/contexts/sahara/test_sahara_image.py index 2d4f48a0..891e9afe 100644 --- a/tests/unit/contexts/sahara/test_sahara_image.py +++ b/tests/unit/contexts/sahara/test_sahara_image.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.contexts.sahara import sahara_image diff --git a/tests/unit/contexts/sahara/test_sahara_input_data_sources.py b/tests/unit/contexts/sahara/test_sahara_input_data_sources.py index db3cd26a..11d24fa2 100644 --- a/tests/unit/contexts/sahara/test_sahara_input_data_sources.py +++ b/tests/unit/contexts/sahara/test_sahara_input_data_sources.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.sahara import sahara_input_data_sources from rally_openstack.scenarios.swift import utils as swift_utils diff --git a/tests/unit/contexts/sahara/test_sahara_job_binaries.py b/tests/unit/contexts/sahara/test_sahara_job_binaries.py index 206768aa..fa370d93 100644 --- a/tests/unit/contexts/sahara/test_sahara_job_binaries.py +++ b/tests/unit/contexts/sahara/test_sahara_job_binaries.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.sahara import sahara_job_binaries from rally_openstack.scenarios.sahara import utils as sahara_utils diff --git a/tests/unit/contexts/sahara/test_sahara_output_data_sources.py b/tests/unit/contexts/sahara/test_sahara_output_data_sources.py index d5b4b4be..544ad3c1 100644 --- a/tests/unit/contexts/sahara/test_sahara_output_data_sources.py +++ b/tests/unit/contexts/sahara/test_sahara_output_data_sources.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.sahara import sahara_output_data_sources from rally_openstack import credential as oscredential diff --git a/tests/unit/contexts/senlin/test_profiles.py b/tests/unit/contexts/senlin/test_profiles.py index c7a57263..5c52b5e7 100644 --- a/tests/unit/contexts/senlin/test_profiles.py +++ b/tests/unit/contexts/senlin/test_profiles.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.senlin import profiles from tests.unit import test diff --git a/tests/unit/contexts/swift/test_objects.py b/tests/unit/contexts/swift/test_objects.py index 9b7f47b6..8c6b2b77 100644 --- a/tests/unit/contexts/swift/test_objects.py +++ b/tests/unit/contexts/swift/test_objects.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.contexts.swift import objects diff --git a/tests/unit/contexts/swift/test_utils.py b/tests/unit/contexts/swift/test_utils.py index d4e827d0..4b339755 100644 --- a/tests/unit/contexts/swift/test_utils.py +++ b/tests/unit/contexts/swift/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.swift import utils from tests.unit import test diff --git a/tests/unit/contexts/test_api_versions.py b/tests/unit/contexts/test_api_versions.py index 85aaebbe..acff0d28 100644 --- a/tests/unit/contexts/test_api_versions.py +++ b/tests/unit/contexts/test_api_versions.py @@ -10,8 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock + from rally.common import utils from rally import exceptions from rally.task import context diff --git a/tests/unit/contexts/vm/test_custom_image.py b/tests/unit/contexts/vm/test_custom_image.py index b33523b0..d9bce1ae 100644 --- a/tests/unit/contexts/vm/test_custom_image.py +++ b/tests/unit/contexts/vm/test_custom_image.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from rally.task import context from rally_openstack.contexts.vm import custom_image diff --git a/tests/unit/contexts/vm/test_image_command_customizer.py b/tests/unit/contexts/vm/test_image_command_customizer.py index ac98ab0d..28848e53 100644 --- a/tests/unit/contexts/vm/test_image_command_customizer.py +++ b/tests/unit/contexts/vm/test_image_command_customizer.py @@ -15,9 +15,10 @@ """Tests for the image customizer using a command execution.""" -import mock +from unittest import mock from rally import exceptions + from rally_openstack.contexts.vm import image_command_customizer from tests.unit import test diff --git a/tests/unit/contexts/watcher/test_audit_templates.py b/tests/unit/contexts/watcher/test_audit_templates.py index e848dd98..10b50167 100644 --- a/tests/unit/contexts/watcher/test_audit_templates.py +++ b/tests/unit/contexts/watcher/test_audit_templates.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.contexts.watcher import audit_templates from rally_openstack.scenarios.watcher import utils as watcher_utils diff --git a/tests/unit/doc/test_docstrings.py b/tests/unit/doc/test_docstrings.py index 64261ce6..45f78cf0 100644 --- a/tests/unit/doc/test_docstrings.py +++ b/tests/unit/doc/test_docstrings.py @@ -22,6 +22,7 @@ from rally.common.plugin import plugin from rally.common import validation from rally import plugins from rally.task import scenario + from tests.unit import test diff --git a/tests/unit/doc/test_jsonschemas.py b/tests/unit/doc/test_jsonschemas.py index 485cca6b..7e123bb2 100644 --- a/tests/unit/doc/test_jsonschemas.py +++ b/tests/unit/doc/test_jsonschemas.py @@ -17,6 +17,7 @@ import json from rally.common.plugin import plugin from rally import plugins + from tests.unit import test diff --git a/tests/unit/doc/test_task_samples.py b/tests/unit/doc/test_task_samples.py index 877a3375..ca18cbf8 100644 --- a/tests/unit/doc/test_task_samples.py +++ b/tests/unit/doc/test_task_samples.py @@ -17,14 +17,15 @@ import inspect import itertools import os import traceback +from unittest import mock + +import yaml -import mock from rally import api from rally.task import context from rally.task import engine from rally.task import scenario from rally.task import task_cfg -import yaml import rally_openstack from tests.unit import test diff --git a/tests/unit/embedcharts/test_osprofilerchart.py b/tests/unit/embedcharts/test_osprofilerchart.py index 2f3bd628..9e5c429e 100644 --- a/tests/unit/embedcharts/test_osprofilerchart.py +++ b/tests/unit/embedcharts/test_osprofilerchart.py @@ -15,8 +15,7 @@ import copy import datetime as dt import os - -import mock +from unittest import mock from rally_openstack.embedcharts import osprofilerchart as osp_chart from tests.unit import test diff --git a/tests/unit/fakes.py b/tests/unit/fakes.py index 9cee404b..090d81e3 100644 --- a/tests/unit/fakes.py +++ b/tests/unit/fakes.py @@ -18,19 +18,19 @@ import multiprocessing import random import re import string +from unittest import mock import uuid from ceilometerclient import exc as ceilometer_exc from glanceclient import exc -import mock from neutronclient.common import exceptions as neutron_exceptions from novaclient import exceptions as nova_exceptions +from swiftclient import exceptions as swift_exceptions + from rally import api from rally.common import utils as rally_utils from rally.task import context from rally.task import scenario -import six -from swiftclient import exceptions as swift_exceptions from rally_openstack import consts from rally_openstack import credential @@ -429,7 +429,7 @@ class FakeServerManager(FakeManager): pass def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) @@ -462,7 +462,7 @@ class FakeImageManager(FakeManager): return self._create(name=name) def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) @@ -543,7 +543,7 @@ class FakeKeypairManager(FakeManager): return self._cache(kp) def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) @@ -561,7 +561,7 @@ class FakeClusterTemplateManager(FakeManager): return self._cache(cluster_template) def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) @@ -578,7 +578,7 @@ class FakeStackManager(FakeManager): return self._cache(stack) def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) @@ -596,7 +596,7 @@ class FakeDomainManager(FakeManager): return self._cache(domain) def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) @@ -656,7 +656,7 @@ class FakeSecurityGroupManager(FakeManager): raise nova_exceptions.NotFound("Security Group not found") def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) @@ -927,7 +927,7 @@ class FakeDbInstanceManager(FakeManager): return self.__db_instances.values() def delete(self, resource): - if not isinstance(resource, six.string_types): + if not isinstance(resource, str): resource = resource.id cached = self.get(resource) diff --git a/tests/unit/hook/test_fault_injection.py b/tests/unit/hook/test_fault_injection.py index bd612806..1ebde2ee 100644 --- a/tests/unit/hook/test_fault_injection.py +++ b/tests/unit/hook/test_fault_injection.py @@ -13,11 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import ddt -import mock import os_faults from os_faults.api import error + from rally import consts from rally.task import hook diff --git a/tests/unit/platforms/test_existing.py b/tests/unit/platforms/test_existing.py index b6ccb359..0cdc1dd5 100644 --- a/tests/unit/platforms/test_existing.py +++ b/tests/unit/platforms/test_existing.py @@ -13,9 +13,10 @@ # under the License. import json +from unittest import mock import jsonschema -import mock + from rally.env import env_mgr from rally.env import platform from rally import exceptions diff --git a/tests/unit/rally_jobs/test_jobs.py b/tests/unit/rally_jobs/test_jobs.py index 0c33b357..8fd3300c 100644 --- a/tests/unit/rally_jobs/test_jobs.py +++ b/tests/unit/rally_jobs/test_jobs.py @@ -16,8 +16,8 @@ import os import shutil import tempfile import traceback +from unittest import mock -import mock from rally import api from rally.common.plugin import discover from rally.common import yamlutils as yaml diff --git a/tests/unit/scenarios/authenticate/test_authenticate.py b/tests/unit/scenarios/authenticate/test_authenticate.py index 1f3b17a2..d7999307 100644 --- a/tests/unit/scenarios/authenticate/test_authenticate.py +++ b/tests/unit/scenarios/authenticate/test_authenticate.py @@ -13,11 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + from rally_openstack.scenarios.authenticate import authenticate from tests.unit import test -import mock - class AuthenticateTestCase(test.ScenarioTestCase): diff --git a/tests/unit/scenarios/barbican/test_containers.py b/tests/unit/scenarios/barbican/test_containers.py index 8963a761..31adab97 100644 --- a/tests/unit/scenarios/barbican/test_containers.py +++ b/tests/unit/scenarios/barbican/test_containers.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.barbican import containers from tests.unit import test diff --git a/tests/unit/scenarios/barbican/test_orders.py b/tests/unit/scenarios/barbican/test_orders.py index cabe52fb..a8be1a81 100644 --- a/tests/unit/scenarios/barbican/test_orders.py +++ b/tests/unit/scenarios/barbican/test_orders.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.barbican import orders from tests.unit import test diff --git a/tests/unit/scenarios/barbican/test_secrets.py b/tests/unit/scenarios/barbican/test_secrets.py index 8d32b182..ee097057 100644 --- a/tests/unit/scenarios/barbican/test_secrets.py +++ b/tests/unit/scenarios/barbican/test_secrets.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.barbican import secrets from tests.unit import fakes diff --git a/tests/unit/scenarios/barbican/test_utils.py b/tests/unit/scenarios/barbican/test_utils.py index 1230d341..92ffbabb 100644 --- a/tests/unit/scenarios/barbican/test_utils.py +++ b/tests/unit/scenarios/barbican/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.barbican import utils from tests.unit import test diff --git a/tests/unit/scenarios/ceilometer/test_alarms.py b/tests/unit/scenarios/ceilometer/test_alarms.py index 435c5207..a32f08e5 100644 --- a/tests/unit/scenarios/ceilometer/test_alarms.py +++ b/tests/unit/scenarios/ceilometer/test_alarms.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.ceilometer import alarms from tests.unit import test diff --git a/tests/unit/scenarios/ceilometer/test_events.py b/tests/unit/scenarios/ceilometer/test_events.py index c253941d..bb0f825c 100644 --- a/tests/unit/scenarios/ceilometer/test_events.py +++ b/tests/unit/scenarios/ceilometer/test_events.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.scenarios.ceilometer import events diff --git a/tests/unit/scenarios/ceilometer/test_meters.py b/tests/unit/scenarios/ceilometer/test_meters.py index 1ed83684..8a0c5df6 100644 --- a/tests/unit/scenarios/ceilometer/test_meters.py +++ b/tests/unit/scenarios/ceilometer/test_meters.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.ceilometer import meters from tests.unit import test diff --git a/tests/unit/scenarios/ceilometer/test_queries.py b/tests/unit/scenarios/ceilometer/test_queries.py index ce2a9960..7045d03a 100644 --- a/tests/unit/scenarios/ceilometer/test_queries.py +++ b/tests/unit/scenarios/ceilometer/test_queries.py @@ -13,8 +13,7 @@ # under the License. import json - -import mock +from unittest import mock from rally_openstack.scenarios.ceilometer import queries from tests.unit import test diff --git a/tests/unit/scenarios/ceilometer/test_resources.py b/tests/unit/scenarios/ceilometer/test_resources.py index ea021f83..39465426 100644 --- a/tests/unit/scenarios/ceilometer/test_resources.py +++ b/tests/unit/scenarios/ceilometer/test_resources.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.scenarios.ceilometer import resources diff --git a/tests/unit/scenarios/ceilometer/test_samples.py b/tests/unit/scenarios/ceilometer/test_samples.py index 06e9d4e7..21ecc3cb 100644 --- a/tests/unit/scenarios/ceilometer/test_samples.py +++ b/tests/unit/scenarios/ceilometer/test_samples.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.ceilometer import samples from tests.unit import test diff --git a/tests/unit/scenarios/ceilometer/test_stats.py b/tests/unit/scenarios/ceilometer/test_stats.py index 04dc2970..a30ec749 100644 --- a/tests/unit/scenarios/ceilometer/test_stats.py +++ b/tests/unit/scenarios/ceilometer/test_stats.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.ceilometer import stats from tests.unit import test diff --git a/tests/unit/scenarios/ceilometer/test_traits.py b/tests/unit/scenarios/ceilometer/test_traits.py index 33ec636e..24aca004 100644 --- a/tests/unit/scenarios/ceilometer/test_traits.py +++ b/tests/unit/scenarios/ceilometer/test_traits.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.ceilometer import traits from tests.unit import test diff --git a/tests/unit/scenarios/ceilometer/test_utils.py b/tests/unit/scenarios/ceilometer/test_utils.py index adb36596..bcce7ef5 100644 --- a/tests/unit/scenarios/ceilometer/test_utils.py +++ b/tests/unit/scenarios/ceilometer/test_utils.py @@ -14,9 +14,9 @@ import copy import datetime as dt +from unittest import mock from dateutil import parser -import mock from rally import exceptions from rally_openstack.scenarios.ceilometer import utils diff --git a/tests/unit/scenarios/cinder/test_qos_specs.py b/tests/unit/scenarios/cinder/test_qos_specs.py index 7f946599..55910e78 100644 --- a/tests/unit/scenarios/cinder/test_qos_specs.py +++ b/tests/unit/scenarios/cinder/test_qos_specs.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions as rally_exceptions from rally_openstack.scenarios.cinder import qos_specs diff --git a/tests/unit/scenarios/cinder/test_utils.py b/tests/unit/scenarios/cinder/test_utils.py index 22d9816f..61816c44 100644 --- a/tests/unit/scenarios/cinder/test_utils.py +++ b/tests/unit/scenarios/cinder/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack import credential from rally_openstack.scenarios.cinder import utils diff --git a/tests/unit/scenarios/cinder/test_volume_backups.py b/tests/unit/scenarios/cinder/test_volume_backups.py index 9d9f82a1..65027fdb 100644 --- a/tests/unit/scenarios/cinder/test_volume_backups.py +++ b/tests/unit/scenarios/cinder/test_volume_backups.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.cinder import volume_backups from tests.unit import test diff --git a/tests/unit/scenarios/cinder/test_volume_types.py b/tests/unit/scenarios/cinder/test_volume_types.py index 305e0327..917a44a2 100644 --- a/tests/unit/scenarios/cinder/test_volume_types.py +++ b/tests/unit/scenarios/cinder/test_volume_types.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions as rally_exceptions from rally_openstack.scenarios.cinder import volume_types diff --git a/tests/unit/scenarios/cinder/test_volumes.py b/tests/unit/scenarios/cinder/test_volumes.py index cd5d6078..a6a63ca3 100755 --- a/tests/unit/scenarios/cinder/test_volumes.py +++ b/tests/unit/scenarios/cinder/test_volumes.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.cinder import volumes from tests.unit import test diff --git a/tests/unit/scenarios/designate/test_basic.py b/tests/unit/scenarios/designate/test_basic.py index ba07cb64..4302da14 100644 --- a/tests/unit/scenarios/designate/test_basic.py +++ b/tests/unit/scenarios/designate/test_basic.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.scenarios.designate import basic diff --git a/tests/unit/scenarios/designate/test_utils.py b/tests/unit/scenarios/designate/test_utils.py index 7c97aaa0..26f3e344 100644 --- a/tests/unit/scenarios/designate/test_utils.py +++ b/tests/unit/scenarios/designate/test_utils.py @@ -14,8 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.designate import utils from tests.unit import test diff --git a/tests/unit/scenarios/ec2/test_servers.py b/tests/unit/scenarios/ec2/test_servers.py index a34864c3..4d38ac99 100644 --- a/tests/unit/scenarios/ec2/test_servers.py +++ b/tests/unit/scenarios/ec2/test_servers.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.ec2 import servers from tests.unit import test diff --git a/tests/unit/scenarios/ec2/test_utils.py b/tests/unit/scenarios/ec2/test_utils.py index a2bcb3fa..6ac4bdf5 100644 --- a/tests/unit/scenarios/ec2/test_utils.py +++ b/tests/unit/scenarios/ec2/test_utils.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg + from rally_openstack.scenarios.ec2 import utils from tests.unit import test diff --git a/tests/unit/scenarios/glance/test_images.py b/tests/unit/scenarios/glance/test_images.py index 7eac045b..a6d6ea1b 100644 --- a/tests/unit/scenarios/glance/test_images.py +++ b/tests/unit/scenarios/glance/test_images.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.scenarios.glance import images diff --git a/tests/unit/scenarios/gnocchi/test_archive_policy.py b/tests/unit/scenarios/gnocchi/test_archive_policy.py index 44907eb8..920d700a 100644 --- a/tests/unit/scenarios/gnocchi/test_archive_policy.py +++ b/tests/unit/scenarios/gnocchi/test_archive_policy.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import archive_policy from tests.unit import test diff --git a/tests/unit/scenarios/gnocchi/test_archive_policy_rule.py b/tests/unit/scenarios/gnocchi/test_archive_policy_rule.py index 4fe37c15..270cd327 100644 --- a/tests/unit/scenarios/gnocchi/test_archive_policy_rule.py +++ b/tests/unit/scenarios/gnocchi/test_archive_policy_rule.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import archive_policy_rule from tests.unit import test diff --git a/tests/unit/scenarios/gnocchi/test_capabilities.py b/tests/unit/scenarios/gnocchi/test_capabilities.py index 21782f08..74d7429d 100644 --- a/tests/unit/scenarios/gnocchi/test_capabilities.py +++ b/tests/unit/scenarios/gnocchi/test_capabilities.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import capabilities from tests.unit import test diff --git a/tests/unit/scenarios/gnocchi/test_metric.py b/tests/unit/scenarios/gnocchi/test_metric.py index c69c7aec..40794547 100644 --- a/tests/unit/scenarios/gnocchi/test_metric.py +++ b/tests/unit/scenarios/gnocchi/test_metric.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import metric from tests.unit import test diff --git a/tests/unit/scenarios/gnocchi/test_resource.py b/tests/unit/scenarios/gnocchi/test_resource.py index 7570b592..ef33d7b2 100644 --- a/tests/unit/scenarios/gnocchi/test_resource.py +++ b/tests/unit/scenarios/gnocchi/test_resource.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import resource from tests.unit import test diff --git a/tests/unit/scenarios/gnocchi/test_resource_type.py b/tests/unit/scenarios/gnocchi/test_resource_type.py index 7daab446..cc3740c4 100644 --- a/tests/unit/scenarios/gnocchi/test_resource_type.py +++ b/tests/unit/scenarios/gnocchi/test_resource_type.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import resource_type from tests.unit import test diff --git a/tests/unit/scenarios/gnocchi/test_status.py b/tests/unit/scenarios/gnocchi/test_status.py index 64dcd365..31157901 100644 --- a/tests/unit/scenarios/gnocchi/test_status.py +++ b/tests/unit/scenarios/gnocchi/test_status.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import status from tests.unit import test diff --git a/tests/unit/scenarios/gnocchi/test_utils.py b/tests/unit/scenarios/gnocchi/test_utils.py index 7d0e366c..91fa569b 100644 --- a/tests/unit/scenarios/gnocchi/test_utils.py +++ b/tests/unit/scenarios/gnocchi/test_utils.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.gnocchi import utils from tests.unit import test diff --git a/tests/unit/scenarios/heat/test_stacks.py b/tests/unit/scenarios/heat/test_stacks.py index 3c40855e..1d0fa62e 100644 --- a/tests/unit/scenarios/heat/test_stacks.py +++ b/tests/unit/scenarios/heat/test_stacks.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions + from rally_openstack.scenarios.heat import stacks from tests.unit import test diff --git a/tests/unit/scenarios/heat/test_utils.py b/tests/unit/scenarios/heat/test_utils.py index 34b22466..961e3174 100644 --- a/tests/unit/scenarios/heat/test_utils.py +++ b/tests/unit/scenarios/heat/test_utils.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions + from rally_openstack.scenarios.heat import utils from tests.unit import test diff --git a/tests/unit/scenarios/ironic/test_nodes.py b/tests/unit/scenarios/ironic/test_nodes.py index 1c31e28c..f4949dcf 100644 --- a/tests/unit/scenarios/ironic/test_nodes.py +++ b/tests/unit/scenarios/ironic/test_nodes.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions + from rally_openstack.scenarios.ironic import nodes from tests.unit import test diff --git a/tests/unit/scenarios/ironic/test_utils.py b/tests/unit/scenarios/ironic/test_utils.py index 1ddddcd8..ad2805fe 100644 --- a/tests/unit/scenarios/ironic/test_utils.py +++ b/tests/unit/scenarios/ironic/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.ironic import utils from tests.unit import test diff --git a/tests/unit/scenarios/keystone/test_basic.py b/tests/unit/scenarios/keystone/test_basic.py index 9ea76f1c..6c57bca9 100755 --- a/tests/unit/scenarios/keystone/test_basic.py +++ b/tests/unit/scenarios/keystone/test_basic.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions from rally_openstack.scenarios.keystone import basic diff --git a/tests/unit/scenarios/loadbalancer/test_loadbalancers.py b/tests/unit/scenarios/loadbalancer/test_loadbalancers.py index b9ce410d..cd7da291 100644 --- a/tests/unit/scenarios/loadbalancer/test_loadbalancers.py +++ b/tests/unit/scenarios/loadbalancer/test_loadbalancers.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.octavia import loadbalancers from tests.unit import test diff --git a/tests/unit/scenarios/loadbalancer/test_pools.py b/tests/unit/scenarios/loadbalancer/test_pools.py index 32e0150b..9be5460c 100644 --- a/tests/unit/scenarios/loadbalancer/test_pools.py +++ b/tests/unit/scenarios/loadbalancer/test_pools.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.octavia import pools from tests.unit import test diff --git a/tests/unit/scenarios/loadbalancer/test_utils.py b/tests/unit/scenarios/loadbalancer/test_utils.py index ed0b7737..f3d0d5cb 100644 --- a/tests/unit/scenarios/loadbalancer/test_utils.py +++ b/tests/unit/scenarios/loadbalancer/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.octavia import utils from tests.unit import test diff --git a/tests/unit/scenarios/magnum/test_cluster_templates.py b/tests/unit/scenarios/magnum/test_cluster_templates.py index 279ed874..21ddbf7c 100644 --- a/tests/unit/scenarios/magnum/test_cluster_templates.py +++ b/tests/unit/scenarios/magnum/test_cluster_templates.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.magnum import cluster_templates from tests.unit import test diff --git a/tests/unit/scenarios/magnum/test_clusters.py b/tests/unit/scenarios/magnum/test_clusters.py index b8e3ab22..0201d860 100644 --- a/tests/unit/scenarios/magnum/test_clusters.py +++ b/tests/unit/scenarios/magnum/test_clusters.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions from rally_openstack.scenarios.magnum import clusters diff --git a/tests/unit/scenarios/magnum/test_k8s_pods.py b/tests/unit/scenarios/magnum/test_k8s_pods.py index 037e7cf6..dcc1f43b 100644 --- a/tests/unit/scenarios/magnum/test_k8s_pods.py +++ b/tests/unit/scenarios/magnum/test_k8s_pods.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions from rally_openstack.scenarios.magnum import k8s_pods diff --git a/tests/unit/scenarios/magnum/test_utils.py b/tests/unit/scenarios/magnum/test_utils.py index a5f00b74..17296e4f 100644 --- a/tests/unit/scenarios/magnum/test_utils.py +++ b/tests/unit/scenarios/magnum/test_utils.py @@ -12,9 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. -import os +from unittest import mock -import mock +import os from kubernetes import client as kubernetes_client from kubernetes.client.rest import ApiException diff --git a/tests/unit/scenarios/manila/test_shares.py b/tests/unit/scenarios/manila/test_shares.py index 9c34fef0..6a212a47 100644 --- a/tests/unit/scenarios/manila/test_shares.py +++ b/tests/unit/scenarios/manila/test_shares.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.manila import shares from tests.unit import test diff --git a/tests/unit/scenarios/manila/test_utils.py b/tests/unit/scenarios/manila/test_utils.py index 6482c3bc..ddd1148f 100644 --- a/tests/unit/scenarios/manila/test_utils.py +++ b/tests/unit/scenarios/manila/test_utils.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions from rally_openstack.contexts.manila import consts diff --git a/tests/unit/scenarios/mistral/test_executions.py b/tests/unit/scenarios/mistral/test_executions.py index 6c99d626..24a9a0e0 100644 --- a/tests/unit/scenarios/mistral/test_executions.py +++ b/tests/unit/scenarios/mistral/test_executions.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.mistral import executions from tests.unit import test diff --git a/tests/unit/scenarios/mistral/test_workbooks.py b/tests/unit/scenarios/mistral/test_workbooks.py index 2b543858..72e529f9 100644 --- a/tests/unit/scenarios/mistral/test_workbooks.py +++ b/tests/unit/scenarios/mistral/test_workbooks.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.mistral import workbooks from tests.unit import test diff --git a/tests/unit/scenarios/monasca/test_metrics.py b/tests/unit/scenarios/monasca/test_metrics.py index 814e69ce..435ee733 100644 --- a/tests/unit/scenarios/monasca/test_metrics.py +++ b/tests/unit/scenarios/monasca/test_metrics.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.monasca import metrics from tests.unit import test diff --git a/tests/unit/scenarios/murano/test_environments.py b/tests/unit/scenarios/murano/test_environments.py index bc12897b..dab13ee2 100644 --- a/tests/unit/scenarios/murano/test_environments.py +++ b/tests/unit/scenarios/murano/test_environments.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.murano import environments from tests.unit import test diff --git a/tests/unit/scenarios/murano/test_packages.py b/tests/unit/scenarios/murano/test_packages.py index 65a462c5..cc0c307e 100644 --- a/tests/unit/scenarios/murano/test_packages.py +++ b/tests/unit/scenarios/murano/test_packages.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.murano import packages from tests.unit import test diff --git a/tests/unit/scenarios/murano/test_utils.py b/tests/unit/scenarios/murano/test_utils.py index bf81be0d..005b495d 100644 --- a/tests/unit/scenarios/murano/test_utils.py +++ b/tests/unit/scenarios/murano/test_utils.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg + from rally_openstack.scenarios.murano import utils from tests.unit import test diff --git a/tests/unit/scenarios/neutron/test_bgpvpn.py b/tests/unit/scenarios/neutron/test_bgpvpn.py index 2fb75943..2b07bd2f 100644 --- a/tests/unit/scenarios/neutron/test_bgpvpn.py +++ b/tests/unit/scenarios/neutron/test_bgpvpn.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.neutron import bgpvpn from tests.unit import test diff --git a/tests/unit/scenarios/neutron/test_loadbalancer_v1.py b/tests/unit/scenarios/neutron/test_loadbalancer_v1.py index 227f20c5..fe5a4d7f 100644 --- a/tests/unit/scenarios/neutron/test_loadbalancer_v1.py +++ b/tests/unit/scenarios/neutron/test_loadbalancer_v1.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.neutron import loadbalancer_v1 from tests.unit import test diff --git a/tests/unit/scenarios/neutron/test_loadbalancer_v2.py b/tests/unit/scenarios/neutron/test_loadbalancer_v2.py index 7d6f3779..d7bd09af 100755 --- a/tests/unit/scenarios/neutron/test_loadbalancer_v2.py +++ b/tests/unit/scenarios/neutron/test_loadbalancer_v2.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.neutron import loadbalancer_v2 from tests.unit import test diff --git a/tests/unit/scenarios/neutron/test_network.py b/tests/unit/scenarios/neutron/test_network.py index e55cff72..072878fe 100644 --- a/tests/unit/scenarios/neutron/test_network.py +++ b/tests/unit/scenarios/neutron/test_network.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions as rally_exceptions from rally_openstack.scenarios.neutron import network diff --git a/tests/unit/scenarios/neutron/test_security_groups.py b/tests/unit/scenarios/neutron/test_security_groups.py index fc9bcf64..6d94b955 100644 --- a/tests/unit/scenarios/neutron/test_security_groups.py +++ b/tests/unit/scenarios/neutron/test_security_groups.py @@ -10,9 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import copy import ddt -import mock from rally import exceptions as rally_exceptions from rally_openstack.scenarios.neutron import security_groups diff --git a/tests/unit/scenarios/neutron/test_trunk.py b/tests/unit/scenarios/neutron/test_trunk.py index 33dea66a..a99b8a93 100644 --- a/tests/unit/scenarios/neutron/test_trunk.py +++ b/tests/unit/scenarios/neutron/test_trunk.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.neutron import trunk from tests.unit import test diff --git a/tests/unit/scenarios/neutron/test_utils.py b/tests/unit/scenarios/neutron/test_utils.py index 62807ec3..d5b4e483 100644 --- a/tests/unit/scenarios/neutron/test_utils.py +++ b/tests/unit/scenarios/neutron/test_utils.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock import netaddr from rally import exceptions diff --git a/tests/unit/scenarios/nova/test_agents.py b/tests/unit/scenarios/nova/test_agents.py index 92a0e2eb..26697a1c 100644 --- a/tests/unit/scenarios/nova/test_agents.py +++ b/tests/unit/scenarios/nova/test_agents.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.nova import agents from tests.unit import test diff --git a/tests/unit/scenarios/nova/test_aggregates.py b/tests/unit/scenarios/nova/test_aggregates.py index 9fbf91c9..715af0dc 100644 --- a/tests/unit/scenarios/nova/test_aggregates.py +++ b/tests/unit/scenarios/nova/test_aggregates.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions + from rally_openstack.scenarios.nova import aggregates from tests.unit import test diff --git a/tests/unit/scenarios/nova/test_availability_zones.py b/tests/unit/scenarios/nova/test_availability_zones.py index 41020ed2..b0dc98d7 100644 --- a/tests/unit/scenarios/nova/test_availability_zones.py +++ b/tests/unit/scenarios/nova/test_availability_zones.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.nova import availability_zones from tests.unit import test diff --git a/tests/unit/scenarios/nova/test_flavors.py b/tests/unit/scenarios/nova/test_flavors.py index 948b1370..3af20189 100644 --- a/tests/unit/scenarios/nova/test_flavors.py +++ b/tests/unit/scenarios/nova/test_flavors.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions from rally_openstack.scenarios.nova import flavors diff --git a/tests/unit/scenarios/nova/test_hypervisors.py b/tests/unit/scenarios/nova/test_hypervisors.py index 00aae583..8e404dc9 100644 --- a/tests/unit/scenarios/nova/test_hypervisors.py +++ b/tests/unit/scenarios/nova/test_hypervisors.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.nova import hypervisors from tests.unit import test diff --git a/tests/unit/scenarios/nova/test_keypairs.py b/tests/unit/scenarios/nova/test_keypairs.py index 6c426b36..faf770cf 100644 --- a/tests/unit/scenarios/nova/test_keypairs.py +++ b/tests/unit/scenarios/nova/test_keypairs.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions from rally_openstack.scenarios.nova import keypairs diff --git a/tests/unit/scenarios/nova/test_server_groups.py b/tests/unit/scenarios/nova/test_server_groups.py index 20e58303..412da029 100644 --- a/tests/unit/scenarios/nova/test_server_groups.py +++ b/tests/unit/scenarios/nova/test_server_groups.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions as rally_exceptions from rally_openstack.scenarios.nova import server_groups diff --git a/tests/unit/scenarios/nova/test_servers.py b/tests/unit/scenarios/nova/test_servers.py index 2ea01694..08cef214 100644 --- a/tests/unit/scenarios/nova/test_servers.py +++ b/tests/unit/scenarios/nova/test_servers.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally import exceptions as rally_exceptions from rally_openstack.scenarios.nova import servers diff --git a/tests/unit/scenarios/nova/test_services.py b/tests/unit/scenarios/nova/test_services.py index 68239da8..ce7e404f 100644 --- a/tests/unit/scenarios/nova/test_services.py +++ b/tests/unit/scenarios/nova/test_services.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.nova import services from tests.unit import test diff --git a/tests/unit/scenarios/nova/test_utils.py b/tests/unit/scenarios/nova/test_utils.py index a9f6f033..4c837a74 100644 --- a/tests/unit/scenarios/nova/test_utils.py +++ b/tests/unit/scenarios/nova/test_utils.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally.common import cfg from rally import exceptions as rally_exceptions diff --git a/tests/unit/scenarios/quotas/test_quotas.py b/tests/unit/scenarios/quotas/test_quotas.py index 20602775..b55e45c8 100644 --- a/tests/unit/scenarios/quotas/test_quotas.py +++ b/tests/unit/scenarios/quotas/test_quotas.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.quotas import quotas from tests.unit import test diff --git a/tests/unit/scenarios/quotas/test_utils.py b/tests/unit/scenarios/quotas/test_utils.py index 80977133..c23aefca 100644 --- a/tests/unit/scenarios/quotas/test_utils.py +++ b/tests/unit/scenarios/quotas/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.quotas import utils from tests.unit import test diff --git a/tests/unit/scenarios/sahara/test_clusters.py b/tests/unit/scenarios/sahara/test_clusters.py index 74e5e49b..9a89d974 100644 --- a/tests/unit/scenarios/sahara/test_clusters.py +++ b/tests/unit/scenarios/sahara/test_clusters.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.sahara import clusters from tests.unit import test diff --git a/tests/unit/scenarios/sahara/test_jobs.py b/tests/unit/scenarios/sahara/test_jobs.py index 664284d9..450d3d15 100644 --- a/tests/unit/scenarios/sahara/test_jobs.py +++ b/tests/unit/scenarios/sahara/test_jobs.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg from rally_openstack.scenarios.sahara import jobs diff --git a/tests/unit/scenarios/sahara/test_node_group_templates.py b/tests/unit/scenarios/sahara/test_node_group_templates.py index 03b46757..2b0241dc 100644 --- a/tests/unit/scenarios/sahara/test_node_group_templates.py +++ b/tests/unit/scenarios/sahara/test_node_group_templates.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.sahara import node_group_templates as ngts from tests.unit import test diff --git a/tests/unit/scenarios/sahara/test_utils.py b/tests/unit/scenarios/sahara/test_utils.py index fd9c1984..b3f52200 100644 --- a/tests/unit/scenarios/sahara/test_utils.py +++ b/tests/unit/scenarios/sahara/test_utils.py @@ -13,16 +13,18 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import uuidutils from saharaclient.api import base as sahara_base from rally.common import cfg from rally import exceptions + +from rally_openstack import consts from rally_openstack.scenarios.sahara import utils from tests.unit import test -from rally_openstack import consts CONF = cfg.CONF diff --git a/tests/unit/scenarios/senlin/test_clusters.py b/tests/unit/scenarios/senlin/test_clusters.py index 10d0437c..d29af09d 100644 --- a/tests/unit/scenarios/senlin/test_clusters.py +++ b/tests/unit/scenarios/senlin/test_clusters.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.senlin import clusters from tests.unit import test diff --git a/tests/unit/scenarios/senlin/test_utils.py b/tests/unit/scenarios/senlin/test_utils.py index 812d4726..92b6ee29 100644 --- a/tests/unit/scenarios/senlin/test_utils.py +++ b/tests/unit/scenarios/senlin/test_utils.py @@ -10,10 +10,11 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg from rally import exceptions + from rally_openstack.scenarios.senlin import utils from tests.unit import test diff --git a/tests/unit/scenarios/swift/test_objects.py b/tests/unit/scenarios/swift/test_objects.py index baf4a53c..8bc4fd3a 100644 --- a/tests/unit/scenarios/swift/test_objects.py +++ b/tests/unit/scenarios/swift/test_objects.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.swift import objects from tests.unit import test diff --git a/tests/unit/scenarios/swift/test_utils.py b/tests/unit/scenarios/swift/test_utils.py index 17079b1a..a674693f 100644 --- a/tests/unit/scenarios/swift/test_utils.py +++ b/tests/unit/scenarios/swift/test_utils.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.scenarios.swift import utils from tests.unit import test diff --git a/tests/unit/scenarios/vm/test_utils.py b/tests/unit/scenarios/vm/test_utils.py index 333350b2..ff1fe478 100644 --- a/tests/unit/scenarios/vm/test_utils.py +++ b/tests/unit/scenarios/vm/test_utils.py @@ -13,10 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. - import subprocess +from unittest import mock -import mock import netaddr from rally.common import cfg @@ -47,7 +46,7 @@ class VMScenarioTestCase(test.ScenarioTestCase): stdin=mock_open.side_effect()) mock_open.assert_called_once_with("foobar", "rb") - @mock.patch("%s.six.moves.StringIO" % VMTASKS_UTILS) + @mock.patch("%s.io.StringIO" % VMTASKS_UTILS) def test__run_command_over_ssh_script_inline(self, mock_string_io): mock_ssh = mock.MagicMock() vm_scenario = utils.VMScenario(self.context) diff --git a/tests/unit/scenarios/vm/test_vmtasks.py b/tests/unit/scenarios/vm/test_vmtasks.py index 98755e98..7141a580 100644 --- a/tests/unit/scenarios/vm/test_vmtasks.py +++ b/tests/unit/scenarios/vm/test_vmtasks.py @@ -14,12 +14,13 @@ # under the License. import os +from unittest import mock import ddt -import mock from rally.common import validation from rally import exceptions + from rally_openstack.scenarios.vm import vmtasks from tests.unit import test diff --git a/tests/unit/scenarios/watcher/test_basic.py b/tests/unit/scenarios/watcher/test_basic.py index 6b2fbb0e..eee34f5c 100644 --- a/tests/unit/scenarios/watcher/test_basic.py +++ b/tests/unit/scenarios/watcher/test_basic.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.watcher import basic from tests.unit import test diff --git a/tests/unit/scenarios/watcher/test_utils.py b/tests/unit/scenarios/watcher/test_utils.py index f2c69355..07372439 100644 --- a/tests/unit/scenarios/watcher/test_utils.py +++ b/tests/unit/scenarios/watcher/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg from rally_openstack.scenarios.watcher import utils diff --git a/tests/unit/scenarios/zaqar/test_basic.py b/tests/unit/scenarios/zaqar/test_basic.py index e5411837..c7fa1ce0 100644 --- a/tests/unit/scenarios/zaqar/test_basic.py +++ b/tests/unit/scenarios/zaqar/test_basic.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.zaqar import basic from tests.unit import test diff --git a/tests/unit/scenarios/zaqar/test_utils.py b/tests/unit/scenarios/zaqar/test_utils.py index 34d957eb..3bac9214 100644 --- a/tests/unit/scenarios/zaqar/test_utils.py +++ b/tests/unit/scenarios/zaqar/test_utils.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.scenarios.zaqar import utils from tests.unit import fakes diff --git a/tests/unit/services/barbican/test_secrets.py b/tests/unit/services/barbican/test_secrets.py index 19e602e3..7a465eaf 100644 --- a/tests/unit/services/barbican/test_secrets.py +++ b/tests/unit/services/barbican/test_secrets.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.services.key_manager import barbican from tests.unit import test diff --git a/tests/unit/services/gnocchi/test_metric.py b/tests/unit/services/gnocchi/test_metric.py index 0ca70ef3..ecd4eb44 100644 --- a/tests/unit/services/gnocchi/test_metric.py +++ b/tests/unit/services/gnocchi/test_metric.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.services.gnocchi import metric from tests.unit import test diff --git a/tests/unit/services/heat/test_main.py b/tests/unit/services/heat/test_main.py index 35ec9697..2c5027fe 100644 --- a/tests/unit/services/heat/test_main.py +++ b/tests/unit/services/heat/test_main.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.services.heat import main from tests.unit import test diff --git a/tests/unit/services/identity/test_identity.py b/tests/unit/services/identity/test_identity.py index 1bbbe3fd..e701fb68 100644 --- a/tests/unit/services/identity/test_identity.py +++ b/tests/unit/services/identity/test_identity.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.services.identity import identity from tests.unit import test diff --git a/tests/unit/services/identity/test_keystone_common.py b/tests/unit/services/identity/test_keystone_common.py index b750396e..654086ac 100644 --- a/tests/unit/services/identity/test_keystone_common.py +++ b/tests/unit/services/identity/test_keystone_common.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack import service from rally_openstack.services.identity import identity diff --git a/tests/unit/services/identity/test_keystone_v2.py b/tests/unit/services/identity/test_keystone_v2.py index 866622ac..8f07b58a 100644 --- a/tests/unit/services/identity/test_keystone_v2.py +++ b/tests/unit/services/identity/test_keystone_v2.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid import ddt -import mock from rally_openstack.services.identity import identity from rally_openstack.services.identity import keystone_v2 diff --git a/tests/unit/services/identity/test_keystone_v3.py b/tests/unit/services/identity/test_keystone_v3.py index 6c40d076..b8a20e4d 100644 --- a/tests/unit/services/identity/test_keystone_v3.py +++ b/tests/unit/services/identity/test_keystone_v3.py @@ -12,12 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid import ddt -import mock from rally import exceptions + from rally_openstack.services.identity import identity from rally_openstack.services.identity import keystone_v3 from tests.unit import test diff --git a/tests/unit/services/image/test_glance_common.py b/tests/unit/services/image/test_glance_common.py index da8e01e8..6161122f 100644 --- a/tests/unit/services/image/test_glance_common.py +++ b/tests/unit/services/image/test_glance_common.py @@ -12,12 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid from glanceclient import exc as glance_exc -import mock from rally import exceptions + from rally_openstack import service from rally_openstack.services.image import glance_common from rally_openstack.services.image import image diff --git a/tests/unit/services/image/test_glance_v1.py b/tests/unit/services/image/test_glance_v1.py index 9141371b..810c6b9c 100644 --- a/tests/unit/services/image/test_glance_v1.py +++ b/tests/unit/services/image/test_glance_v1.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt import fixtures -import mock from rally_openstack.services.image import glance_v1 from rally_openstack.services.image import image diff --git a/tests/unit/services/image/test_glance_v2.py b/tests/unit/services/image/test_glance_v2.py index 7972a397..f05f3d7f 100644 --- a/tests/unit/services/image/test_glance_v2.py +++ b/tests/unit/services/image/test_glance_v2.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt import fixtures -import mock from rally_openstack.services.image import glance_v2 from tests.unit import test diff --git a/tests/unit/services/image/test_image.py b/tests/unit/services/image/test_image.py index 4145ab51..b0892719 100644 --- a/tests/unit/services/image/test_image.py +++ b/tests/unit/services/image/test_image.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally_openstack.services.image import glance_v1 from rally_openstack.services.image import glance_v2 diff --git a/tests/unit/services/loadbalancer/test_octavia.py b/tests/unit/services/loadbalancer/test_octavia.py index 15a2d674..0e699999 100644 --- a/tests/unit/services/loadbalancer/test_octavia.py +++ b/tests/unit/services/loadbalancer/test_octavia.py @@ -13,11 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import fixtures -import mock from rally.common import cfg from rally import exceptions + from rally_openstack.services.loadbalancer import octavia from tests.unit import test diff --git a/tests/unit/services/storage/test_block.py b/tests/unit/services/storage/test_block.py index 598eb359..c807cdc6 100755 --- a/tests/unit/services/storage/test_block.py +++ b/tests/unit/services/storage/test_block.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack.services.storage import block from tests.unit import test diff --git a/tests/unit/services/storage/test_cinder_common.py b/tests/unit/services/storage/test_cinder_common.py index 262adf57..e55dc899 100755 --- a/tests/unit/services/storage/test_cinder_common.py +++ b/tests/unit/services/storage/test_cinder_common.py @@ -12,13 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid import ddt -import mock from rally.common import cfg from rally import exceptions + from rally_openstack import service from rally_openstack.services.storage import block from rally_openstack.services.storage import cinder_common diff --git a/tests/unit/services/storage/test_cinder_v1.py b/tests/unit/services/storage/test_cinder_v1.py index 26963d62..8c305a83 100755 --- a/tests/unit/services/storage/test_cinder_v1.py +++ b/tests/unit/services/storage/test_cinder_v1.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg + from rally_openstack.services.storage import cinder_v1 from tests.unit import fakes from tests.unit import test diff --git a/tests/unit/services/storage/test_cinder_v2.py b/tests/unit/services/storage/test_cinder_v2.py index 06809741..cdc3e32a 100755 --- a/tests/unit/services/storage/test_cinder_v2.py +++ b/tests/unit/services/storage/test_cinder_v2.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally.common import cfg + from rally_openstack.services.storage import cinder_v2 from tests.unit import fakes from tests.unit import test diff --git a/tests/unit/services/storage/test_cinder_v3.py b/tests/unit/services/storage/test_cinder_v3.py index 36ff95c7..6aa23687 100755 --- a/tests/unit/services/storage/test_cinder_v3.py +++ b/tests/unit/services/storage/test_cinder_v3.py @@ -12,8 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock + from rally.common import cfg from rally_openstack.services.storage import cinder_v3 diff --git a/tests/unit/test.py b/tests/unit/test.py index d11ef28e..19f27934 100644 --- a/tests/unit/test.py +++ b/tests/unit/test.py @@ -15,14 +15,15 @@ import fixtures import os +from unittest import mock import uuid -import mock from oslotest import base from rally.common import cfg from rally.common import db from rally import plugins + from tests.unit import fakes diff --git a/tests/unit/test_credential.py b/tests/unit/test_credential.py index c5ba6712..c1d0acea 100644 --- a/tests/unit/test_credential.py +++ b/tests/unit/test_credential.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally_openstack import credential from tests.unit import test diff --git a/tests/unit/test_hacking.py b/tests/unit/test_hacking.py index d38a90ba..f7856b48 100644 --- a/tests/unit/test_hacking.py +++ b/tests/unit/test_hacking.py @@ -10,11 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -import sys +import io import tokenize import ddt -import six from tests.hacking import checks from tests.unit import test @@ -22,14 +21,14 @@ from tests.unit import test @ddt.ddt class HackingTestCase(test.TestCase): - def setUp(self): - super(HackingTestCase, self).setUp() - # NOTE(andreykurilin): the current implementation of our hacking - # rules with a magic method skip_ignored_lines fails due to - # https://www.python.org/dev/peps/pep-0479/ rule which is enabled - # on Python 3.7 env - if sys.version_info.major == 3 and sys.version_info.minor == 7: - self.skip("There is no need to check this at all envs.") + + def _assert_good_samples(self, checker, samples, module_file="f"): + for s in samples: + self.assertEqual([], list(checker(s, s, module_file)), s) + + def _assert_bad_samples(self, checker, samples, module_file="f"): + for s in samples: + self.assertEqual(1, len(list(checker(s, s, module_file))), s) def test__parse_assert_mock_str(self): pos, method, obj = checks._parse_assert_mock_str( @@ -92,14 +91,6 @@ class HackingTestCase(test.TestCase): self.assertEqual(4, actual_number) self.assertTrue(actual_msg.startswith("N303")) - def _assert_good_samples(self, checker, samples, module_file="f"): - for s in samples: - self.assertEqual([], list(checker(s, s, module_file)), s) - - def _assert_bad_samples(self, checker, samples, module_file="f"): - for s in samples: - self.assertEqual(1, len(list(checker(s, s, module_file))), s) - def test_check_wrong_logging_import(self): bad_imports = ["from oslo_log import log", "import oslo_log", @@ -319,14 +310,14 @@ class HackingTestCase(test.TestCase): for sample in bad: sample = "print(%s)" % sample tokens = tokenize.generate_tokens( - six.moves.StringIO(sample).readline) + io.StringIO(sample).readline) self.assertEqual( 1, len(list(checks.check_dict_formatting_in_string(sample, tokens)))) sample = "print(\"%(a)05.2lF\" % d + \" added: %(a)s\" % d)" - tokens = tokenize.generate_tokens(six.moves.StringIO(sample).readline) + tokens = tokenize.generate_tokens(io.StringIO(sample).readline) self.assertEqual( 2, len(list(checks.check_dict_formatting_in_string(sample, tokens)))) @@ -338,7 +329,7 @@ class HackingTestCase(test.TestCase): for sample in good: sample = "print(%s)" % sample tokens = tokenize.generate_tokens( - six.moves.StringIO(sample).readline) + io.StringIO(sample).readline) self.assertEqual( [], list(checks.check_dict_formatting_in_string(sample, tokens))) @@ -354,13 +345,14 @@ class HackingTestCase(test.TestCase): self.assertEqual([], list(checkres)) def test_check_raises(self): - checkres = checks.check_raises( - "text = :raises: Exception if conditions", "fakefile") - self.assertIsNotNone(checkres) + self._assert_bad_samples( + checks.check_raises, + ["text = :raises: Exception if conditions"]) - checkres = checks.check_raises( - "text = :raises Exception: if conditions", "fakefile") - self.assertIsNone(checkres) + self._assert_good_samples( + checks.check_raises, + ["text = :raises Exception: if conditions"] + ) def test_check_db_imports_of_cli(self): line = "from rally.common import db" diff --git a/tests/unit/test_mock.py b/tests/unit/test_mock.py index 6a26f3fb..8299e3f4 100644 --- a/tests/unit/test_mock.py +++ b/tests/unit/test_mock.py @@ -15,8 +15,6 @@ import itertools import os import re -import six.moves - from tests.unit import test @@ -222,7 +220,9 @@ class FuncMockArgsDecoratorsChecker(ast.NodeVisitor): self.generic_visit(node) if node.col_offset == 0: - mnode = ast.Module(body=[node]) + mnode = ast.parse("") + mnode.body = [node] + mnode = ast.fix_missing_locations(mnode) code = compile(mnode, "", "exec") try: exec(code, self.globals_) @@ -241,7 +241,7 @@ class FuncMockArgsDecoratorsChecker(ast.NodeVisitor): self.generic_visit(node) def check_name(self, arg, dec_vars): - return (dec_vars is not None and arg in dec_vars) + return dec_vars is not None and arg in dec_vars def visit_FunctionDef(self, node): self.generic_visit(node) @@ -255,7 +255,7 @@ class FuncMockArgsDecoratorsChecker(ast.NodeVisitor): error_msgs = [] mismatched = False - for arg, dec_vars in six.moves.zip_longest(mock_args, mock_decs): + for arg, dec_vars in itertools.zip_longest(mock_args, mock_decs): if not self.check_name(arg, dec_vars): if arg and dec_vars: sorted_by_len = sorted( @@ -263,19 +263,19 @@ class FuncMockArgsDecoratorsChecker(ast.NodeVisitor): shortest_name = sorted_by_len.pop() if len(shortest_name) <= self.SHORTEST_VARIANT_LEN_LIMIT: error_msgs.append( - ("Argument '%(arg)s' misnamed; should be either " - "of %(dec)s that is derived from the mock " - "decorator args.\n") % {"arg": arg, - "dec": dec_vars}) + (f"Argument 'mock_{arg}' misnamed; should be " + f"either of {dec_vars} that is derived from the " + f"mock decorator args.\n") + ) elif not arg: error_msgs.append( - "Missing or malformed argument for %s decorator." - % dec_vars) + f"Missing or malformed argument for {dec_vars} " + f"decorator.") mismatched = True elif not dec_vars: error_msgs.append( - "Missing or malformed decorator for '%s' argument." - % arg) + f"Missing or malformed decorator for 'mock_{arg}' " + f"argument.") mismatched = True if error_msgs: diff --git a/tests/unit/test_osclients.py b/tests/unit/test_osclients.py index a31dc259..cfea78e6 100644 --- a/tests/unit/test_osclients.py +++ b/tests/unit/test_osclients.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally.common import cfg from rally import exceptions diff --git a/tests/unit/test_pytest_launcher.py b/tests/unit/test_pytest_launcher.py index 2d007fbe..85c6ff7a 100644 --- a/tests/unit/test_pytest_launcher.py +++ b/tests/unit/test_pytest_launcher.py @@ -13,8 +13,7 @@ # under the License. import os - -import mock +from unittest import mock from tests.ci import pytest_launcher from tests.unit import test diff --git a/tests/unit/test_scenario.py b/tests/unit/test_scenario.py index eff12375..bb853023 100644 --- a/tests/unit/test_scenario.py +++ b/tests/unit/test_scenario.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt import fixtures -import mock from rally_openstack.credential import OpenStackCredential from rally_openstack import scenario as base_scenario diff --git a/tests/unit/test_test_mock.py b/tests/unit/test_test_mock.py index a1f8e1da..287e3026 100644 --- a/tests/unit/test_test_mock.py +++ b/tests/unit/test_test_mock.py @@ -11,8 +11,8 @@ # under the License. import ast - -import mock +import sys +from unittest import mock from tests.unit import test from tests.unit import test_mock @@ -327,12 +327,17 @@ def test_func(self, mock_args, mock_args2, mock_some_longer_args): ) self.assertIsNone(self.visitor.visit_FunctionDef(self.tree)) + if sys.version_info < (3, 8): + # https://github.com/python/cpython/pull/9731 + lineno = 2 + else: + lineno = 7 self.assertEqual( [ { - "lineno": 2, + "lineno": lineno, "messages": [ - "Argument 'bar_foo_misnamed' misnamed; should be " + "Argument 'mock_bar_foo_misnamed' misnamed; should be " "either of %s that is derived from the mock decorator " "args.\n" % variants ], @@ -362,15 +367,20 @@ def test_func(self, mock_args, mock_args2, mock_some_longer_args): ) self.assertIsNone(self.visitor.visit_FunctionDef(self.tree)) + if sys.version_info < (3, 8): + # https://github.com/python/cpython/pull/9731 + lineno = 2 + else: + lineno = 7 self.assertEqual( [ { - "lineno": 2, + "lineno": lineno, "messages": [ - "Argument 'bar_foo_misnamed' misnamed; should be " + "Argument 'mock_bar_foo_misnamed' misnamed; should be " "either of %s that is derived from the mock decorator " "args.\n" % variants, - "Missing or malformed decorator for 'mismatched' " + "Missing or malformed decorator for 'mock_mismatched' " "argument." ], "args": self.visitor._get_mock_args.return_value, @@ -398,10 +408,15 @@ def test_func(self, mock_args, mock_args2, mock_some_longer_args): ) self.assertIsNone(self.visitor.visit_FunctionDef(self.tree)) + if sys.version_info < (3, 8): + # https://github.com/python/cpython/pull/9731 + lineno = 2 + else: + lineno = 7 self.assertEqual( [ { - "lineno": 2, + "lineno": lineno, "messages": [ "Missing or malformed argument for {'mock_foo', " "'mock_foo_bar', 'mock_pkg_foo_bar', ...} decorator." @@ -433,7 +448,12 @@ def test_func(self, mock_args, mock_args2, mock_some_longer_args): self.visitor.errors[0]["decs"] ) - self.assertEqual(2, self.visitor.errors[0]["lineno"]) + if sys.version_info < (3, 8): + # https://github.com/python/cpython/pull/9731 + lineno = 2 + else: + lineno = 7 + self.assertEqual(lineno, self.visitor.errors[0]["lineno"]) def test_visit_ok(self): self.visitor.classname_python = "my_class_object" diff --git a/tests/unit/test_types.py b/tests/unit/test_types.py index 35091d1f..d4b64220 100644 --- a/tests/unit/test_types.py +++ b/tests/unit/test_types.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from rally import exceptions + from rally_openstack import types from tests.unit import fakes from tests.unit import test diff --git a/tests/unit/test_validators.py b/tests/unit/test_validators.py index b4407adc..5b9ef25b 100644 --- a/tests/unit/test_validators.py +++ b/tests/unit/test_validators.py @@ -15,7 +15,7 @@ import copy import ddt -import mock +from unittest import mock from glanceclient import exc as glance_exc from novaclient import exceptions as nova_exc diff --git a/tests/unit/verification/tempest/test_config.py b/tests/unit/verification/tempest/test_config.py index 8b8cb82f..0f759b19 100644 --- a/tests/unit/verification/tempest/test_config.py +++ b/tests/unit/verification/tempest/test_config.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from rally.common import cfg from rally_openstack import osclients @@ -261,8 +262,8 @@ class TempestConfigfileManagerTestCase(test.TestCase): for item in expected: self.assertIn(item, result) - @mock.patch("%s.six.StringIO" % PATH) - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open()) + @mock.patch("%s.io.StringIO" % PATH) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open()) @mock.patch("inspect.getmembers") def test_create(self, mock_inspect_getmembers, mock_open, mock_string_io): configure_something_method = mock.MagicMock() diff --git a/tests/unit/verification/tempest/test_context.py b/tests/unit/verification/tempest/test_context.py index 869b37c1..4bb00c09 100644 --- a/tests/unit/verification/tempest/test_context.py +++ b/tests/unit/verification/tempest/test_context.py @@ -14,13 +14,14 @@ # under the License. import os +from unittest import mock import ddt -import mock import requests from rally.common import cfg from rally import exceptions + from rally_openstack.verification.tempest import config from rally_openstack.verification.tempest import context from tests.unit import fakes @@ -67,8 +68,7 @@ class TempestContextTestCase(test.TestCase): self.context.conf.add_section("orchestration") self.context.conf.add_section("scenario") - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open(), - create=True) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open(), create=True) def test__download_image_from_glance(self, mock_open): self.mock_isfile.return_value = False img_path = os.path.join(self.context.data_dir, "foo") @@ -84,7 +84,7 @@ class TempestContextTestCase(test.TestCase): mock.call("t"), mock.call("a")]) - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open()) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open()) @mock.patch("requests.get", return_value=mock.MagicMock(status_code=200)) def test__download_image_from_url_success(self, mock_get, mock_open): self.mock_isfile.return_value = False @@ -118,7 +118,7 @@ class TempestContextTestCase(test.TestCase): @mock.patch("rally_openstack.wrappers." "network.NeutronWrapper.create_network") - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open()) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open()) def test_options_configured_manually( self, mock_open, mock_neutron_wrapper_create_network): self.context.available_services = ["glance", "heat", "nova", "neutron"] @@ -168,8 +168,7 @@ class TempestContextTestCase(test.TestCase): image = self.context._discover_image() self.assertEqual("CirrOS", image.name) - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open(), - create=True) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open(), create=True) @mock.patch("rally_openstack.services.image.image.Image") @mock.patch("os.path.isfile", return_value=False) def test__download_image(self, mock_isfile, mock_image, mock_open): @@ -356,7 +355,7 @@ class TempestContextTestCase(test.TestCase): self.assertEqual("", self.context.conf.get("compute", "fixed_network_name")) - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open()) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open()) @mock.patch("%s.TempestContext._configure_option" % PATH) @mock.patch("%s.TempestContext._create_tempest_roles" % PATH) @mock.patch("rally.verification.utils.create_dir") diff --git a/tests/unit/verification/tempest/test_manager.py b/tests/unit/verification/tempest/test_manager.py index 31474455..009acab7 100644 --- a/tests/unit/verification/tempest/test_manager.py +++ b/tests/unit/verification/tempest/test_manager.py @@ -14,10 +14,10 @@ import json import os import subprocess - -import mock +from unittest import mock from rally import exceptions + from rally_openstack.verification.tempest import manager from tests.unit import test @@ -44,7 +44,7 @@ class TempestManagerTestCase(test.TestCase): self.assertEqual(os.path.join(tempest.home_dir, "tempest.conf"), tempest.configfile) - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open()) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open()) def test_get_configuration(self, mock_open): tempest = manager.TempestManager(mock.MagicMock(uuid="uuuiiiddd")) tempest.get_configuration() @@ -78,7 +78,7 @@ class TempestManagerTestCase(test.TestCase): mock_extend_configfile.assert_called_once_with(extra_options, tempest.configfile) - @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open()) + @mock.patch("%s.open" % PATH, side_effect=mock.mock_open()) def test_override_configuration(self, mock_open): tempest = manager.TempestManager(mock.MagicMock(uuid="uuuiiiddd")) new_content = mock.Mock() diff --git a/tests/unit/workload/test_siege.py b/tests/unit/workload/test_siege.py index 73844dc9..42fb9ec8 100644 --- a/tests/unit/workload/test_siege.py +++ b/tests/unit/workload/test_siege.py @@ -15,8 +15,7 @@ import sys - -import mock +from unittest import mock from rally_openstack.workload import siege diff --git a/tests/unit/wrappers/test_network.py b/tests/unit/wrappers/test_network.py index aa635fbb..39c79eeb 100644 --- a/tests/unit/wrappers/test_network.py +++ b/tests/unit/wrappers/test_network.py @@ -13,10 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt -import mock +from unittest import mock +import ddt from neutronclient.common import exceptions as neutron_exceptions + from rally.common import utils from rally_openstack import consts diff --git a/tox.ini b/tox.ini index bfa71207..f6adc5b5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,8 @@ [tox] minversion = 2.0 skipsdist = True -envlist = py27,py35,py36,py37,pep8 +ignore_basepython_conflict = true +envlist = py36,py37,py38,pep8 [testenv] extras = {env:RALLY_EXTRAS:} @@ -23,47 +24,37 @@ commands = find . -type f -name "*.pyc" -delete python {toxinidir}/tests/ci/pytest_launcher.py tests/unit --posargs={posargs} distribute = false -basepython = python2.7 +basepython = python3.6 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY REQUESTS_CA_BUNDLE [testenv:pep8] -basepython = python3 commands = flake8 distribute = false - -[testenv:py35] -basepython = python3.5 - - [testenv:py36] basepython = python3.6 [testenv:py37] basepython = python3.7 +[testenv:py38] +basepython = python3.8 + [testenv:venv] basepython = python3 commands = {posargs} [testenv:debug] -basepython = python3 -commands = oslo_debug_helper -t tests {posargs} - -[testenv:debug35] -basepython = python3.5 commands = oslo_debug_helper -t tests {posargs} [testenv:functional] -basepython = python3 sitepackages = True commands = find . -type f -name "*.pyc" -delete {toxinidir}/tests/ci/rally_functional_job.sh {posargs} [testenv:cover] -basepython = python3 commands = {toxinidir}/tests/ci/cover.sh {posargs} @@ -73,7 +64,6 @@ commands = oslo-config-generator --config-file etc/rally/rally-config-generator.conf [testenv:requirements] -basepython = python3 deps = requests[security] install_command = pip install -U {opts} {packages} commands = python {toxinidir}/tests/ci/sync_requirements.py {posargs} @@ -90,7 +80,6 @@ exclude=.venv,.git,.tox,dist,*lib/python*,*egg,tools,build,setup.py local-check-factory = tests.hacking.checks.factory [testenv:bindep] -basepython = python3 # Do not install any requirements. We want this to be fast and work even if # system dependencies are missing, since it's used to tell you what system # dependencies are missing! This also means that bindep must be installed @@ -99,7 +88,6 @@ deps = bindep commands = bindep [testenv:self] -basepython = python3 commands = {toxinidir}/tests/ci/rally_self_job.sh {toxinidir}/rally-jobs/self-rally.yaml [pytest]