[Biopython-dev] [Bug 2820] Convert test_PDB.py to unittest

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Apr 24 03:12:15 UTC 2009


http://bugzilla.open-bio.org/show_bug.cgi?id=2820





------- Comment #2 from eric.talevich at gmail.com  2009-04-23 23:12 EST -------
(In reply to comment #1)
> You wrote on Bug 2754 comment 14 that "one of the tests broke during the
> merge", was that this one:
> 
>     def test_warnings(self):
> [...]
> 
> I tried but couldn't get this to work (on Python 2.4.3 on Linux), even with
> plenty of warnings.resetwarnings() which seemed cleaner than popping things.
> 

Yep, that's the one.

The behavior of the warnings module and resetwarnings() is pathological, I
think. If a warning is triggered before the warnings.simplefilter('always')
function is called, that specific warning will be silent until the interpreter
is restarted. That's why order is sensitive in that function, and why the three
exceptions aren't three separate functions. The attribute warnings.filters is a
list of filters that warnings are checked against as they're raised, and at
startup the list is not empty. Calling warnings.resetwarnings() just empties
this list, including the default filters and any use of 'ignore' or 'always'.
Maybe the popping was just voodoo and an empty filter list is fine... dunno.

Python 2.6 includes a context manager that makes all these problems
*completely* go away, by catching all of the warnings raised within a context
and optionally storing them as a list of warning objects that can be inspected.
Would you be interested in having a unit test that does a more thorough check
of the warnings system, but only runs on Py2.6? I'm guessing no, but hey, worth
a shot.

Most likely, some warnings just aren't being caught because my version of the
unit test assumed a different variety of warnings coming out of PDB. If that's
the case then it should be an easy fix and you can disregard my whining.


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list