From f9696d6816c5e56dee6ca4b274ef861a39d1483f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Tr=C4=99bski?= Date: Thu, 16 Feb 2017 07:08:59 +0100 Subject: [PATCH] Migrate fully to ostestr Following commit migrates python-monascaclient fully to os-testr and oslo.test Additionally: - removed mock requirement (unused) - removed sphinx requirement (unused) Change-Id: If534134ced5081ccdf40ab7963e087e29672608d --- .testr.conf | 7 +++- monascaclient/tests/test_shell.py | 10 ++++- test-requirements.txt | 6 +-- tox.ini | 66 +++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/.testr.conf b/.testr.conf index a2ff14b..0ab8e2d 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,4 +1,9 @@ [DEFAULT] -test_command=${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \ + ${PYTHON:-python} -m subunit.run discover -t ./ $OS_TEST_PATH $LISTOPT $IDOPTION + test_id_option=--load-list $IDFILE test_list_option=--list +group_regex=monascaclient\.tests(?:\.|_)([^_]+) diff --git a/monascaclient/tests/test_shell.py b/monascaclient/tests/test_shell.py index 5980847..c4a4b45 100644 --- a/monascaclient/tests/test_shell.py +++ b/monascaclient/tests/test_shell.py @@ -19,16 +19,22 @@ import sys import fixtures from keystoneclient.v3 import client as ksclient from mox3 import mox +from oslotest import base from requests_mock.contrib import fixture as requests_mock_fixture import six -import testtools from monascaclient import exc import monascaclient.shell from monascaclient.tests import fakes -class TestCase(testtools.TestCase): +class TestCase(base.BaseTestCase): + + def setUp(self): + super(TestCase, self).setUp() + + def tearDown(self): + super(TestCase, self).tearDown() def set_fake_env(self, fake_env): client_env = ('OS_USERNAME', 'OS_PASSWORD', 'OS_USER_DOMAIN_ID', diff --git a/test-requirements.txt b/test-requirements.txt index 102dc36..74932da 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,14 +1,14 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. +hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 bandit>=1.1.0 # Apache-2.0 coverage>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD -hacking<0.12,>=0.11.0 # Apache-2.0 -mock>=2.0 # BSD mox3!=0.19.0,>=0.7.0 # Apache-2.0 +oslotest>=1.10.0 # Apache-2.0 +os-testr>=0.8.0 # Apache-2.0 requests-mock>=1.1 # Apache-2.0 -sphinx>=1.5.1 # BSD testrepository>=0.0.18 # Apache-2.0/BSD testscenarios>=0.4 # Apache-2.0/BSD testtools>=1.4.0 # MIT diff --git a/tox.ini b/tox.ini index 6ac2961..05e5a3c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] -envlist = py35,py27,pypy,pep8 -minversion = 2.0 +envlist = py{27,35},pypy,cover,pep8 +minversion = 2.5 skipsdist = True [testenv] @@ -8,39 +8,73 @@ setenv = VIRTUAL_ENV={envdir} BRANCH_NAME=master CLIENT_NAME=python-monascaclient + OS_TEST_PATH=monascaclient/tests +passenv = http_proxy + HTTP_PROXY + https_proxy + HTTPS_PROXY + no_proxy + NO_PROXY usedevelop = True install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -whitelist_externals = find +whitelist_externals = bash + find + rm commands = find . -type f -name "*.pyc" -delete - python setup.py testr --slowest --testr-args='{posargs}' -[testenv:pep8] -deps = - {[testenv]deps} +[testenv:py27] +basepython = python2.7 commands = - {[testenv:flake8]commands} - {[bandit]commands} + {[testenv]commands} + ostestr {posargs} -[testenv:venv] -commands = {posargs} +[testenv:py35] +basepython = python3.5 +commands = + {[testenv]commands} + ostestr {posargs} + +[testenv:pypy] +basepython = pypy +commands = + {[testenv]commands} + ostestr {posargs} [testenv:cover] -commands = python setup.py testr --coverage --testr-args='{posargs}' +basepython = python2.7 +commands = + {[testenv]commands} + coverage erase + python setup.py test --coverage --testr-args='{posargs}' --coverage-package-name=monascaclient + coverage report + +[testenv:debug] +commands = + {[testenv]commands} + oslo_debug_helper -t {env:OS_TEST_PATH} {posargs} + +[testenv:pep8] +commands = + {[testenv:flake8]commands} + {[testenv:bandit]commands} [testenv:flake8] commands = flake8 monascaclient +[testenv:bandit] +commands = + bandit -r monascaclient -n5 -x {env:OS_TEST_PATH} + +[testenv:venv] +commands = {posargs} + [flake8] show-source = True max-line-length = 120 builtins = _ exclude=.venv,.git,.tox,dist,client_api_example.py,*lib/python*,*egg,build - -[bandit] -commands = - bandit -r monascaclient -n5 -x monascaclient/tests