Exemplo n.º 1
0
def test_writer_zero_entries():
    out = io.StringIO()
    writer = Writer(out)
    writer.close()

    string = out.getvalue()
    assert string == ""
Exemplo n.º 2
0
def test_writer_one_entry():
    out = io.StringIO()
    writer = Writer(out)
    entry = Entry(name="one")
    writer.write(entry)
    writer.close()

    string = out.getvalue()
    assert string == '- name: one\n'
Exemplo n.º 3
0
def test_writer_many_entries():
    out = io.StringIO()
    writer = Writer(out)
    for name in ['one', 'two', 'three']:
        entry = Entry(name=name, text="hello world")
        writer.write(entry)
    writer.close()

    string = out.getvalue()
    assert string == ('- name: one\n'
                      '  text: hello world\n'
                      '\n'
                      '- name: two\n'
                      '  text: hello world\n'
                      '\n'
                      '- name: three\n'
                      '  text: hello world\n')