Add test coverage of GuiManuscript tool

This commit is contained in:
Veronica Berglyd Olsen
2023-07-18 17:52:49 +02:00
parent 1997872f71
commit 9721c25613
3 changed files with 258 additions and 19 deletions
+9 -13
View File
@@ -112,32 +112,28 @@ def cmpFiles(
return not diffFound
def getGuiItem(theName):
"""Returns a QtWidget based on its objectName.
"""
def getGuiItem(name: str):
"""Returns a QtWidget based on its objectName."""
for qWidget in qApp.topLevelWidgets():
if qWidget.objectName() == theName:
if qWidget.objectName() == name:
return qWidget
return None
def readFile(fileName):
"""Returns the content of a file as a string.
"""
def readFile(fileName: str | Path):
"""Returns the content of a file as a string."""
with open(fileName, mode="r", encoding="utf-8") as inFile:
return inFile.read()
def writeFile(fileName, fileData):
"""Write the contents of a string to a file.
"""
def writeFile(fileName: str | Path, fileData: str):
"""Write the contents of a string to a file."""
with open(fileName, mode="w", encoding="utf-8") as outFile:
outFile.write(fileData)
def cleanProject(path):
"""Delete all generated files in a project.
"""
def cleanProject(path: str | Path):
"""Delete all generated files in a project."""
path = Path(path)
cacheDir = path / "cache"
if cacheDir.is_dir():