- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
str("#813D72") ch-6ren">
我正在构建的包中有一个函数,该函数将十六进制代码分配给全局环境以供分析师使用...
optiplum<-function(){
assign(
x="optiplum",
value=rgb(red=129,green=61,blue=114, maxColorValue = 255),
envir=.GlobalEnv)
}
test_that("optiplum - produces the correct hex code",{
optiplum()
expect_true(identical(optiplum,"#813D72"))
})
> str(optiplum)
chr "#813D72"
> str("#813D72")
chr "#813D72"
> identical("#813D72",optiplum)
[1] TRUE
> expect_true(identical(optiplum,"#813D72"))
> test_file("./tests/testthat/test-optiplum.R")
optiplum : .
> test()
Testing optINTERNAL
Loading optINTERNAL
optiplum : 1
1. Failure: optiplum - produces the correct hex code --------------------------------------------------------------------------------------------------------------
identical(optiplum, "#813D72") isn't true
最佳答案
分配给全局环境是一个禁忌,见 R Inferno和 testthat 尽可能隔离测试(请参阅 test_that()
详细信息)。因此,optiplum()
分配给全局环境不会成功,因为 testthat 函数严格禁止这种行为。
@Hadley 正确地指出该函数应该只返回字符串而不是分配它,特别是因为每次使用它只是两个额外的字符。
所以不是
optiplum<-function(){
assign(
x="optiplum",
value=rgb(red=129,green=61,blue=114, maxColorValue = 255),
envir=.GlobalEnv)
}
optiplum <- function() rgb(red=102,green=17,blue=109, maxColorValue = 255)
关于r devtools test() 错误但测试 test_file() 有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21674798/
我在本地环境中调用 test_file 时遇到问题。 local({ newvar <- 1; expect_equal(newvar, 1); }); 工作正常。 local({ newvar
我正在构建的包中有一个函数,该函数将十六进制代码分配给全局环境以供分析师使用... optiplum str(optiplum) chr "#813D72" > str("#813D72") ch
我在 R 中使用了优秀的 testthat 包。我的问题是我在使用 test_file 时在被测试的代码中看不到 message() 函数的任何输出。例如,假设我在名为 test_message.R
我正在尝试为我一直从事的项目执行测试用例。我以前可以成功执行单元测试,但现在出错了。我确信没有任何库的更新或路径的更改。我试图查看源代码并找出它出错的原因,但还没有成功。如有任何帮助,我们将不胜感激。
我正在将文件复制到 nfs 安装目录。当我手动运行以下命令时,文件复制成功 sudo cp TEST_FILE/mnt/ask78b30 但是,当我在 python 脚本中使用相同的命令时,出现以下错
我不清楚 .gemspec 文件中的某些规范在做什么。具体来说, spec.files = `git ls-files -z`.split("\x0") spec.executable
我是一名优秀的程序员,十分优秀!