[Biopython-dev] [Bug 2759] Unit test for Bio.PDB.HSExposure

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Thu Feb 12 14:13:45 UTC 2009


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





------- Comment #4 from biopython-bugzilla at maubp.freeserve.co.uk  2009-02-12 09:13 EST -------
(In reply to comment #2)
> 
> Can I suggest you a small refactoring of the test unit?
> I would move all the asserts in setUp to different functions.

Maybe.  They were really to check the file had loaded as I expected, so that
the later tests are checking the residues I expect them to.

> Then, it would be good to put also the call to PDB.PDBStructure to a global
> fixture, to avoid to repeat it for every test.

NO!  That would be a very bad idea here.  The HSExposure calls MODIFY the model
passed to them, so for a clean test we NEED a fresh model each time.  I suppose
we could read the structure in once, and then make a copy for each sub-test,
but I think it is clearer as it is.

In general, having "global fixtures" is risky.  The individual test methods may
have side effects (like the changes to the residues in the model in this case),
meaning that the overall behaviour will depend on the order the individual test
methods are called in.

One of the big benefits of using the unittest framework is that each test
method is run in a clean known environment (compare this to our
print-and-compare scripts, where this isn't the case).  Using "global fixtures"
shares objects between the individual tests and breaks this.

The only good reason I can think of for having a global-setUp method (called
once only) rather the current setUp method (called for each test method) is if
the set up code is very slow.

> Moreover, I will generalize all the know values and put them as variables,
> so later you will be able to apply the same test to other files by just
> subclassing the test.

You would also have to extract the individual exposure scores.  It would be
simple to get these (and the residue names) as lists, and then check every
single residue matches the expected values (rather than the short cut I used to
just check the first few and the last few).  We could also check any other
chains in the structure (not just chain A).  These changes are probably a good
idea if we ever wanted to extend this unittest to try other PDB files as well,
but seemed unnecessary for testing the basics of the Bio.PDB.HSExposure module.


-- 
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