Use oslotest rather than copying helpers

The basic test setup is now handled by oslotest and the recommended way
of setting up tests should be to use that.

This theoretically means we should be able to remove testtools from
test-requirements.txt however it has been left as it will likely be
needed later.

Fixtures was removed as a dependency because commonly the required
fixtures would have been set up by oslotest.

Change-Id: I7fa71207ef56ce308fbe4e7a77fa3b9a7e2444ae
This commit is contained in:
Jamie Lennox 2014-09-04 14:10:47 +10:00
parent 485cdc892c
commit 2953715bff
2 changed files with 3 additions and 33 deletions

View File

@ -6,10 +6,10 @@ hacking>=0.9.2,<0.10
coverage>=3.6
discover
fixtures>=0.3.14
python-subunit
sphinx>=1.1.2
oslosphinx
oslotest>=1.1.0.0a1
testrepository>=0.0.18
testscenarios>=0.4
testtools>=0.9.34

View File

@ -15,39 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import fixtures
import testtools
_TRUE_VALUES = ('True', 'true', '1', 'yes')
from oslotest import base
class TestCase(testtools.TestCase):
class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests."""
def setUp(self):
"""Run before each test method to initialize test environment."""
super(TestCase, self).setUp()
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
try:
test_timeout = int(test_timeout)
except ValueError:
# If timeout value is invalid do not set a timeout.
test_timeout = 0
if test_timeout > 0:
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.TempHomeDir())
if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES:
stdout = self.useFixture(fixtures.StringStream('stdout')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
self.log_fixture = self.useFixture(fixtures.FakeLogger())