[Gradle, Test] Reset locale to default when changing it for tests
Since `Locale.setDefault` is a global operation it will take effect on other test causing them to produce unexpectable results. ^KT-38712
This commit is contained in:
committed by
Space Team
parent
f09fb5ed09
commit
a37b548b9f
+11
-1
@@ -382,8 +382,17 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun `gradle entities should have correct names when default locale is turkish`() {
|
fun `gradle entities should have correct names when default locale is turkish`() {
|
||||||
Locale.setDefault(Locale("tr", "TR"))
|
fun withLocale(locale: Locale, code: () -> Unit) {
|
||||||
|
val currentLocal = Locale.getDefault()
|
||||||
|
try {
|
||||||
|
Locale.setDefault(locale)
|
||||||
|
code()
|
||||||
|
} finally {
|
||||||
|
Locale.setDefault(currentLocal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
withLocale(Locale("tr", "TR")) {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm()
|
jvm()
|
||||||
@@ -411,3 +420,4 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user