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}