Capture visibility problems in a unit test

Issue #205 new
Dav Clark created an issue

See this stack overflow question for an example of code we could use:

E.g., print statements should print once, assignments shouldn't print at all.

Comments (7)

  1. Laurent Gautier

    I am not familiar at all with what is happening in Rmagic but I suspect that the following specificity in R is near the root of the problem: the R interactive terminal does a bit a magic (ah ! pun not intended).

    A quick a example might be the best possible explanation:

    # pass-through function:
    # it just returns the argument it is given... only if there is a left side to the expression in an R console
    f <- function(x) {

    Now if we use it in the R terminal:

    > f(123)
    # nothing happens, or is displayed
    > x <- f(123)
    # the variable x contains the value 123

    In rpy2

    r['f'](123) will return an IntVector of length 1 with the value 123.

    Now how is R doing this ? There is an invisible boolean attribute to objects returned by a function. If set to True, the object will never be displayed by the R console.

  2. Dav Clark reporter

    This is now being handled correctly by the rmagic, using the withVisible() function. The technical thing I need to figure out is how to know what would have been printed if we were using IPython!

  3. Laurent Gautier

    Ah, I saw too late that this was about testing. That's a question for the ipython development crowd...

    Thanks for the lightning fast bugfix. I'll get rpy2-2.4.1 out shortly (this week-end, or earlier)

  4. Dav Clark reporter

    This is not resolved, but to move things forward, I need to reach out to some IPython people. I'll do that now.

  5. Log in to comment