Separated out writing stats test and updated it

This commit is contained in:
Veronica K. B. Olsen
2020-12-12 14:44:33 +01:00
parent 22cb1669e1
commit 70eadd11cb
5 changed files with 298 additions and 196 deletions
+42 -8
View File
@@ -13,6 +13,8 @@ from PyQt5.QtWidgets import QMessageBox
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
import nw # noqa: E402
from nw.config import Config # noqa: E402
##
@@ -55,16 +57,28 @@ def outDir(tmpDir):
def fncDir(tmpDir):
"""A temporary folder for a single test function.
"""
funcDir = os.path.join(tmpDir, "ftemp")
if os.path.isdir(funcDir):
shutil.rmtree(funcDir)
if not os.path.isdir(funcDir):
os.mkdir(funcDir)
yield funcDir
if os.path.isdir(funcDir):
shutil.rmtree(funcDir)
fncDir = os.path.join(tmpDir, "f_temp")
if os.path.isdir(fncDir):
shutil.rmtree(fncDir)
if not os.path.isdir(fncDir):
os.mkdir(fncDir)
yield fncDir
if os.path.isdir(fncDir):
shutil.rmtree(fncDir)
return
@pytest.fixture(scope="function")
def fncProj(fncDir):
"""A temporary folder for a single test function,
with a project folder.
"""
prjDir = os.path.join(fncDir, "project")
if os.path.isdir(prjDir):
shutil.rmtree(prjDir)
if not os.path.isdir(prjDir):
os.mkdir(prjDir)
return prjDir
##
# novelWriter Objects
##
@@ -89,6 +103,26 @@ def dummyGUI(tmpConf):
theDummy.mainConf = tmpConf
return theDummy
@pytest.fixture(scope="function")
def nwGUI(qtbot, fncDir):
"""Create an instance of the novelWriter GUI.
"""
nwGUI = nw.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % fncDir])
qtbot.addWidget(nwGUI)
nwGUI.show()
qtbot.waitForWindowShown(nwGUI)
qtbot.wait(20)
nwGUI.mainConf.lastPath = fncDir
yield nwGUI
qtbot.wait(20)
nwGUI.closeMain()
qtbot.wait(20)
return
##
# Temp Project Folders
##