Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_journal_name():
shrt = pybtex.database.Entry(
"article", fields={"journal": "SIAM J. Matrix Anal. Appl."}
)
lng = pybtex.database.Entry(
"article",
fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
)
tmp = betterbib.journal_abbrev({"key": lng})
assert tmp["key"].fields["journal"] == shrt.fields["journal"]
lng = pybtex.database.Entry(
"article",
fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
)
tmp = betterbib.journal_abbrev({"key": shrt}, long_journal_names=True)
assert tmp["key"].fields["journal"] == lng.fields["journal"]
def test_custom_abbrev():
infile = tempfile.NamedTemporaryFile().name
super_short = '{"PNAS": "' + PNAS_ABBREV + '"}'
with open(infile, "w") as f:
f.write(super_short)
entries = make_fake_entry("PNAS")
abbreviated = betterbib.journal_abbrev(entries, custom_abbrev=infile)
assert abbreviated["foo"].fields["journal"] == PNAS_ABBREV
super_short = '{"' + FULL_PNAS + '": "PNAS"}'
with open(infile, "w") as f:
f.write(super_short)
entries = make_fake_entry(FULL_PNAS)
abbreviated = betterbib.journal_abbrev(entries, custom_abbrev=infile)
assert abbreviated["foo"].fields["journal"] == "PNAS"
def test_standard_abbrev_long():
journals = [FULL_PNAS]
abbrevs = [PNAS_ABBREV]
for journal, abbrev in zip(journals, abbrevs):
entries = make_fake_entry(abbrev)
abbreviated = betterbib.journal_abbrev(entries, long_journal_names=True)
assert abbreviated["foo"].fields["journal"] == journal
shrt = pybtex.database.Entry(
"article", fields={"journal": "SIAM J. Matrix Anal. Appl."}
)
lng = pybtex.database.Entry(
"article",
fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
)
tmp = betterbib.journal_abbrev({"key": lng})
assert tmp["key"].fields["journal"] == shrt.fields["journal"]
lng = pybtex.database.Entry(
"article",
fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
)
tmp = betterbib.journal_abbrev({"key": shrt}, long_journal_names=True)
assert tmp["key"].fields["journal"] == lng.fields["journal"]
def test_custom_abbrev_long():
infile = tempfile.NamedTemporaryFile().name
super_short = '{"' + FULL_PNAS + ': "PNAS"}'
with open(infile, "w") as f:
f.write(super_short)
entries = make_fake_entry(PNAS_ABBREV)
abbreviated = betterbib.journal_abbrev(entries, long_journal_names=True)
assert abbreviated["foo"].fields["journal"] == FULL_PNAS
def test_standard_abbrev():
journals = [FULL_PNAS]
abbrevs = [PNAS_ABBREV]
for journal, abbrev in zip(journals, abbrevs):
entries = make_fake_entry(journal)
abbreviated = betterbib.journal_abbrev(entries)
assert abbreviated["foo"].fields["journal"] == abbrev