[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 05:59:09 EDT 2009
http://bugzilla.open-bio.org/show_bug.cgi?id=2820
------- Comment #7 from biopython-bugzilla at maubp.freeserve.co.uk 2009-04-24 05:59 EST -------
(In reply to comment #2)
>
> 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 ...
> Calling warnings.resetwarnings() just empties this list, including the
> default filters and any use of 'ignore' or 'always'.
The reduced warning test in CVS was working until I added more unit tests (for
Bug 2759). This changed the test order, and the warnings were no longer being
triggered. I tried a few things like setting warnings.defaultaction="always"
at the top of the file, and adding and warnings. onceregistry={} to the test
method, but I have given up. We need to be able to *completely* reset the
warnings module for this approach to work.
> 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.
That sounds much better :)
> 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.
Yes - other than using the old print-and-compare test, this seems worth doing
in order to actually test the warnings we expect are being issued. It could be
a whole new file, test_PDB_warnings.py which required Python 2.6+, but as its
just one or two tests, maybe just use conditional method(s) within the
test_PDB_unit.py file.
Peter
--
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