Avoid library() in test files by MichaelChirico · Pull Request #741 · IRkernel/IRkernel · GitHub
Skip to content

Avoid library() in test files#741

Open
MichaelChirico wants to merge 2 commits intoIRkernel:masterfrom
MichaelChirico:patch-1
Open

Avoid library() in test files#741
MichaelChirico wants to merge 2 commits intoIRkernel:masterfrom
MichaelChirico:patch-1

Conversation

@MichaelChirico
Copy link
Copy Markdown
Contributor

This makes tests less hermetic by creating permanent side effects that survive the test file.

Also remove deprecated expect_is() in anticipation of upgrading to {testthat} 3rd edition.

@flying-sheep flying-sheep added this pull request to the merge queue Nov 13, 2023
@flying-sheep
Copy link
Copy Markdown
Member

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 13, 2023
Comment thread tests/testthat/test_utils.r Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could make this test more clear by making it more explicit:

expect_equal(skipped_stack[[1]], quote(f(1)))

Or even:

expect_equal(skipped_stack, list(quote(f(1)), quote(stop(x))))

That illustrates a subtle problem somewhere in the stack because if you print skipped_stack you see:

[[1]]
f(1)

[[2]]
function(x) stop(x)

Because the srcref is out of sync with the actual contents of the element.

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 this pull request may close these issues.

3 participants