[Biopython-dev] Python 2.4 / Adding QUIET argument to PDBParser()

Eric Talevich eric.talevich at gmail.com
Fri May 6 16:20:54 UTC 2011


On Fri, May 6, 2011 at 5:31 AM, Peter Cock <p.j.a.cock at googlemail.com>wrote:

> On Fri, May 6, 2011 at 10:25 AM, Peter Cock <p.j.a.cock at googlemail.com>
> wrote:
> >
> > The second approach requires a temporary warnings filter,
> > which I think would easily done with the context manager
> > warnings.catch_warnings() in Python 2.5+
>
> Arhh, Jaoa just pointed out warnings.catch_warnings() is
> in Python 2.6+ so we have to wait a while longer before
> we can use that :(
>
>
Fortunately we've already worked around it in test_PDB.py, by
monkeypatching:
https://github.com/biopython/biopython/blob/master/Tests/test_PDB.py

See the method test_1_warnings. Replace the function warnings.showwarnings
with a new function that just collects warning objects in a list rather than
printing them. Then, before the outer function ends, swap back the original
showwarnings function.

-E



More information about the Biopython-dev mailing list