Various test changes, and improvements to project wizard test

This commit is contained in:
Veronica K. B. Olsen
2020-09-29 21:10:21 +02:00
parent 9f8dd4abf3
commit 0c9849b906
10 changed files with 319 additions and 375 deletions
+6 -7
View File
@@ -2,18 +2,13 @@
"""novelWriter Test Tools
"""
from os import path, mkdir
from itertools import chain
from PyQt5.QtWidgets import qApp
def ensureDir(theDir):
if not path.isdir(theDir):
mkdir(theDir)
return
def cmpFiles(fileOne, fileTwo, ignoreLines=[]):
"""Compare two files, but optionally ignore lines given by a list.
"""
try:
foOne = open(fileOne, mode="r", encoding="utf8")
except Exception as e:
@@ -54,6 +49,8 @@ def cmpFiles(fileOne, fileTwo, ignoreLines=[]):
return not diffFound
def cmpList(listOne, listTwo):
"""Compare two iterable objects.
"""
flatOne = list(chain.from_iterable([listOne]))
flatTwo = list(chain.from_iterable([listTwo]))
if len(flatOne) != len(flatTwo):
@@ -64,6 +61,8 @@ def cmpList(listOne, listTwo):
return True
def getGuiItem(theName):
"""Returns a QtWidget based on its objectName.
"""
for qWidget in qApp.topLevelWidgets():
if qWidget.objectName() == theName:
return qWidget