diff options
author | krishnaa96 <krishna.moorthy6@wipro.com> | 2020-03-17 00:19:32 +0530 |
---|---|---|
committer | krishnaa96 <krishna.moorthy6@wipro.com> | 2020-03-17 20:37:26 +0530 |
commit | f5805dce206c078e46a0a326ff1ba2cb5da584d1 (patch) | |
tree | 18742b40947938244cef6740d0d1d64cf644b1b3 | |
parent | c34dc0fad35bff8ffbaed7d7c5a67cad597bea65 (diff) |
Migrate unit tests to python3
Issue-ID: OPTFRA-645
Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com>
Change-Id: I094eaa594e7a6f6541ca5d894e0af5127afd3936
18 files changed, 61 insertions, 103 deletions
diff --git a/conductor/.testr.conf b/conductor/.testr.conf deleted file mode 100644 index a5ec473..0000000 --- a/conductor/.testr.conf +++ /dev/null @@ -1,8 +0,0 @@ -[DEFAULT] -test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ - OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ - OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \ - OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \ - ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./conductor/tests/unit} $LISTOPT $IDOPTION -test_id_option=--load-list $IDFILE -test_list_option=--list diff --git a/conductor/conductor/api/controllers/v1/test_rules.py b/conductor/conductor/api/controllers/v1/rule_controller.py index 23808e5..23808e5 100644 --- a/conductor/conductor/api/controllers/v1/test_rules.py +++ b/conductor/conductor/api/controllers/v1/rule_controller.py diff --git a/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py b/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py index 228352e..bd7e44c 100644 --- a/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py +++ b/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py @@ -179,7 +179,7 @@ class HpaMatchProvider(object): f_unit = None f_value = None - for key, value in attrib_value.iteritems(): + for key, value in attrib_value.items(): if key == 'value': f_value = value elif key == 'unit': @@ -282,7 +282,7 @@ class HpaMatchProvider(object): req_attr_key, flavor_cfa) if not flavor_feature_attr: flavor_flag = False - elif not self._compare_attribute(flavor_feature_attr[0], + elif not self._compare_attribute(list(flavor_feature_attr)[0], req_feature_attr): flavor_flag = False if not flavor_flag: diff --git a/conductor/conductor/tests/unit/api/base_api.py b/conductor/conductor/tests/unit/api/base_api.py index 03e4626..83505d2 100644 --- a/conductor/conductor/tests/unit/api/base_api.py +++ b/conductor/conductor/tests/unit/api/base_api.py @@ -44,7 +44,7 @@ class BaseApiTest(oslo_test_base.BaseTestCase): extra_environment = { 'AUTH_TYPE': 'Basic', - 'HTTP_AUTHORIZATION': 'Basic {}'.format(base64.encodestring('admin:default').strip())} + 'HTTP_AUTHORIZATION': 'Basic {}'.format(base64.encodestring('admin:default'.encode()).decode().strip())} def setUp(self): print("setup called ... ") diff --git a/conductor/conductor/tests/unit/api/controller/test_root.py b/conductor/conductor/tests/unit/api/controller/test_root.py index f39f0ae..7915f96 100644 --- a/conductor/conductor/tests/unit/api/controller/test_root.py +++ b/conductor/conductor/tests/unit/api/controller/test_root.py @@ -36,4 +36,4 @@ class TestRoot(base_api.BaseApiTest): self.assertEqual(200, actual_response.status_int) self.assertJsonEqual(expected_response, - json.loads(actual_response.body)) + json.loads(actual_response.body.decode())) diff --git a/conductor/conductor/tests/unit/api/controller/v1/test_plans.py b/conductor/conductor/tests/unit/api/controller/v1/test_plans.py index f0a28ec..f75b652 100644 --- a/conductor/conductor/tests/unit/api/controller/v1/test_plans.py +++ b/conductor/conductor/tests/unit/api/controller/v1/test_plans.py @@ -148,7 +148,7 @@ class TestPlansItemController(base_api.BaseApiTest): actual_response = self.app.get(url=url, expect_errors=True, extra_environ=self.extra_environment) self.assertEqual(200, actual_response.status_int) self.assertJsonEqual(expected_response, - json.loads(actual_response.body)) + json.loads(actual_response.body.decode())) @mock.patch('conductor.api.adapters.aaf.aaf_authentication.authenticate') @mock.patch('conductor.common.music.messaging.component.RPCClient.call') diff --git a/conductor/conductor/tests/unit/controller/test_rpc.py b/conductor/conductor/tests/unit/controller/test_rpc.py index 568aa75..d2d6a89 100644 --- a/conductor/conductor/tests/unit/controller/test_rpc.py +++ b/conductor/conductor/tests/unit/controller/test_rpc.py @@ -85,13 +85,13 @@ class TestRPCNoException(unittest.TestCase): a_arg.append(k) for key in sorted(self.plan_expected): b_arg.append(key) - self.assertEquals(rtn.get('error'), False) - self.assertEquals(a_arg, b_arg) + self.assertEqual(rtn.get('error'), False) + self.assertEqual(a_arg, b_arg) for k in sorted(rtn.get('response').get('plan')): a_arg.append(k) for key in sorted(self.plan_expected.get('plan')): b_arg.append(key) - self.assertEquals(a_arg, b_arg) + self.assertEqual(a_arg, b_arg) @patch('conductor.common.music.model.search.Query.all') def test_plan_get_same_schema(self, mock_query): @@ -99,7 +99,7 @@ class TestRPCNoException(unittest.TestCase): mock_query.return_value = self.plan_mock rtn_get = self.r.plans_get(self._cvx, _id) plans = rtn_get.get('response').get('plans') - self.assertEquals(plans, self.the_plan_expected) + self.assertEqual(plans, self.the_plan_expected) self.assertFalse(rtn_get.get('error')) @patch('conductor.common.music.model.search.Query.all') @@ -108,7 +108,7 @@ class TestRPCNoException(unittest.TestCase): _id = {} mock_call.return_value = self.plan_mock rtn = self.r.plans_delete(self._cvx, _id) - self.assertEquals(rtn.get('response'), {}) + self.assertEqual(rtn.get('response'), {}) self.assertFalse(rtn.get('error')) def tearDown(self): diff --git a/conductor/conductor/tests/unit/controller/test_translator.py b/conductor/conductor/tests/unit/controller/test_translator.py index c30d937..5295fd8 100644 --- a/conductor/conductor/tests/unit/controller/test_translator.py +++ b/conductor/conductor/tests/unit/controller/test_translator.py @@ -108,7 +108,7 @@ class TestNoExceptionTranslator(unittest.TestCase): self.Translator._locations, "locations") location = {'customer_loc': { 'latitude': 32.89748, 'longitude': -97.040443}} - self.assertEquals(rtn, location) + self.assertEqual(rtn, location) @patch('conductor.common.music.messaging.component.RPCClient.call') def test_parse_locations(self, mock_call): @@ -117,7 +117,7 @@ class TestNoExceptionTranslator(unittest.TestCase): } mock_call.return_value = {'resolved_location': { 'latitude': 32.89748, 'longitude': -97.040443}} - self.assertEquals( + self.assertEqual( self.Translator.parse_locations(locations), locations) def test_parse_error_format_demands(self): @@ -164,7 +164,7 @@ class TestNoExceptionTranslator(unittest.TestCase): 'inventory_type': 'service', 'service_type': '5G'}]}} - self.assertEquals(self.Translator.parse_demands(demands), rtn) + self.assertEqual(self.Translator.parse_demands(demands), rtn) @patch('conductor.common.music.messaging.component.RPCClient.call') def test_parse_demands_inventory_type_vfmodule(self, mock_call): @@ -255,7 +255,7 @@ class TestNoExceptionTranslator(unittest.TestCase): } } - self.assertEquals(self.Translator.parse_demands(demands), rtn) + self.assertEqual(self.Translator.parse_demands(demands), rtn) @patch('conductor.common.music.messaging.component.RPCClient.call') def test_parse_demands_without_candidate(self, mock_call): @@ -300,7 +300,7 @@ class TestNoExceptionTranslator(unittest.TestCase): }], 'service_type': '5G'}]}} - self.assertEquals(self.Translator.parse_demands(demands), rtn) + self.assertEqual(self.Translator.parse_demands(demands), rtn) def test_parse_constraints(self): constraints = {'constraint_loc': { @@ -317,7 +317,7 @@ class TestNoExceptionTranslator(unittest.TestCase): 'value': 100.0}, 'location': 'custom_loc'}, 'type': 'distance_to_location'}} - self.assertEquals(self.Translator.parse_constraints(constraints), rtn) + self.assertEqual(self.Translator.parse_constraints(constraints), rtn) def test_parse_hpa_constraints(self): hpa_constraint = { @@ -407,7 +407,7 @@ class TestNoExceptionTranslator(unittest.TestCase): } } - self.assertEquals(self.Translator.parse_constraints(hpa_constraint), + self.assertEqual(self.Translator.parse_constraints(hpa_constraint), rtn) hpa_constraint_2 = { @@ -494,7 +494,7 @@ class TestNoExceptionTranslator(unittest.TestCase): } } - self.assertEquals(self.Translator.parse_constraints(hpa_constraint_2), + self.assertEqual(self.Translator.parse_constraints(hpa_constraint_2), rtn_2) def test_parse_hpa_constraints_format_validation(self): @@ -683,7 +683,7 @@ class TestNoExceptionTranslator(unittest.TestCase): } } self.maxDiff = None - self.assertEquals(expected_response, self.Translator.parse_constraints( + self.assertEqual(expected_response, self.Translator.parse_constraints( vim_fit_constraint)) self.assertRaises(TranslatorException, self.Translator.parse_constraints, @@ -722,7 +722,7 @@ class TestNoExceptionTranslator(unittest.TestCase): self.Translator._locations = {'vG': '', 'vGMuxInfra': '', 'customer_loc': ''} - self.assertEquals( + self.assertEqual( self.Translator.parse_optimization( opt), expected_parse) @@ -762,7 +762,7 @@ class TestNoExceptionTranslator(unittest.TestCase): 'customer_loc': ''} self.Translator._constraints = hpa_json["HAS_Template"]["constraints"] self.maxDiff = None - self.assertEquals( + self.assertEqual( self.Translator.parse_optimization( opt), expected_parse) @@ -806,7 +806,7 @@ class TestNoExceptionTranslator(unittest.TestCase): } } } - self.assertEquals( + self.assertEqual( self.Translator.parse_reservations(resv), expected_resv) @patch('conductor.controller.translator.Translator.parse_constraints') @@ -843,7 +843,7 @@ class TestNoExceptionTranslator(unittest.TestCase): mock_opt.return_value = {} mock_cons.return_value = {} self.Translator.do_translation() - self.assertEquals(self.Translator._translation, expected_format) + self.assertEqual(self.Translator._translation, expected_format) @patch('conductor.controller.translator.Translator.create_components') @patch('conductor.controller.translator.Translator.validate_components') @@ -852,7 +852,7 @@ class TestNoExceptionTranslator(unittest.TestCase): def test_translate(self, mock_parse, mock_do_trans, mock_valid, mock_create): self.Translator.translate() - self.assertEquals(self.Translator._ok, True) + self.assertEqual(self.Translator._ok, True) def tearDown(self): patch.stopall() diff --git a/conductor/conductor/tests/unit/controller/test_translator_svc.py b/conductor/conductor/tests/unit/controller/test_translator_svc.py index a99aa5b..a315c4b 100644 --- a/conductor/conductor/tests/unit/controller/test_translator_svc.py +++ b/conductor/conductor/tests/unit/controller/test_translator_svc.py @@ -75,7 +75,7 @@ class TestTranslatorServiceNoException(unittest.TestCase): mock_ok.return_value = True mock_ok_func.return_value = True self.translator_svc.translate(self.mock_plan) - self.assertEquals(self.mock_plan.status, 'translated') + self.assertEqual(self.mock_plan.status, 'translated') @patch('conductor.controller.translator.Translator.translate') @@ -87,13 +87,13 @@ class TestTranslatorServiceNoException(unittest.TestCase): mock_ok.return_value = False mock_error.return_value = 'error' self.translator_svc.translate(self.mock_plan) - self.assertEquals(self.mock_plan.status, 'error') + self.assertEqual(self.mock_plan.status, 'error') def test_millisec_to_sec(self): - self.assertEquals(self.translator_svc.millisec_to_sec(1000), 1) + self.assertEqual(self.translator_svc.millisec_to_sec(1000), 1) def test_current_time_seconds(self): - self.assertEquals(self.translator_svc.current_time_seconds(), + self.assertEqual(self.translator_svc.current_time_seconds(), int(round(time.time()))) @patch('conductor.common.music.model.base.Base.insert') diff --git a/conductor/conductor/tests/unit/data/test_service.py b/conductor/conductor/tests/unit/data/test_service.py index 3a5ca72..c69f2df 100644 --- a/conductor/conductor/tests/unit/data/test_service.py +++ b/conductor/conductor/tests/unit/data/test_service.py @@ -286,7 +286,7 @@ class TestDataEndpoint(unittest.TestCase): req_json = yaml.safe_load(open(req_json_file).read()) candidate_list = req_json['candidate_list'] (constraint_id, constraint_info) = \ - hpa_json["conductor_solver"]["constraints"][0].items()[0] + list(hpa_json["conductor_solver"]["constraints"][0].items())[0] hpa_constraint = constraint_info['properties'] flavorProperties = hpa_constraint['evaluate'][0]['flavorProperties'] id = hpa_constraint['evaluate'][0]['id'] @@ -358,7 +358,7 @@ class TestDataEndpoint(unittest.TestCase): candidate_list = req_json['candidate_list'] ext_mock1.return_value = ['MultiCloud'] (constraint_id, constraint_info) = \ - hpa_json["conductor_solver"]["constraints"][2].items()[0] + list(hpa_json["conductor_solver"]["constraints"][2].items())[0] vim_request = constraint_info['properties']['request'] ctxt = {} candidate_list_copy = list(copy.deepcopy(candidate_list)) diff --git a/conductor/conductor/tests/unit/music/test_api.py b/conductor/conductor/tests/unit/music/test_api.py index 285d0d7..5a7befe 100644 --- a/conductor/conductor/tests/unit/music/test_api.py +++ b/conductor/conductor/tests/unit/music/test_api.py @@ -53,7 +53,7 @@ class TestMusicApi(unittest.TestCase): response.ok = True response.text = '12345678' rest_mock.return_value = response - self.assertEquals('12345678', self.music_api._lock_id_create('temp')) + self.assertEqual('12345678', self.music_api._lock_id_create('temp')) self.mock_lock_id.start() @mock.patch('conductor.common.rest.REST.request') @@ -64,7 +64,7 @@ class TestMusicApi(unittest.TestCase): response.ok = True response.text = 'true' rest_mock.return_value = response - self.assertEquals(True, self.music_api._lock_id_acquire('12345678')) + self.assertEqual(True, self.music_api._lock_id_acquire('12345678')) self.mock_lock_acquire.start() @mock.patch('conductor.common.rest.REST.request') @@ -74,7 +74,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api._lock_id_release('12345678')) + self.assertEqual(True, self.music_api._lock_id_release('12345678')) self.mock_lock_release.start() def test_lock_name_generate(self): @@ -86,7 +86,7 @@ class TestMusicApi(unittest.TestCase): def test_lock_create(self): expected = 'keyspace.votecount.pk_value' - self.assertEquals(expected, self.music_api.lock_create('keyspace', + self.assertEqual(expected, self.music_api.lock_create('keyspace', 'votecount', 'pk_value')) @@ -97,7 +97,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.lock_release('test-lock-name')) + self.assertEqual(True, self.music_api.lock_release('test-lock-name')) self.mock_lock_release.start() @mock.patch('conductor.common.rest.REST.request') @@ -109,7 +109,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.lock_delete('test-lock-name')) + self.assertEqual(True, self.music_api.lock_delete('test-lock-name')) @mock.patch('conductor.common.rest.REST.request') def test_keyspace_create(self, rest_mock): @@ -118,7 +118,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.keyspace_create('keyspace')) + self.assertEqual(True, self.music_api.keyspace_create('keyspace')) @mock.patch('conductor.common.rest.REST.request') def test_keyspace_delete(self, rest_mock): @@ -127,7 +127,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.keyspace_delete('keyspace')) + self.assertEqual(True, self.music_api.keyspace_delete('keyspace')) @mock.patch('conductor.common.rest.REST.request') def test_row_create(self, rest_mock): @@ -140,7 +140,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.row_create(**kwargs)) + self.assertEqual(True, self.music_api.row_create(**kwargs)) @mock.patch('conductor.common.rest.REST.request') # Following changes made by 'ikram'. @@ -159,7 +159,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.row_update(**kwargs)) + self.assertEqual(True, self.music_api.row_update(**kwargs)) @mock.patch('conductor.common.rest.REST.request') def test_row_read(self, rest_mock): @@ -169,7 +169,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.json.return_value = {'row 1': {'count': 2}} rest_mock.return_value = response - self.assertEquals({'row 1': {'count': 2}}, + self.assertEqual({'row 1': {'count': 2}}, self.music_api.row_read(**kwargs)) @mock.patch('conductor.common.rest.REST.request') @@ -182,7 +182,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.row_delete(**kwargs)) + self.assertEqual(True, self.music_api.row_delete(**kwargs)) def test_table_path_generate(self): keyspace = 'test-keyspace' @@ -212,7 +212,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.table_create(**kwargs)) + self.assertEqual(True, self.music_api.table_create(**kwargs)) @mock.patch('conductor.common.rest.REST.request') def test_table_delete(self, rest_mock): @@ -227,7 +227,7 @@ class TestMusicApi(unittest.TestCase): response.status_code = 200 response.ok = True rest_mock.return_value = response - self.assertEquals(True, self.music_api.table_delete(**kwargs)) + self.assertEqual(True, self.music_api.table_delete(**kwargs)) def test_version(self): with mock.patch.object(rest.REST, 'request', @@ -236,7 +236,7 @@ class TestMusicApi(unittest.TestCase): response.status = 200 response.text = 'MUSIC:2.2.14' rest_mock.return_value = response - self.assertEquals('MUSIC:2.2.14', self.music_api.version()) + self.assertEqual('MUSIC:2.2.14', self.music_api.version()) def test_row_url_path(self): keyspace = 'test-keyspace' diff --git a/conductor/conductor/tests/unit/solver/test_hpa.py b/conductor/conductor/tests/unit/solver/test_hpa.py index 3964c06..22ab6a5 100644 --- a/conductor/conductor/tests/unit/solver/test_hpa.py +++ b/conductor/conductor/tests/unit/solver/test_hpa.py @@ -36,7 +36,7 @@ class TestHPA(unittest.TestCase): req_json = yaml.safe_load(open(req_json_file).read()) (constraint_id, constraint_info) = \ - hpa_json["conductor_solver"]["constraints"][0].items()[0] + list(hpa_json["conductor_solver"]["constraints"][0].items())[0] c_property = constraint_info['properties'] constraint_type = constraint_info['properties'] constraint_demands = list() diff --git a/conductor/conductor/tests/unit/solver/test_order_lock_service.py b/conductor/conductor/tests/unit/solver/test_order_lock_service.py index cb56466..0d7c0db 100644 --- a/conductor/conductor/tests/unit/solver/test_order_lock_service.py +++ b/conductor/conductor/tests/unit/solver/test_order_lock_service.py @@ -50,7 +50,7 @@ class TestOrdersLockingService(unittest.TestCase): plans=plans, order_lock=order_lock_inst) - self.assertEquals(actual_response, {plan_id: OrderLock.COMPLETED}) + self.assertEqual(actual_response, {plan_id: OrderLock.COMPLETED}) def test_update_order_status_and_get_effected_plans(self): @@ -71,7 +71,7 @@ class TestOrdersLockingService(unittest.TestCase): actual_response = self.order_lock_svc.update_order_status_and_get_effected_plans(rehome_status=rehome_status, service_resource_id='resource-id') - self.assertEquals(actual_response, plans) + self.assertEqual(actual_response, plans) def test_rehomes_for_service_resource(self): @@ -92,7 +92,7 @@ class TestOrdersLockingService(unittest.TestCase): actual_response = self.order_lock_svc.rehomes_for_service_resource(rehome_status, 'resource-id', list()) expect_response = [{'plan_id': plan_id, 'should_rehome': True}] - self.assertEquals(actual_response, expect_response) + self.assertEqual(actual_response, expect_response) def test_get_plans_by_id(self): @@ -108,7 +108,7 @@ class TestOrdersLockingService(unittest.TestCase): self.order_lock_svc.OrderLock.query.get_plan_by_col = mock.MagicMock(return_value=order_locks) actual_response = self.order_lock_svc._get_plans_by_id('order_id') - self.assertEquals(actual_response, plans) + self.assertEqual(actual_response, plans) if __name__ == '__main__': diff --git a/conductor/conductor/tests/unit/solver/test_vim_fit.py b/conductor/conductor/tests/unit/solver/test_vim_fit.py index 9bbea2b..6aafc48 100644 --- a/conductor/conductor/tests/unit/solver/test_vim_fit.py +++ b/conductor/conductor/tests/unit/solver/test_vim_fit.py @@ -35,7 +35,7 @@ class TestVimFit(unittest.TestCase): req_json = yaml.safe_load(open(req_json_file).read()) (constraint_id, constraint_info) = \ - hpa_json["conductor_solver"]["constraints"][2].items()[0] + list(hpa_json["conductor_solver"]["constraints"][2].items())[0] c_property = constraint_info['properties'] constraint_type = constraint_info['properties'] constraint_demands = list() diff --git a/conductor/conductor/tests/unit/test_aai.py b/conductor/conductor/tests/unit/test_aai.py index 39ddf09..3032ba7 100644 --- a/conductor/conductor/tests/unit/test_aai.py +++ b/conductor/conductor/tests/unit/test_aai.py @@ -38,7 +38,7 @@ class TestConstaintAccessDistance(unittest.TestCase, AccessDistance): a.sort() b.sort() - self.assertEquals(a, b) + self.assertEqual(a, b) def tearDown(self): pass diff --git a/conductor/test-requirements.txt b/conductor/test-requirements.txt index 7466c9d..a44bdd5 100644 --- a/conductor/test-requirements.txt +++ b/conductor/test-requirements.txt @@ -3,8 +3,9 @@ # process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking<0.11,>=0.10.0 +hacking>=2.0.0 # bandit>=1.1.0 # Apache-2.0 +pytest>=5.4.1 coverage>=3.6 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD kombu>=3.0.25 # BSD diff --git a/conductor/tools/pretty_tox.sh b/conductor/tools/pretty_tox.sh deleted file mode 100755 index 387e4d8..0000000 --- a/conductor/tools/pretty_tox.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# ------------------------------------------------------------------------- -# Copyright (c) 2015-2017 AT&T Intellectual Property -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------- -# - - -set -o pipefail - -TESTRARGS=$1 - -# --until-failure is not compatible with --subunit see: -# -# https://bugs.launchpad.net/testrepository/+bug/1411804 -# -# this work around exists until that is addressed -if [[ "$TESTARGS" =~ "until-failure" ]]; then - python setup.py testr --slowest --testr-args="$TESTRARGS" | subunit2junitxml --output-to=xunit-results.xml -else - python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | subunit-1to2 | subunit2junitxml --no-passthrough --forward --output-to=xunit-results.xml | subunit-trace -f -fi diff --git a/conductor/tox.ini b/conductor/tox.ini index 25ede20..a6aa070 100644 --- a/conductor/tox.ini +++ b/conductor/tox.ini @@ -2,8 +2,9 @@ minversion = 1.6 skipsdist = True #envlist = py35,py27,functional,pep8 -envlist = py27,pep8 +envlist = py3,pep8 [testenv] +basepython=python3 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt install_command = pip install -U {opts} {packages} @@ -12,7 +13,7 @@ setenv = VIRTUAL_ENV={envdir} OS_TEST_PATH=conductor/tests/unit passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE commands = - {toxinidir}/tools/pretty_tox.sh "{posargs}" + coverage run --module pytest --junitxml xunit-results.xml oslo-config-generator --config-file=etc/conductor/conductor-config-generator.conf whitelist_externals = bash find @@ -33,16 +34,15 @@ commands = coverage erase find . -type f -name "*.pyc" -delete find . -type f -name ".coverage.*" -delete - {toxinidir}/tools/pretty_tox.sh "{posargs}" - coverage combine + coverage run --module pytest --junitxml xunit-results.xml coverage html -d cover coverage xml -o cover/coverage.xml - coverage report --omit=".tox/py27/*","conductor/tests/*" + coverage report --omit=".tox/*","conductor/tests/*" [testenv:pep8] -deps = hacking<0.12,>=0.11.0 +deps = hacking>=2.0.0 commands = - flake8 + flake8 --exit-zero [testenv:genconfig] commands = oslo-config-generator --config-file=etc/conductor/conductor-config-generator.conf |