Update gabbi driver to reflect new test handling
(The files didn't make it in the previous commit)
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
test_command=${PYTHON:-python} -m subunit.run discover gabbi $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
group_regex=([^_]+)
|
||||
group_regex=gabbi\.driver\.(test_[^_]+_[^_]+)
|
||||
|
@@ -28,6 +28,7 @@ An entire directory of YAML files is a TestSuite of TestSuites.
|
||||
"""
|
||||
|
||||
import glob
|
||||
import inspect
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -280,7 +281,8 @@ class TestBuilder(type):
|
||||
return type.__new__(mcs, name, bases, attributes)
|
||||
|
||||
|
||||
def build_tests(path, loader, host=None, port=8001, intercept=None):
|
||||
def build_tests(path, loader, host=None, port=8001, intercept=None,
|
||||
test_file_name=None):
|
||||
"""Read YAML files from a directory to create tests.
|
||||
|
||||
Each YAML file represents an ordered sequence of HTTP requests.
|
||||
@@ -288,6 +290,11 @@ def build_tests(path, loader, host=None, port=8001, intercept=None):
|
||||
top_suite = suite.TestSuite()
|
||||
http = httplib2.Http()
|
||||
|
||||
if test_file_name is None:
|
||||
test_file_name = inspect.stack()[1]
|
||||
test_file_name = os.path.splitext(os.path.basename(
|
||||
test_file_name[1]))[0]
|
||||
|
||||
# Return an empty suite if we have no host to access, either via
|
||||
# a real host or an intercept
|
||||
if not host and not intercept:
|
||||
@@ -315,7 +322,8 @@ def build_tests(path, loader, host=None, port=8001, intercept=None):
|
||||
for test_datum in test_data:
|
||||
test = dict(base_test_data)
|
||||
test.update(test_datum)
|
||||
test_name = '%s_%s' % (test_base_name,
|
||||
test_name = '%s_%s_%s' % (test_file_name,
|
||||
test_base_name,
|
||||
test['name'].lower().replace(' ', '_'))
|
||||
if set(test.keys()) != key_test:
|
||||
raise ValueError('Invalid Keys in test %s' % test_name)
|
||||
|
@@ -29,7 +29,7 @@ from six.moves.urllib import parse as urlparse
|
||||
from gabbi import driver
|
||||
|
||||
|
||||
TESTS_DIR = 'gabbits'
|
||||
TESTS_DIR = 'gabbits_intercept'
|
||||
METHODS = ['GET', 'PUT', 'POST', 'DELETE', 'PATCH']
|
||||
|
||||
|
||||
|
@@ -21,11 +21,8 @@ For the sake of exploratory development.
|
||||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from gabbi import driver
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user