Various test changes, and improvements to project wizard test
This commit is contained in:
+6
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user