How to use the mailmerge.__main__.read_csv_database function in mailmerge

To help you get started, we’ve selected a few mailmerge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awdeorio / mailmerge / tests / test_helpers.py View on Github external
def test_csv_utf8(tmpdir):
    """CSV with quotes and commas."""
    database_path = Path(tmpdir/"database.csv")
    database_path.write_text(textwrap.dedent(u"""\
        email,message
        Laȝamon ,Laȝamon emoji \xf0\x9f\x98\x80 klâwen
    """))
    row = next(mailmerge.__main__.read_csv_database(database_path))
    assert row["email"] == u"Laȝamon "
    assert row["message"] == u"Laȝamon emoji \xf0\x9f\x98\x80 klâwen"
github awdeorio / mailmerge / tests / test_helpers.py View on Github external
def test_csv_bad(tmpdir):
    """Bad CSV includes includes filename and line number."""
    # CSV with unmatched quote
    database_path = Path(tmpdir/"database.csv")
    database_path.write_text(textwrap.dedent(u"""\
        a,b
        1,"2
    """))

    # The first line of data triggers an error
    with pytest.raises(csv.Error):
        next(mailmerge.__main__.read_csv_database(database_path))