Skip to content

Commit

Permalink
actually check that the warning was raised instead of surpressing it
Browse files Browse the repository at this point in the history
  • Loading branch information
BioGeek committed Feb 14, 2017
1 parent 1c1f8b3 commit 47d8d8f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Tests/test_SeqIO_PdbIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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')
Expand All @@ -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__":
Expand Down

0 comments on commit 47d8d8f

Please sign in to comment.