From 97722b179e008ba83519b571df0068110d0848cd Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Thu, 15 Mar 2018 13:40:26 +0200 Subject: [PATCH] Remove several test dependencies * oslotest We are using just one fixture class(with only one useful code-line) from oslotest library. To reduce inheritors and simplify readability of the code, let's remove oslotest dependency. NOTE: coverage job will fail at master change with trying to import oslotest. To fix this issue oslotest is temporary added to `cover` tox env and will be removed in follow-up change * testscenarios We do not use this dependency now (or even ever?!) * coverage This library was used before we switched to pytest. Now, all we need is pytest-cov Change-Id: Id0d52f928e067ced5bf4613c291019529b43fbbf --- requirements.txt | 1 + test-requirements.txt | 3 --- tests/unit/test.py | 26 ++++++++++++++++++++++++-- tox.ini | 5 +++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4c7fd7a52b..0f55c5ad43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,7 @@ jsonschema>=2.6.0,<3.0.0 # MIT morph # GPLv3+ netaddr>=0.7.18 # BSD oslo.config>=5.1.0 # Apache Software License +# do not forget to remove `testresources` from test-requirements. it is a dependency of oslo.db for tests oslo.db>=4.27.0 # Apache Software License oslo.log>=3.36.0 # Apache Software License paramiko>=2.0.0 # LGPL diff --git a/test-requirements.txt b/test-requirements.txt index 4ffcffb91f..4e16aff40f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -12,7 +12,6 @@ pytest-html>=1.10.0 # Mozilla Public License # py.test xdist plugin for distributed testing and loop-on-failing modes pytest-xdist # MIT -coverage>=4.0,!=4.4 # Apache License, Version 2.0 ddt>=1.0.1 # UNKNOWN mock>=2.0.0 # UNKNOWN python-dateutil>=2.4.2 # Simplified BSD @@ -20,7 +19,5 @@ testtools>=2.2.0 # UNKNOWN sphinx>=1.6.2,!=1.6.6 # BSD oslosphinx>=4.7.0 # Apache Software License -oslotest>=3.2.0 # Apache Software License testresources>=2.0.0 # UNKNOWN -testscenarios>=0.4 # UNKNOWN diff --git a/tests/unit/test.py b/tests/unit/test.py index 84bd4f33cb..25ff9e4f50 100644 --- a/tests/unit/test.py +++ b/tests/unit/test.py @@ -14,11 +14,12 @@ # under the License. import fixtures +from fixtures._fixtures.tempdir import TempDir import os import uuid import mock -from oslotest import base +import testtools from rally.common import cfg from rally.common import db @@ -26,6 +27,17 @@ from rally import plugins from tests.unit import fakes +class TempHomeDir(TempDir): + """Create a temporary directory and set it as $HOME + + :ivar path: the path of the temporary directory. + """ + + def _setUp(self): + super(TempHomeDir, self)._setUp() + self.useFixture(fixtures.EnvironmentVariable("HOME", self.path)) + + class DatabaseFixture(cfg.fixture.Config): """Create clean DB before starting test.""" def setUp(self): @@ -37,13 +49,23 @@ class DatabaseFixture(cfg.fixture.Config): db.schema.schema_create() -class TestCase(base.BaseTestCase): +class TestCase(testtools.TestCase): """Test case base class for all unit tests.""" + def __init__(self, *args, **kwargs): + super(TestCase, self).__init__(*args, **kwargs) + + # This is the number of characters shown when two objects do not + # match for assertDictEqual, assertMultiLineEqual, and + # assertSequenceEqual. The default is 640 which is too + # low for comparing most dicts + self.maxDiff = 10000 + def setUp(self): super(TestCase, self).setUp() self.addCleanup(mock.patch.stopall) plugins.load() + self.useFixture(TempHomeDir()) def _test_atomic_action_timer(self, atomic_actions, name, count=1, parent=[]): diff --git a/tox.ini b/tox.ini index 329d6d1d9a..0865300ae4 100644 --- a/tox.ini +++ b/tox.ini @@ -74,6 +74,11 @@ commands = [testenv:cover] +deps = + oslotest + -c {toxinidir}/upper-constraints.txt + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt commands = {toxinidir}/tests/ci/cover.sh {posargs}