Skip to content

Commit

Permalink
Add a test for results and include
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv committed Apr 24, 2024
1 parent 5384c91 commit 5e01a47
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MyClass:
def _repr_html_(self):
return "<p>uh-oh</p>"

MyClass()
16 changes: 16 additions & 0 deletions tests/testthat/resources/knitr-results-hide.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "Hide and include"
output: md_document
---

```{python, results = 'hide'}
class MyClass:
def _repr_html_(self):
return "<p>uh-oh</p>"
MyClass()
```

```{python, include = FALSE}
1 + 1
```
17 changes: 17 additions & 0 deletions tests/testthat/test-python-knitr-engine.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ test_that("knitr 'warning=FALSE' option", {

})

test_that("knitr results='hide' and include = FALSE options", {

skip_on_cran()
skip_if_not_installed("rmarkdown")

local_edition(3) # needed for expect_snapshot_file()

owd <- setwd(test_path("resources"))
rmarkdown::render("knitr-results-hide.Rmd", quiet = TRUE)
setwd(owd)

rendered <- test_path("resources", "knitr-results-hide.md")

expect_snapshot_file(rendered)

})

test_that("Output streams are remaped when kniting", {

skip_on_cran()
Expand Down

0 comments on commit 5e01a47

Please sign in to comment.