Exemple #1
0
def test_read_then_write_produces_the_same_result():
    filepath = os.path.join('tests', 'data', 'huge.bib')
    bib1 = pybibs.read_file(filepath)
    out1 = pybibs.write_string(bib1)
    bib2 = pybibs.read_string(out1)
    out2 = pybibs.write_string(bib2)
    assert out1 == out2
Exemple #2
0
def test_read_file(database):
    bib = pybibs.read_file(database)
    for entry in bib:
        if entry.get("key") == "bailenson2005digital":
            break
    else:
        raise AssertionError(
            "Couldn't find bailenson2005digital in parsed data")
Exemple #3
0
def load_database(database):
    """
    Load the database from .bib. Create (in memory) if doesn't exist.
    """
    try:
        return pybibs.read_file(database)
    except IOError:
        return []
Exemple #4
0
def test_read_file():
    filepath = os.path.join('tests', 'data', 'huge.bib')
    bib = pybibs.read_file(filepath)
    for entry in bib:
        if entry['key'] == 'bailenson2005digital':
            break
    else:
        raise AssertionError(
            'Couldn\'t find bailenson2005digital in parsed data')
Exemple #5
0
def test_read_then_write_produces_the_same_result(database):
    bib1 = pybibs.read_file(database)
    out1 = pybibs.write_string(bib1)
    bib2 = pybibs.read_string(out1)
    out2 = pybibs.write_string(bib2)
    assert out1 == out2
Exemple #6
0
def data(database):
    return pybibs.read_file(database)
Exemple #7
0
def test_list_with_no_arguments_to_get_everything(runner, database):
    args = ["--database", database, "list"]
    result = runner.invoke(bibo.cli, args)
    for entry in pybibs.read_file(database):
        if entry["type"] not in ["string", "comment", "preamble"]:
            assert entry["key"] in result.output