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
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")
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 []
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')
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
def data(database): return pybibs.read_file(database)
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