[Bioc-devel] [BioC] NAMESPACES, export, and unit tests

hpages at fhcrc.org hpages at fhcrc.org
Tue May 2 05:28:41 CEST 2006


Hi Seth,

Quoting Seth Falcon <sfalcon at fhcrc.org>:

> Herve Pages <hpages at fhcrc.org> writes:
> > I'm asking because there seems to be other things that you can't do
> > in the unit tests (like defining S4 classes or dispatching on an S4
> > class defined somewhere in the package, I don't remember exactly).
> > I'm wondering what's the motivation behind these restrictions...
> 
> If you are interested, how about some specifics on what doesn't work.

Yes sorry, I could not remember exactly what I've tried once and that
didn't work for me. Now I found it: you can't use setGeneric() or
setMethod() in a test unit. For example, you can't have this in your
runit-toto.R file:

  setMethod("==", signature(e1="BString", e2="DNAString"),
    function(e1, e2) { ... }
  )

at the top level or nested in one of your test_totoN() functions.
Even if you don't have a NAMESPACE.
Or you'll get something like:

  Executing test function test_totoN  ...
  Error in setMethod("==", signature(e1 = "BString", e2 = "DNAString"),  :
  the environment 'RUnit' is locked; cannot assign methods for function '=='

> I don't think there is any "motivation" behind the observed
> restrictions.  Certainly there are limitations of the current S4
> implementation, but I do not believe anyone has sat down and said,
> "let's make this particular thing not work for people wanting to do
> unit testing".

My comment was more about the motivations on the RUnit side than
on the S4 implementation side. Lets's keep the S4 implementation
discussion for another day ;-)

H.



More information about the Bioc-devel mailing list