Change how spel checking and booleans in general are saved in the XML

This commit is contained in:
Veronica Berglyd Olsen
2022-11-07 22:46:30 +01:00
parent 42f2bf3628
commit 26f7bb4b32
20 changed files with 622 additions and 572 deletions
+60 -7
View File
@@ -32,9 +32,9 @@ from novelwriter.common import (
checkStringNone, checkString, checkInt, checkFloat, checkBool, checkHandle,
checkUuid, isHandle, isTitleTag, isItemClass, isItemType, isItemLayout,
hexToInt, minmax, checkIntTuple, formatInt, formatTimeStamp, formatTime,
simplified, splitVersionNumber, transferCase, fuzzyTime, numberToRoman,
jsonEncode, readTextFile, makeFileNameSafe, ensureFolder, sha256sum,
getGuiItem, NWConfigParser
simplified, yesNo, splitVersionNumber, transferCase, fuzzyTime,
numberToRoman, jsonEncode, readTextFile, makeFileNameSafe, ensureFolder,
sha256sum, getGuiItem, NWConfigParser
)
@@ -105,16 +105,41 @@ def testBaseCommon_CheckBool():
bool, or integer 1 or 0, are returned as bool. Otherwise, the
default is returned.
"""
# Bools
assert checkBool(True, False) is True
assert checkBool(False, True) is False
# Valid Strings
assert checkBool("True", False) is True
assert checkBool("False", True) is False
assert checkBool("Boo", False) is False
assert checkBool("Boo", True) is True
assert checkBool(None, True) is True
assert checkBool(None, False) is False
assert checkBool("true", False) is True
assert checkBool("false", True) is False
assert checkBool("Yes", False) is True
assert checkBool("No", True) is False
assert checkBool("yes", False) is True
assert checkBool("no", True) is False
assert checkBool("On", False) is True
assert checkBool("Off", True) is False
assert checkBool("on", False) is True
assert checkBool("off", True) is False
# Invalid Strings
assert checkBool("Foo", False) is False
assert checkBool("Foo", True) is True
assert checkBool("bar", False) is False
assert checkBool("bar", True) is True
# Valid Integers
assert checkBool(0, True) is False
assert checkBool(1, False) is True
# Inalid Integers
assert checkBool(2, True) is True
assert checkBool(2, False) is False
# Other Types
assert checkBool(None, True) is True
assert checkBool(None, False) is False
assert checkBool(0.0, True) is True
assert checkBool(1.0, False) is False
assert checkBool(2.0, True) is True
@@ -331,6 +356,34 @@ def testBaseCommon_Simplified():
# END Test testBaseCommon_Simplified
@pytest.mark.base
def testBaseCommon_YesNo():
"""Test the yesNo function.
"""
# Bool
assert yesNo(True) == "yes"
assert yesNo(False) == "no"
# None
assert yesNo(None) == "no"
# String
assert yesNo("foo") == "yes"
assert yesNo("") == "no"
# Integer
assert yesNo(0) == "no"
assert yesNo(1) == "yes"
assert yesNo(2) == "yes"
# Float
assert yesNo(0.0) == "no"
assert yesNo(1.0) == "yes"
assert yesNo(2.0) == "yes"
# END Test testBaseCommon_YesNo
@pytest.mark.base
def testBaseCommon_SplitVersionNumber():
"""Test the splitVersionNumber function.