Skip to content

Commit

Permalink
Ensure JunitReporter alway uses . for decimal (#1885)
Browse files Browse the repository at this point in the history
Fixes #1660
  • Loading branch information
maksymiuks authored Oct 19, 2023
1 parent c0845db commit 5550c98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# testthat (development version)

* `JunitReporter()` now uses ensures numeric values are saved the xml file
with `.` as decimal separator. (@maksymiuks, #1660)

# testthat 3.2.0

## Lifecycle changes
Expand Down
3 changes: 3 additions & 0 deletions R/reporter-junit.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ JunitReporter <- R6::R6Class("JunitReporter",
},

end_context = function(context) {
# Always uses . as decimal place in output regardless of options set in test
withr::local_options(list(OutDec = "."))
xml2::xml_attr(self$suite, "tests") <- as.character(self$tests)
xml2::xml_attr(self$suite, "skipped") <- as.character(self$skipped)
xml2::xml_attr(self$suite, "failures") <- as.character(self$failures)
Expand All @@ -96,6 +98,7 @@ JunitReporter <- R6::R6Class("JunitReporter",
},

add_result = function(context, test, result) {
withr::local_options(list(OutDec = "."))
self$tests <- self$tests + 1

time <- self$elapsed_time()
Expand Down

0 comments on commit 5550c98

Please sign in to comment.