mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Run integration tests from temporary directory.
ci_complete
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user