Пример #1
0
def test_writer_zero_entries():
    out = io.StringIO()
    writer = Writer(out)
    writer.close()

    string = out.getvalue()
    assert string == "[]"
Пример #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"}]'
Пример #3
0
def test_writer_many_entries():
    out = io.StringIO()
    writer = Writer(out)
    for name in ['one', 'two', 'three']:
        entry = Entry(name=name)
        writer.write(entry)
    writer.close()

    string = out.getvalue()
    assert string == ('['
                      '{"name":"one"},'
                      '{"name":"two"},'
                      '{"name":"three"}]')