Ejemplo n.º 1
0
def test_save_log_entry(log_entry):
    with mock.patch('tombstones.log.open', mock.mock_open()) as mock_open:
        save_log_entry(log_entry)
        assert mock_open.called
        mock_open.assert_has_calls([
            mock.call().write('\n')
        ])
Ejemplo n.º 2
0
def tombstone(wrapped, instance, args, kwargs):
    """Tombstone decorator to save log entry."""
    save_log_entry(LogEntry(
        name=wrapped.__name__,
        source_file=os.path.abspath(
            inspect.getsourcefile(wrapped)
        ),
        line_number=line_number_for_tombstone(
            *inspect.getsourcelines(wrapped)
        ),
        datetime=str(datetime.datetime.now()),
    ))
    return wrapped(*args, **kwargs)