Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set and reset Locale to pass test for non-english contributor. #2622

Merged
merged 7 commits into from
Apr 6, 2024
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