Run integration tests from temporary directory.

ci_complete
This commit is contained in:
Matt Clay 2019-01-10 14:43:21 -08:00
parent 18c35b69fb
commit b834b29e43
7 changed files with 327 additions and 43 deletions

View file

@ -754,6 +754,8 @@ class CommonConfig(object):
if is_shippable():
self.redact = True
self.cache = {}
def docker_qualify_image(name):
"""
@ -765,6 +767,29 @@ def docker_qualify_image(name):
return config.get('name', name)
@contextlib.contextmanager
def named_temporary_file(args, prefix, suffix, directory, content):
"""
:param args: CommonConfig
:param prefix: str
:param suffix: str
:param directory: str
:param content: str | bytes | unicode
:rtype: str
"""
if not isinstance(content, bytes):
content = content.encode('utf-8')
if args.explain:
yield os.path.join(directory, '%stemp%s' % (prefix, suffix))
else:
with tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix, dir=directory) as tempfile_fd:
tempfile_fd.write(content)
tempfile_fd.flush()
yield tempfile_fd.name
def parse_to_list_of_dict(pattern, value):
"""
:type pattern: str