Code and GUI text cleanup (#926)
* Move int range checkers from options class to common file * Improve error handling and reporting * Make some minor improvements to init and test suite * Fix 'trypewriter' to 'typewriter' typo * Remove menu path description in dialog help text * Improve the help text for entries in the Format menu * Reword a couple of dialog messages
This commit is contained in:
committed by
GitHub
parent
e71121f738
commit
e8bb130245
+7
-7
@@ -43,15 +43,15 @@ class MockGuiMain():
|
||||
def releaseNotes(self):
|
||||
return
|
||||
|
||||
def makeAlert(self, theMessage, theLevel):
|
||||
assert isinstance(theMessage, str) or isinstance(theMessage, list)
|
||||
print("%s: %s" % (str(theLevel), theMessage))
|
||||
self.lastAlert = str(theMessage)
|
||||
def makeAlert(self, message, level=0, exception=None):
|
||||
assert isinstance(message, str) or isinstance(message, list)
|
||||
print("%s: %s" % (str(level), message))
|
||||
self.lastAlert = str(message)
|
||||
return
|
||||
|
||||
def askQuestion(self, theTitle, theQustion):
|
||||
print("Question: %s" % theQustion)
|
||||
self.lastQuestion = (theTitle, theQustion)
|
||||
def askQuestion(self, title, qustion):
|
||||
print("Question: %s" % qustion)
|
||||
self.lastQuestion = (title, qustion)
|
||||
return self.askResponse
|
||||
|
||||
def setStatus(self, theMessage):
|
||||
|
||||
@@ -32,10 +32,10 @@ from tools import writeFile
|
||||
from novelwriter.guimain import GuiMain
|
||||
from novelwriter.common import (
|
||||
checkString, checkInt, checkFloat, checkBool, checkHandle, isHandle,
|
||||
isTitleTag, isItemClass, isItemType, isItemLayout, hexToInt, formatInt,
|
||||
formatTimeStamp, formatTime, parseTimeStamp, splitVersionNumber,
|
||||
transferCase, fuzzyTime, numberToRoman, jsonEncode, readTextFile,
|
||||
makeFileNameSafe, sha256sum, getGuiItem, NWConfigParser
|
||||
isTitleTag, isItemClass, isItemType, isItemLayout, hexToInt, checkIntRange,
|
||||
checkIntTuple, formatInt, formatTimeStamp, formatTime, parseTimeStamp,
|
||||
splitVersionNumber, transferCase, fuzzyTime, numberToRoman, jsonEncode,
|
||||
readTextFile, makeFileNameSafe, sha256sum, getGuiItem, NWConfigParser
|
||||
)
|
||||
|
||||
|
||||
@@ -216,6 +216,28 @@ def testBaseCommon_HexToInt():
|
||||
# END Test testBaseCommon_HexToInt
|
||||
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseCommon_CheckIntRange():
|
||||
"""Test the checkIntRange function.
|
||||
"""
|
||||
assert checkIntRange(5, 0, 9, 3) == 5
|
||||
assert checkIntRange(5, 0, 4, 3) == 3
|
||||
assert checkIntRange(5, 0, 5, 3) == 5
|
||||
assert checkIntRange(0, 0, 5, 3) == 0
|
||||
|
||||
# END Test testBaseCommon_CheckIntRange
|
||||
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseCommon_CheckIntTuple():
|
||||
"""Test the checkIntTuple function.
|
||||
"""
|
||||
assert checkIntTuple(0, (0, 1, 2), 3) == 0
|
||||
assert checkIntTuple(5, (0, 1, 2), 3) == 3
|
||||
|
||||
# END Test testBaseCommon_CheckIntTuple
|
||||
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseCommon_FormatTimeStamp():
|
||||
"""Test the formatTimeStamp function.
|
||||
|
||||
@@ -140,13 +140,4 @@ def testCoreOptions_SetGet(mockGUI):
|
||||
assert theOpts.getBool("GuiBuildNovel", "addNovel", None) is True
|
||||
assert theOpts.getBool("GuiBuildNovel", "mockItem", None) is None
|
||||
|
||||
# Check integer validators
|
||||
assert theOpts.validIntRange(5, 0, 9, 3) == 5
|
||||
assert theOpts.validIntRange(5, 0, 4, 3) == 3
|
||||
assert theOpts.validIntRange(5, 0, 5, 3) == 5
|
||||
assert theOpts.validIntRange(0, 0, 5, 3) == 0
|
||||
|
||||
assert theOpts.validIntTuple(0, (0, 1, 2), 3) == 0
|
||||
assert theOpts.validIntTuple(5, (0, 1, 2), 3) == 3
|
||||
|
||||
# END Test testCoreOptions_SetGet
|
||||
|
||||
@@ -40,17 +40,15 @@ stepDelay = 20
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@pytest.mark.skipif(sys.platform.startswith("darwin"), reason="Not running on Darwin")
|
||||
def testToolProjectWizard_Main(qtbot, monkeypatch, nwGUI, nwMinimal):
|
||||
"""Test the new project wizard.
|
||||
Disabled for macOS because the test segfaults on QWizard.show()
|
||||
"""
|
||||
# Block message box
|
||||
monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
|
||||
monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes)
|
||||
|
||||
if sys.platform.startswith("darwin"):
|
||||
# Disable for macOS because the test segfaults on QWizard.show()
|
||||
return
|
||||
|
||||
##
|
||||
# Test New Project Function
|
||||
##
|
||||
|
||||
+4
-4
@@ -33,14 +33,14 @@ def cmpFiles(fileOne, fileTwo, ignoreLines=None, ignoreStart=None):
|
||||
|
||||
try:
|
||||
foOne = open(fileOne, mode="r", encoding="utf-8")
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
except Exception as exc:
|
||||
print(str(exc))
|
||||
return False
|
||||
|
||||
try:
|
||||
foTwo = open(fileTwo, mode="r", encoding="utf-8")
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
except Exception as exc:
|
||||
print(str(exc))
|
||||
return False
|
||||
|
||||
txtOne = foOne.readlines()
|
||||
|
||||
Reference in New Issue
Block a user