Skip to content

Commit ab7c931

Browse files
Use setattr to avoid shallow copy in autoprint test setup (#7102)
* try setattr * Update autoprint.Rout.save
1 parent 5bb6450 commit ab7c931

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tests/autoprint.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ local({
5858

5959
# child class of data.table doesn't induce unintended print, #3029
6060
dt = data.table(x = 1)
61-
class(dt) = c("foo", "data.table", "data.frame")
61+
setattr(dt, "class", c("foo", "data.table", "data.frame"))
6262
print.foo = function(x, ...) {
6363
NextMethod("print")
6464
}

tests/autoprint.Rout.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ NULL
172172
>
173173
> # child class of data.table doesn't induce unintended print, #3029
174174
> dt = data.table(x = 1)
175-
> class(dt) = c("foo", "data.table", "data.frame")
175+
> setattr(dt, "class", c("foo", "data.table", "data.frame"))
176176
> print.foo = function(x, ...) {
177177
+ NextMethod("print")
178178
+ }

0 commit comments

Comments
 (0)