[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 May 1 18:16:57 UTC 2009
http://bugzilla.open-bio.org/show_bug.cgi?id=2820
------- Comment #8 from eric.talevich at gmail.com 2009-05-01 14:16 EST -------
(In reply to comment #7)
> (In reply to comment #2)
> > 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
>
I have something that works on both Py2.5 and Py2.6 now:
http://github.com/etal/biopython/tree/pdbtidy
I added a new file called _PDB_extra.py which test_PDB_unit.py imports if an
attribute called 'catch_warnings' is available in the current warnings module.
If so, the method test_warnings is added to the class, otherwise nothing
happens. So Py2.6 runs 9 tests in test_PDB_unit.py, while Py2.5 only runs 8.
This seemed easier than creating a whole separate unittest suite for one tricky
test, but I defer to you on the organization and naming. I think I'll need to
do a similar separation of tests for PhyloXML, so I'd like to have a consistent
pattern to follow here.
Also, apparently tests are run in alphabetical order, and Exposure was jumping
ahead of PDBExceptionTest. I renamed PDBExceptionTest to ExceptionTest to
restore the natural order of things and stop setting off the warnings
prematurely. Maybe test suites with multiple TestCase classes should be
arranged alphabetically in the code to avoid confusion in the future.
--
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