Skip to content

Commit

Permalink
Fix missing fstring on error message (#4638)
Browse files Browse the repository at this point in the history
* Fix missing fstring on error message
* Add test for raised exception text in DSSP
  • Loading branch information
marinegor committed Jul 25, 2024
1 parent 780f958 commit 7302719
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/dssp/dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def __init__(
):
raise ValueError(
(
"Residue {calpha.residue} contains wrong number of hydrogens: "
f"Residue {calpha.residue} contains wrong number of hydrogens: "
"exactly 1 hydrogen is expected for non-PRO residues, and "
"zero hydrogens for PRO residues."
)
Expand Down
12 changes: 12 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ def test_trajectory_with_uneven_number_of_atoms_fails(pdb_filename):
u = mda.Universe(pdb_filename)
with pytest.raises(ValueError):
DSSP(u, guess_hydrogens=True).run()


@pytest.mark.parametrize(
"pdb_filename", glob.glob(f"{DSSP_FOLDER}/wrong_hydrogens.pdb.gz")
)
def test_exception_raises_with_atom_index(pdb_filename):
u = mda.Universe(pdb_filename)
with pytest.raises(
ValueError,
match="Residue <Residue SER, 298> contains*",
):
DSSP(u, guess_hydrogens=False).run()
Binary file not shown.

0 comments on commit 7302719

Please sign in to comment.