Skip to content

Commit 2afb528

Browse files
Add test for fallback when a custom formatting style is given
pelican-pybtex falls back to the plain formatting style if it can't find the custom format. It gives out two error messages in that case. Check for them.
1 parent 0610403 commit 2afb528

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026 Johannes Röttenbacher <jr-alias@posteo.de>
2+
# SPDX-License-Identifier: MIT
3+
4+
PATH = "content"
5+
PYBTEX_SOURCES = ["publications.bib"]
6+
PYBTEX_FORMAT_STYLE = "custom_bibtex_style.NotAvailable"

tests/data/custom-style/content/publications.bib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@article{wendisch_2023,
88
title = {Atmospheric and {{Surface Processes}}, and {{Feedback Mechanisms Determining Arctic Amplification}}: {{A Review}} of {{First Results}} and {{Prospects}} of the ({{AC}})3 {{Project}}},
99
shorttitle = {Atmospheric and {{Surface Processes}}, and {{Feedback Mechanisms Determining Arctic Amplification}}},
10-
author = {Wendisch, M. and Br{\"u}ckner, M. and Crewell, S. and Ehrlich, A. and Notholt, J. and L{\"u}pkes, C. and Macke, A. and Burrows, J. P. and Rinke, A. and Quaas, J. and Maturilli, M. and Schemann, V. and Shupe, M. D. and Akansu, E. F. and {Barrientos-Velasco}, C. and B{\"a}rfuss, K. and Blechschmidt, A.-M. and Block, K. and Bougoudis, I. and Bozem, H. and B{\"o}ckmann, C. and Bracher, A. and Bresson, H. and Bretschneider, L. and Buschmann, M. and Chechin, D. G. and Chylik, J. and Dahlke, S. and Deneke, H. and Dethloff, K. and Donth, T. and Dorn, W. and Dupuy, R. and Ebell, K. and Egerer, U. and Engelmann, R. and Eppers, O. and Gerdes, R. and Gierens, R. and Gorodetskaya, I. V. and Gottschalk, M. and Griesche, H. and Gryanik, V. M. and Handorf, D. and {Harm-Altst{\"a}dter}, B. and Hartmann, J. and Hartmann, M. and Heinold, B. and Herber, A. and Herrmann, H. and Heygster, G. and H{\"o}schel, I. and Hofmann, Z. and H{\"o}lemann, J. and H{\"u}nerbein, A. and Jafariserajehlou, S. and J{\"a}kel, E. and Jacobi, C. and Janout, M. and Jansen, F. and Jourdan, O. and Jur{\'a}nyi, Z. and {Kalesse-Los}, H. and Kanzow, T. and K{\"a}thner, R. and Kliesch, L. L. and Klingebiel, M. and Knudsen, E. M. and Kov{\'a}cs, T. and K{\"o}rtke, W. and Krampe, D. and Kretzschmar, J. and Kreyling, D. and Kulla, B. and Kunkel, D. and Lampert, A. and Lauer, M. and Lelli, L. and Von Lerber, A. and Linke, O. and L{\"o}hnert, U. and Lonardi, M. and Losa, S. N. and Losch, M. and Maahn, M. and Mech, M. and Mei, L. and Mertes, S. and Metzner, E. and Mewes, D. and Michaelis, J. and Mioche, G. and Moser, M. and Nakoudi, K. and Neggers, R. and Neuber, R. and Nomokonova, T. and Oelker, J. and {Papakonstantinou-Presvelou}, I. and P{\"a}tzold, F. and Pefanis, V. and Pohl, C. and Van Pinxteren, M. and Radovan, A. and Rhein, M. and Rex, M. and Richter, A. and Risse, N. and Ritter, C. and Rostosky, P. and Rozanov, V. V. and Donoso, E. Ruiz and Saavedra Garfias, P. and Salzmann, M. and Schacht, J. and Sch{\"a}fer, M. and Schneider, J. and Schnierstein, N. and Seifert, P. and Seo, S. and Siebert, H. and Soppa, M. A. and Spreen, G. and Stachlewska, I. S. and Stapf, J. and Stratmann, F. and Tegen, I. and Viceto, C. and Voigt, C. and Vountas, M. and Walbr{\"o}l, A. and Walter, M. and Wehner, B. and Wex, H. and Willmes, S. and Zanatta, M. and Zeppenfeld, S.},
10+
author = {Wendisch, M. and Br{\"u}ckner, M. and Crewell, S. and Ehrlich, A. and Notholt, J.},
1111
year = 2023,
1212
month = jan,
1313
journal = {Bull. Am. Meteorol. Soc.},
@@ -22,7 +22,7 @@ @article{wendisch_2023
2222
@article{wendisch_2019,
2323
title = {The {{Arctic Cloud Puzzle}}: {{Using ACLOUD}}/{{PASCAL Multiplatform Observations}} to {{Unravel}} the {{Role}} of {{Clouds}} and {{Aerosol Particles}} in {{Arctic Amplification}}},
2424
shorttitle = {The {{Arctic Cloud Puzzle}}},
25-
author = {Wendisch, Manfred and Macke, Andreas and Ehrlich, Andr{\'e} and L{\"u}pkes, Christof and Mech, Mario and Chechin, Dmitry and Dethloff, Klaus and Velasco, Carola Barrientos and Bozem, Heiko and Br{\"u}ckner, Marlen and Clemen, Hans-Christian and Crewell, Susanne and Donth, Tobias and Dupuy, Regis and Ebell, Kerstin and Egerer, Ulrike and Engelmann, Ronny and Engler, Christa and Eppers, Oliver and Gehrmann, Martin and Gong, Xianda and Gottschalk, Matthias and Gourbeyre, Christophe and Griesche, Hannes and Hartmann, J{\"o}rg and Hartmann, Markus and Heinold, Bernd and Herber, Andreas and Herrmann, Hartmut and Heygster, Georg and Hoor, Peter and Jafariserajehlou, Soheila and J{\"a}kel, Evelyn and J{\"a}rvinen, Emma and Jourdan, Olivier and K{\"a}stner, Udo and Kecorius, Simonas and Knudsen, Erlend M. and K{\"o}llner, Franziska and Kretzschmar, Jan and Lelli, Luca and Leroy, Delphine and Maturilli, Marion and Mei, Linlu and Mertes, Stephan and Mioche, Guillaume and Neuber, Roland and Nicolaus, Marcel and Nomokonova, Tatiana and Notholt, Justus and Palm, Mathias and Van Pinxteren, Manuela and Quaas, Johannes and Richter, Philipp and {Ruiz-Donoso}, Elena and Sch{\"a}fer, Michael and Schmieder, Katja and Schnaiter, Martin and Schneider, Johannes and Schwarzenb{\"o}ck, Alfons and Seifert, Patric and Shupe, Matthew D. and Siebert, Holger and Spreen, Gunnar and Stapf, Johannes and Stratmann, Frank and Vogl, Teresa and Welti, Andr{\'e} and Wex, Heike and Wiedensohler, Alfred and Zanatta, Marco and Zeppenfeld, Sebastian},
25+
author = {Wendisch, Manfred and Macke, Andreas and Ehrlich, Andr{\'e} and L{\"u}pkes, Christof},
2626
year = 2019,
2727
month = may,
2828
journal = {Bull. Am. Meteorol. Soc.},

tests/test_pybtex.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,36 @@ def test_biblio_override(setup_pelican: tuple[list[logging.LogRecord], pathlib.P
721721
)
722722

723723

724+
@pytest.mark.parametrize("subdir", ["custom-style-fallback"])
725+
def test_custom_style_fallback(
726+
setup_pelican: tuple[list[logging.LogRecord], pathlib.Path],
727+
):
728+
records, pelican_output = setup_pelican
729+
730+
# check that the bibliography still gets build
731+
publications_html = pelican_output / "publications.html"
732+
assert publications_html.exists()
733+
734+
with publications_html.open() as f:
735+
soup = BeautifulSoup(f, "html.parser")
736+
737+
div = soup.find_all("div", id="pybtex")
738+
assert len(div) == 1
739+
740+
_assert_log_contains(
741+
records,
742+
message="Failed to import custom style 'custom_bibtex_style.NotAvailable'",
743+
level=logging.ERROR,
744+
count=1,
745+
)
746+
_assert_log_contains(
747+
records,
748+
message="Unsupported formatting style 'custom_bibtex_style.NotAvailable', defaulting to 'plain'",
749+
level=logging.ERROR,
750+
count=1,
751+
)
752+
753+
724754
@pytest.mark.parametrize("subdir", ["custom-style"])
725755
def test_custom_style(setup_pelican: tuple[list[logging.LogRecord], pathlib.Path]):
726756
records, pelican_output = setup_pelican

0 commit comments

Comments
 (0)