Skip to content

Commit

Permalink
Error if build_tests has no host or intercept
Browse files Browse the repository at this point in the history
Fixes #23 by doing an assert at the start of the method.

Note that this doesn't have a test but see #11.
  • Loading branch information
cdent committed Mar 10, 2015
1 parent 753ab77 commit f900ba1
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions gabbi/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def build_tests(path, loader, host=None, port=8001, intercept=None,
Each YAML file represents an ordered sequence of HTTP requests.
"""

assert bool(host) ^ bool(intercept), \
'must specify exactly one of host or intercept'

top_suite = suite.TestSuite()

if test_loader_name is None:
Expand All @@ -67,18 +71,17 @@ def build_tests(path, loader, host=None, port=8001, intercept=None,

# Return an empty suite if we have no host to access, either via
# a real host or an intercept
if host or intercept:
for test_file in glob.iglob(yaml_file_glob):
if intercept:
host = str(uuid.uuid4())
test_yaml = load_yaml(test_file)
test_name = '%s_%s' % (test_loader_name,
os.path.splitext(
os.path.basename(test_file))[0])
file_suite = test_suite_from_yaml(loader, test_name, test_yaml,
path, host, port, fixture_module,
intercept)
top_suite.addTest(file_suite)
for test_file in glob.iglob(yaml_file_glob):
if intercept:
host = str(uuid.uuid4())
test_yaml = load_yaml(test_file)
test_name = '%s_%s' % (test_loader_name,
os.path.splitext(
os.path.basename(test_file))[0])
file_suite = test_suite_from_yaml(loader, test_name, test_yaml,
path, host, port, fixture_module,
intercept)
top_suite.addTest(file_suite)
return top_suite


Expand Down

0 comments on commit f900ba1

Please sign in to comment.