8000 `describe_it` doesn't find the right environment when `it()` is prefixed with `testthat::` · Issue #2085 · r-lib/testthat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

describe_it doesn't find the right environment when it() is prefixed with testthat:: #2085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
averissimo opened this issue Jun 4, 2025 · 0 comments · May be fixed by #2086
Open

describe_it doesn't find the right environment when it() is prefixed with testthat:: #2085

averissimo opened this issue Jun 4, 2025 · 0 comments · May be fixed by #2086

Comments

@averissimo
Copy link

I believe the it function should pass the parent.frame() explicitly

See reproducible example below of failure

testthat::describe("a test", {
  aa <- 1
  it("should pass", {
    testthat::expect_equal(aa, 1)
  })
})
#> Test passed 🌈


testthat::describe("a test", {
  aa <- 1
  testthat::it("should pass", {
    testthat::expect_equal(aa, 1)
  })
})
#> ── Error: should pass ──────────────────────────────────────────────────────────
#> Error in `eval(code, test_env)`: object 'aa' not found
#> Backtrace:
#>     ▆
#>  1. └─testthat::expect_equal(aa, 1)
#>  2.   └─testthat::quasi_label(enquo(object), label, arg = "object") at testthat/R/expect-equality.R:62:3
#>  3.     └─rlang::eval_bare(expr, quo_get_env(quo)) at testthat/R/quasi-label.R:45:3
#> Error:
#> ! Test failed

library(testthat)
describe("a test", {
  aa <- 1
  testthat::it("should pass", {
    testthat::expect_equal(aa, 1)
  })
})
#> ── Error: should pass ──────────────────────────────────────────────────────────
#> Error in `eval(code, test_env)`: object 'aa' not found
#> Backtrace:
#>     ▆
#>  1. └─testthat::expect_equal(aa, 1)
#>  2.   └─testthat::quasi_label(enquo(object), label, arg = "object") at testthat/R/expect-equality.R:62:3
#>  3.     └─rlang::eval_bare(expr, quo_get_env(quo)) at testthat/R/quasi-label.R:45:3
#> Error:
#> ! Test failed

Created on 2025-06-04 with reprex v2.1.1

@averissimo averissimo changed the title describe_it doesn't find the right environment when prefixed with testthat:: describe_it doesn't find the right environment when it() is prefixed with testthat:: Jun 4, 2025
@averissimo averissimo linked a pull request Jun 4, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0