@contextlib.contextmanager
def open_output_file(self, test_record):
    'Open file based on pattern.'
    record_dict = data.convert_to_base_types(test_record, ignore_keys=('code_info', 'phases', 'log_records'))
    pattern = self.filename_pattern
    if (isinstance(pattern, six.string_types) or callable(pattern)):
        output_file = self.open_file(util.format_string(pattern, record_dict))
        try:
            (yield output_file)
        finally:
            output_file.close()
    elif hasattr(self.filename_pattern, 'write'):
        (yield self.filename_pattern)
    else:
        raise ValueError('filename_pattern must be string, callable, or File-like object')
Open file based on pattern.
@contextlib.contextmanager
def open_output_file(self, test_record):
    
    record_dict = data.convert_to_base_types(test_record, ignore_keys=('code_info', 'phases', 'log_records'))
    pattern = self.filename_pattern
    if (isinstance(pattern, six.string_types) or callable(pattern)):
        output_file = self.open_file(util.format_string(pattern, record_dict))
        try:
            (yield output_file)
        finally:
            output_file.close()
    elif hasattr(self.filename_pattern, 'write'):
        (yield self.filename_pattern)
    else:
        raise ValueError('filename_pattern must be string, callable, or File-like object')