I'd like to be able to access unexported functions in the testing code 
for a package with a namespace.  I know that one way to do this is to 
use the ":::" operator, but I'd prefer to avoid cluttering up my testing 
code with lots of repetitions of "myPackageName:::".

One way I found to do this was to attach() the namespace of the package, 
e.g., using the following:

pkg <- "myPackageName"
library(package=pkg, character.only=TRUE)
## --- Load the name space to allow testing of private functions ---
if (is.element(pkg, loadedNamespaces()))
     attach(loadNamespace(pkg), name=paste("namespace", pkg, sep=":"), 
pos=3)


Are there any pitfalls that I will find if I continue with this 
approach?  Or is there another better way?

-- Tony Plate

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to