From 5d53b4a93c03e344421f70f736e2fb869b61bd7b Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Tue, 15 Feb 2022 23:27:22 -0800 Subject: [PATCH] Ensure Plain BPMF tests run with Standard layout This exposes an issue that our Preferences is a global singleton that uses the user defaults store and is therefore not hermetic. --- McBopomofoTests/KeyHandlerPlainBopomofoTests.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/McBopomofoTests/KeyHandlerPlainBopomofoTests.swift b/McBopomofoTests/KeyHandlerPlainBopomofoTests.swift index 4e99ebbd..feeb0e0c 100644 --- a/McBopomofoTests/KeyHandlerPlainBopomofoTests.swift +++ b/McBopomofoTests/KeyHandlerPlainBopomofoTests.swift @@ -25,15 +25,22 @@ import XCTest @testable import McBopomofo class KeyHandlerPlainBopomofoTests: XCTestCase { + var savedKeyboardLayout: Int = 0 var handler = KeyHandler() override func setUpWithError() throws { LanguageModelManager.loadDataModels() handler = KeyHandler() handler.inputMode = .plainBopomofo + + savedKeyboardLayout = Preferences.keyboardLayout + + // Punctuation-related tests only work when the layout is Standard. + Preferences.keyboardLayout = KeyboardLayout.standard.rawValue } override func tearDownWithError() throws { + Preferences.keyboardLayout = savedKeyboardLayout } func testPunctuationTable() {