def METHOD_NAME(self, content):
    tmp_file = tempfile.NamedTemporaryFile(prefix='ansible-test-', suffix='-known_hosts', delete=False)
    tmp_file.write(to_bytes(content))
    tmp_file.close()
    self.addCleanup(os.unlink, tmp_file.name)
    return tmp_file.name