Skip to content

Commit

Permalink
Set and reset Locale to pass test for non-english contributor. (#2622)
Browse files Browse the repository at this point in the history
Fixes #2621

Co-authored-by: Paul Dingemans <paul-dingemans@users.noreply.github.com>
  • Loading branch information
Jaehwa-Noh and paul-dingemans committed Apr 6, 2024
1 parent 9ed0746 commit 3e67a28
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import io.github.oshai.kotlinlogging.KotlinLogging
import nl.altindag.log.LogCaptor
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatExceptionOfType
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
Expand All @@ -20,6 +22,7 @@ import org.junit.jupiter.params.provider.EnumSource
import org.xml.sax.SAXParseException
import java.nio.file.Path
import java.nio.file.Paths
import java.util.Locale
import kotlin.io.path.Path
import kotlin.io.path.copyTo
import kotlin.io.path.pathString
Expand All @@ -43,6 +46,17 @@ private fun KLogger.underlyingLogger(): Logger? =
?.underlyingLogger

class BaselineTest {
private val currentLocale = Locale.getDefault()

@BeforeEach
fun setLocaleEnglish() {
// SAXParseException messages are localized. Prevent tests from failing when run on a system for which local is not set to English.
Locale.setDefault(Locale.ENGLISH)
}

@AfterEach
fun resetLocaleDefault() = Locale.setDefault(currentLocale)

@Nested
inner class `Given a valid baseline file` {
@Test
Expand Down

0 comments on commit 3e67a28

Please sign in to comment.