test fixups

This commit is contained in:
meejah
2018-03-27 16:11:40 -06:00
parent 47b1787633
commit affb80e39e
6 changed files with 144 additions and 57 deletions

View File

@ -199,10 +199,24 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
return d
def await_file_contents(path, contents, timeout=15):
def await_file_contents(path, contents, timeout=15, error_if=None):
"""
wait up to `timeout` seconds for the file at `path` to have the
exact content `contents.
:param error_if: if specified, a list of additional paths; if any
of these paths appear an Exception is raised.
"""
start_time = time.time()
while time.time() - start_time < timeout:
print(" waiting for '{}'".format(path))
if error_if and any([exists(p) for p in error_if]):
raise Exception(
"While waiting for '{}', unwanted files appeared: {}".format(
path,
', '.join([p for p in error_if if exists(p)]),
)
)
if exists(path):
try:
with open(path, 'r') as f: