From 47d8d8fdd7163a075a1fad4ba9c09ac993fb8500 Mon Sep 17 00:00:00 2001 From: Jeroen Van Goey Date: Tue, 14 Feb 2017 15:56:31 +0100 Subject: [PATCH] actually check that the warning was raised instead of surpressing it --- Tests/test_SeqIO_PdbIO.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Tests/test_SeqIO_PdbIO.py b/Tests/test_SeqIO_PdbIO.py index 7b67348f20a..bcab2fc2939 100644 --- a/Tests/test_SeqIO_PdbIO.py +++ b/Tests/test_SeqIO_PdbIO.py @@ -18,6 +18,7 @@ "Install NumPy if you want to use PDB formats with SeqIO.") from Bio import SeqIO +from Bio import BiopythonWarning from Bio.PDB.PDBExceptions import PDBConstructionWarning @@ -95,6 +96,7 @@ def test_atom_read(self): 'KALGPGATLEEMMTACQG') with warnings.catch_warnings(): warnings.simplefilter("ignore", PDBConstructionWarning) + warnings.simplefilter("ignore", BiopythonWarning) chain = SeqIO.read('PDB/a_structure.pdb', 'pdb-atom') self.assertEqual(chain.id, '????:A') self.assertEqual(chain.annotations['chain'], 'A') @@ -103,13 +105,13 @@ def test_atom_read(self): def test_atom_noheader(self): """Parse a PDB with no HEADER line.""" - with warnings.catch_warnings(): - warnings.simplefilter('ignore', PDBConstructionWarning) - warnings.simplefilter('ignore', UserWarning) - chains = list(SeqIO.parse('PDB/1LCD.pdb', 'pdb-atom')) + with warnings.catch_warnings(record=True) as warning_list: + warnings.simplefilter('always') + # Trigger the warning. + chains = list(SeqIO.parse('PDB/a_structure.pdb', 'pdb-atom')) - self.assertEqual(len(chains), 1) - self.assertEqual(str(chains[0].seq), 'MKPVTLYDVAEYAGVSYQTVSRVVNQASHVSAKTREKVEAAMAELNYIPNR') + # Verify that the warning was raised + self.assertEqual(warning_list[0].category, BiopythonWarning) if __name__ == "__main__":