diff --git a/R-package/tests/testthat/test_basic.R b/R-package/tests/testthat/test_basic.R index 3cbf7f991884..2f2f9efc32d3 100644 --- a/R-package/tests/testthat/test_basic.R +++ b/R-package/tests/testthat/test_basic.R @@ -245,11 +245,12 @@ test_that("training continuation works", { expect_equal(bst$raw, bst2$raw) expect_equal(dim(bst2$evaluation_log), c(2, 2)) # test continuing from a model in file - xgb.save(bst1, "xgboost.model") - bst2 <- xgb.train(param, dtrain, nrounds = 2, watchlist, verbose = 0, xgb_model = "xgboost.model") + xgb.save(bst1, "xgboost.json") + bst2 <- xgb.train(param, dtrain, nrounds = 2, watchlist, verbose = 0, xgb_model = "xgboost.json") if (!windows_flag && !solaris_flag) expect_equal(bst$raw, bst2$raw) expect_equal(dim(bst2$evaluation_log), c(2, 2)) + file.remove("xgboost.json") }) test_that("model serialization works", { diff --git a/R-package/tests/testthat/test_callbacks.R b/R-package/tests/testthat/test_callbacks.R index 9016c1bcbdfa..fd42f519af60 100644 --- a/R-package/tests/testthat/test_callbacks.R +++ b/R-package/tests/testthat/test_callbacks.R @@ -173,16 +173,16 @@ test_that("cb.reset.parameters works as expected", { }) test_that("cb.save.model works as expected", { - files <- c('xgboost_01.model', 'xgboost_02.model', 'xgboost.model') + files <- c('xgboost_01.json', 'xgboost_02.json', 'xgboost.json') for (f in files) if (file.exists(f)) file.remove(f) bst <- xgb.train(param, dtrain, nrounds = 2, watchlist, eta = 1, verbose = 0, - save_period = 1, save_name = "xgboost_%02d.model") - expect_true(file.exists('xgboost_01.model')) - expect_true(file.exists('xgboost_02.model')) - b1 <- xgb.load('xgboost_01.model') + save_period = 1, save_name = "xgboost_%02d.json") + expect_true(file.exists('xgboost_01.json')) + expect_true(file.exists('xgboost_02.json')) + b1 <- xgb.load('xgboost_01.json') expect_equal(xgb.ntree(b1), 1) - b2 <- xgb.load('xgboost_02.model') + b2 <- xgb.load('xgboost_02.json') expect_equal(xgb.ntree(b2), 2) xgb.config(b2) <- xgb.config(bst) @@ -191,9 +191,9 @@ test_that("cb.save.model works as expected", { # save_period = 0 saves the last iteration's model bst <- xgb.train(param, dtrain, nrounds = 2, watchlist, eta = 1, verbose = 0, - save_period = 0) - expect_true(file.exists('xgboost.model')) - b2 <- xgb.load('xgboost.model') + save_period = 0, save_name = 'xgboost.json') + expect_true(file.exists('xgboost.json')) + b2 <- xgb.load('xgboost.json') xgb.config(b2) <- xgb.config(bst) expect_equal(bst$raw, b2$raw)