Merge "Use gabbi inner_fixtures for better error capture"
This commit is contained in:
commit
dce330b0e6
@ -10,7 +10,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from gabbi import fixture
|
from gabbi import fixture
|
||||||
@ -38,25 +37,15 @@ class APIFixture(fixture.GabbiFixture):
|
|||||||
self.conf = None
|
self.conf = None
|
||||||
|
|
||||||
def start_fixture(self):
|
def start_fixture(self):
|
||||||
# Set up a logger for errors that will display to screen,
|
|
||||||
# otherwise gabbi failures can be hard to debug while doing
|
|
||||||
# TDD. Establish here but don't add until after the logging
|
|
||||||
# fixture is started, because that cares about handler
|
|
||||||
# ordering.
|
|
||||||
error_log = logging.StreamHandler()
|
|
||||||
error_log.setLevel(logging.ERROR)
|
|
||||||
|
|
||||||
# Set up stderr and stdout captures by directly driving the
|
# Set up stderr and stdout captures by directly driving the
|
||||||
# existing nova fixtures that do that.
|
# existing nova fixtures that do that. This captures the
|
||||||
|
# output that happens outside individual tests (for
|
||||||
|
# example database migrations).
|
||||||
self.standard_logging_fixture = fixtures.StandardLogging()
|
self.standard_logging_fixture = fixtures.StandardLogging()
|
||||||
self.standard_logging_fixture.setUp()
|
self.standard_logging_fixture.setUp()
|
||||||
self.output_stream_fixture = fixtures.OutputStreamCapture()
|
self.output_stream_fixture = fixtures.OutputStreamCapture()
|
||||||
self.output_stream_fixture.setUp()
|
self.output_stream_fixture.setUp()
|
||||||
|
|
||||||
# add the error handler
|
|
||||||
# catastrophic error messages in a useful way
|
|
||||||
logging.getLogger().addHandler(error_log)
|
|
||||||
|
|
||||||
self.conf = CONF
|
self.conf = CONF
|
||||||
self.conf.set_override('auth_strategy', 'noauth2')
|
self.conf.set_override('auth_strategy', 'noauth2')
|
||||||
# Be explicit about all three database connections to avoid
|
# Be explicit about all three database connections to avoid
|
||||||
|
@ -14,6 +14,7 @@ import os
|
|||||||
|
|
||||||
from gabbi import driver
|
from gabbi import driver
|
||||||
|
|
||||||
|
from nova.tests import fixtures as nova_fixtures
|
||||||
from nova.tests.functional.api.openstack.placement import fixtures
|
from nova.tests.functional.api.openstack.placement import fixtures
|
||||||
|
|
||||||
TESTS_DIR = 'gabbits'
|
TESTS_DIR = 'gabbits'
|
||||||
@ -22,7 +23,14 @@ TESTS_DIR = 'gabbits'
|
|||||||
def load_tests(loader, tests, pattern):
|
def load_tests(loader, tests, pattern):
|
||||||
"""Provide a TestSuite to the discovery process."""
|
"""Provide a TestSuite to the discovery process."""
|
||||||
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
||||||
|
# These inner fixtures provide per test request output and log
|
||||||
|
# capture, for cleaner results reporting.
|
||||||
|
inner_fixtures = [
|
||||||
|
nova_fixtures.OutputStreamCapture,
|
||||||
|
nova_fixtures.StandardLogging,
|
||||||
|
]
|
||||||
return driver.build_tests(test_dir, loader, host=None,
|
return driver.build_tests(test_dir, loader, host=None,
|
||||||
test_loader_name=__name__,
|
test_loader_name=__name__,
|
||||||
intercept=fixtures.setup_app,
|
intercept=fixtures.setup_app,
|
||||||
|
inner_fixtures=inner_fixtures,
|
||||||
fixture_module=fixtures)
|
fixture_module=fixtures)
|
||||||
|
@ -24,7 +24,7 @@ testtools>=1.4.0 # MIT
|
|||||||
tempest-lib>=0.14.0 # Apache-2.0
|
tempest-lib>=0.14.0 # Apache-2.0
|
||||||
bandit>=1.1.0 # Apache-2.0
|
bandit>=1.1.0 # Apache-2.0
|
||||||
openstackdocstheme>=1.5.0 # Apache-2.0
|
openstackdocstheme>=1.5.0 # Apache-2.0
|
||||||
gabbi>=1.25.0 # Apache-2.0
|
gabbi>=1.26.1 # Apache-2.0
|
||||||
|
|
||||||
# vmwareapi driver specific dependencies
|
# vmwareapi driver specific dependencies
|
||||||
oslo.vmware>=2.11.0 # Apache-2.0
|
oslo.vmware>=2.11.0 # Apache-2.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user