iNZightVIT / iNZightTools

Functions for integration of iNZight GUI to iNZight packages.
https://inzightvit.github.io/iNZightTools/
1 stars 4 forks source link

Make tests independent of locales #158

Closed markvanderloo closed 3 years ago

markvanderloo commented 3 years ago

Hi there,

I was running reverse dependency checks for the validate package, and found two errors. It turned out to have nothing to do with validate introducing new errors, but the fact that my pc is partly in a non-english locale. In particular:

  ══ testthat results  ═══════════════════════════════════════════════════════════
  FAILURE (test_Extfromdt.R:70:3): Factor levels have correct order
  FAILURE (test_Extfromdt.R:74:3): Factor levels have correct order

This is because you extract weekdays, which you presume to be in English.

weekdays <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
  "Saturday", "Sunday")
#<snip>
  expect_equal(
    levels(extract_part(data, "a", "Day of the week (name)", "dow")$dow),
    weekdays
  )

You can make the tests locale-independent, for example by generating the weekdays as follows:

lubridate::wday(as.Date("2020-12-07") + 0:6, label=TRUE, abbr=FALSE)

It would make tests more robust, also in case you start using other packages.

In any case, thank you for your trust in validate.

Kind regards, Mark

tmelliott commented 3 years ago

Thanks @markvanderloo for taking the time to give a solution! Should be fixed in the next release.