Remove nwFuncTemp fixture
This commit is contained in:
@@ -198,17 +198,3 @@ def nwTempBuild(tmpDir):
|
|||||||
if not os.path.isdir(buildDir):
|
if not os.path.isdir(buildDir):
|
||||||
os.mkdir(buildDir)
|
os.mkdir(buildDir)
|
||||||
return buildDir
|
return buildDir
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
|
||||||
def nwFuncTemp(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)
|
|
||||||
return
|
|
||||||
|
|||||||
+20
-20
@@ -30,7 +30,7 @@ typeDelay = 1
|
|||||||
stepDelay = 20
|
stepDelay = 20
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
def testProjectSettings(qtbot, monkeypatch, yesToAll, fncDir, nwTempGUI, refDir, tmpDir):
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
@@ -43,8 +43,8 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, ref
|
|||||||
|
|
||||||
# Create new project
|
# Create new project
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
assert nwGUI.newProject({"projPath": nwFuncTemp})
|
assert nwGUI.newProject({"projPath": fncDir})
|
||||||
nwGUI.mainConf.backupPath = nwFuncTemp
|
nwGUI.mainConf.backupPath = fncDir
|
||||||
|
|
||||||
# Get the dialog object
|
# Get the dialog object
|
||||||
monkeypatch.setattr(GuiProjectSettings, "exec_", lambda *args: None)
|
monkeypatch.setattr(GuiProjectSettings, "exec_", lambda *args: None)
|
||||||
@@ -135,7 +135,7 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, ref
|
|||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
# Check the files
|
# Check the files
|
||||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
projFile = os.path.join(fncDir, "nwProject.nwx")
|
||||||
testFile = os.path.join(nwTempGUI, "2_nwProject.nwx")
|
testFile = os.path.join(nwTempGUI, "2_nwProject.nwx")
|
||||||
refFile = os.path.join(refDir, "gui", "2_nwProject.nwx")
|
refFile = os.path.join(refDir, "gui", "2_nwProject.nwx")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
@@ -145,7 +145,7 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, ref
|
|||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
def testItemEditor(qtbot, yesToAll, monkeypatch, fncDir, nwTempGUI, refDir, tmpDir):
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
@@ -154,7 +154,7 @@ def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, nwTempGUI, refDir,
|
|||||||
|
|
||||||
# Create new, save, open project
|
# Create new, save, open project
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
assert nwGUI.newProject({"projPath": nwFuncTemp})
|
assert nwGUI.newProject({"projPath": fncDir})
|
||||||
assert nwGUI.openDocument("0e17daca5f3e1")
|
assert nwGUI.openDocument("0e17daca5f3e1")
|
||||||
assert nwGUI.treeView.setSelectedHandle("0e17daca5f3e1", doScroll=True)
|
assert nwGUI.treeView.setSelectedHandle("0e17daca5f3e1", doScroll=True)
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, nwTempGUI, refDir,
|
|||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
# Check the files
|
# Check the files
|
||||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
projFile = os.path.join(fncDir, "nwProject.nwx")
|
||||||
testFile = os.path.join(nwTempGUI, "3_nwProject.nwx")
|
testFile = os.path.join(nwTempGUI, "3_nwProject.nwx")
|
||||||
refFile = os.path.join(refDir, "gui", "3_nwProject.nwx")
|
refFile = os.path.join(refDir, "gui", "3_nwProject.nwx")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
@@ -218,7 +218,7 @@ def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, nwTempGUI, refDir,
|
|||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
def testWritingStatsExport(qtbot, monkeypatch, yesToAll, fncDir, tmpDir):
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
@@ -227,13 +227,13 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
|
|
||||||
# Create new, save, close project
|
# Create new, save, close project
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
assert nwGUI.newProject({"projPath": nwFuncTemp})
|
assert nwGUI.newProject({"projPath": fncDir})
|
||||||
qtbot.wait(200)
|
qtbot.wait(200)
|
||||||
assert nwGUI.saveProject()
|
assert nwGUI.saveProject()
|
||||||
assert nwGUI.closeProject()
|
assert nwGUI.closeProject()
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
sessFile = os.path.join(nwFuncTemp, "meta", nwFiles.SESS_STATS)
|
sessFile = os.path.join(fncDir, "meta", nwFiles.SESS_STATS)
|
||||||
with open(sessFile, mode="w+", encoding="utf-8") as outFile:
|
with open(sessFile, mode="w+", encoding="utf-8") as outFile:
|
||||||
outFile.write(
|
outFile.write(
|
||||||
"# Start Time End Time Novel Notes\n"
|
"# Start Time End Time Novel Notes\n"
|
||||||
@@ -244,10 +244,10 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Open again, and check the stats
|
# Open again, and check the stats
|
||||||
assert nwGUI.openProject(nwFuncTemp)
|
assert nwGUI.openProject(fncDir)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
nwGUI.mainConf.lastPath = nwFuncTemp
|
nwGUI.mainConf.lastPath = fncDir
|
||||||
nwGUI.mainMenu.aWritingStats.activate(QAction.Trigger)
|
nwGUI.mainMenu.aWritingStats.activate(QAction.Trigger)
|
||||||
qtbot.waitUntil(lambda: getGuiItem("GuiWritingStats") is not None, timeout=1000)
|
qtbot.waitUntil(lambda: getGuiItem("GuiWritingStats") is not None, timeout=1000)
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||||
qtbot.wait(100)
|
qtbot.wait(100)
|
||||||
|
|
||||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
jsonStats = os.path.join(fncDir, "sessionStats.json")
|
||||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||||
jsonData = json.load(inFile)
|
jsonData = json.load(inFile)
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
jsonStats = os.path.join(fncDir, "sessionStats.json")
|
||||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||||
jsonData = json.loads(inFile.read())
|
jsonData = json.loads(inFile.read())
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
jsonStats = os.path.join(fncDir, "sessionStats.json")
|
||||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||||
jsonData = json.load(inFile)
|
jsonData = json.load(inFile)
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
jsonStats = os.path.join(fncDir, "sessionStats.json")
|
||||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||||
jsonData = json.load(inFile)
|
jsonData = json.load(inFile)
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
jsonStats = os.path.join(fncDir, "sessionStats.json")
|
||||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||||
jsonData = json.load(inFile)
|
jsonData = json.load(inFile)
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
jsonStats = os.path.join(fncDir, "sessionStats.json")
|
||||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||||
jsonData = json.load(inFile)
|
jsonData = json.load(inFile)
|
||||||
|
|
||||||
@@ -357,8 +357,8 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, tmpDir):
|
|||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testAboutBox(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
def testAboutBox(qtbot, monkeypatch, fncDir, tmpDir):
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir])
|
nwGUI = nw.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % tmpDir])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
qtbot.waitForWindowShown(nwGUI)
|
qtbot.waitForWindowShown(nwGUI)
|
||||||
|
|||||||
+2
-2
@@ -10,9 +10,9 @@ from PyQt5.QtWidgets import qApp
|
|||||||
from nw.error import NWErrorMessage, exceptionHandler
|
from nw.error import NWErrorMessage, exceptionHandler
|
||||||
|
|
||||||
@pytest.mark.error
|
@pytest.mark.error
|
||||||
def testErrorDialog(qtbot, nwFuncTemp, tmpDir):
|
def testErrorDialog(qtbot, fncDir, tmpDir):
|
||||||
qApp.closeAllWindows()
|
qApp.closeAllWindows()
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir])
|
nwGUI = nw.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % tmpDir])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
qtbot.waitForWindowShown(nwGUI)
|
qtbot.waitForWindowShown(nwGUI)
|
||||||
|
|||||||
+23
-23
@@ -27,11 +27,11 @@ typeDelay = 1
|
|||||||
stepDelay = 20
|
stepDelay = 20
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testLaunch(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
def testLaunch(qtbot, monkeypatch, fncDir, tmpDir):
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir, "--style=Fusion"]
|
["--testmode", "--config=%s" % fncDir, "--data=%s" % tmpDir, "--style=Fusion"]
|
||||||
)
|
)
|
||||||
assert nw.logger.getEffectiveLevel() == logging.WARNING
|
assert nw.logger.getEffectiveLevel() == logging.WARNING
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
@@ -39,21 +39,21 @@ def testLaunch(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
|
|
||||||
# Log Levels
|
# Log Levels
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--info", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir]
|
["--testmode", "--info", "--config=%s" % fncDir, "--data=%s" % tmpDir]
|
||||||
)
|
)
|
||||||
assert nw.logger.getEffectiveLevel() == logging.INFO
|
assert nw.logger.getEffectiveLevel() == logging.INFO
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
nwGUI.close()
|
nwGUI.close()
|
||||||
|
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--debug", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir]
|
["--testmode", "--debug", "--config=%s" % fncDir, "--data=%s" % tmpDir]
|
||||||
)
|
)
|
||||||
assert nw.logger.getEffectiveLevel() == logging.DEBUG
|
assert nw.logger.getEffectiveLevel() == logging.DEBUG
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
nwGUI.close()
|
nwGUI.close()
|
||||||
|
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--verbose", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir]
|
["--testmode", "--verbose", "--config=%s" % fncDir, "--data=%s" % tmpDir]
|
||||||
)
|
)
|
||||||
assert nw.logger.getEffectiveLevel() == 5
|
assert nw.logger.getEffectiveLevel() == 5
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
@@ -62,7 +62,7 @@ def testLaunch(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
# Help and Version
|
# Help and Version
|
||||||
with pytest.raises(SystemExit) as ex:
|
with pytest.raises(SystemExit) as ex:
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--help", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir]
|
["--testmode", "--help", "--config=%s" % fncDir, "--data=%s" % tmpDir]
|
||||||
)
|
)
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
nwGUI.close()
|
nwGUI.close()
|
||||||
@@ -70,7 +70,7 @@ def testLaunch(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
|
|
||||||
with pytest.raises(SystemExit) as ex:
|
with pytest.raises(SystemExit) as ex:
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--version", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir]
|
["--testmode", "--version", "--config=%s" % fncDir, "--data=%s" % tmpDir]
|
||||||
)
|
)
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
nwGUI.close()
|
nwGUI.close()
|
||||||
@@ -79,7 +79,7 @@ def testLaunch(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
# Invalid options
|
# Invalid options
|
||||||
with pytest.raises(SystemExit) as ex:
|
with pytest.raises(SystemExit) as ex:
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--invalid", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir]
|
["--testmode", "--invalid", "--config=%s" % fncDir, "--data=%s" % tmpDir]
|
||||||
)
|
)
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
nwGUI.close()
|
nwGUI.close()
|
||||||
@@ -92,7 +92,7 @@ def testLaunch(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
monkeypatch.setattr("nw.CONFIG.verPyQtValue", 50000)
|
monkeypatch.setattr("nw.CONFIG.verPyQtValue", 50000)
|
||||||
with pytest.raises(SystemExit) as ex:
|
with pytest.raises(SystemExit) as ex:
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--config=%s" % nwFuncTemp, "--data=%s" % tmpDir]
|
["--testmode", "--config=%s" % fncDir, "--data=%s" % tmpDir]
|
||||||
)
|
)
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
nwGUI.close()
|
nwGUI.close()
|
||||||
@@ -103,7 +103,7 @@ def testLaunch(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
def testDocEditor(qtbot, yesToAll, fncDir, nwTempGUI, refDir, tmpDir):
|
||||||
|
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
@@ -113,7 +113,7 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
|||||||
|
|
||||||
# Create new, save, close project
|
# Create new, save, close project
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
assert nwGUI.newProject({"projPath": nwFuncTemp})
|
assert nwGUI.newProject({"projPath": fncDir})
|
||||||
assert nwGUI.saveProject()
|
assert nwGUI.saveProject()
|
||||||
assert nwGUI.closeProject()
|
assert nwGUI.closeProject()
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
|||||||
assert not nwGUI.theProject.spellCheck
|
assert not nwGUI.theProject.spellCheck
|
||||||
|
|
||||||
# Check the files
|
# Check the files
|
||||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
projFile = os.path.join(fncDir, "nwProject.nwx")
|
||||||
testFile = os.path.join(nwTempGUI, "0_nwProject.nwx")
|
testFile = os.path.join(nwTempGUI, "0_nwProject.nwx")
|
||||||
refFile = os.path.join(refDir, "gui", "0_nwProject.nwx")
|
refFile = os.path.join(refDir, "gui", "0_nwProject.nwx")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
@@ -140,7 +140,7 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
|||||||
# qtbot.stopForInteraction()
|
# qtbot.stopForInteraction()
|
||||||
|
|
||||||
# Re-open project
|
# Re-open project
|
||||||
assert nwGUI.openProject(nwFuncTemp)
|
assert nwGUI.openProject(fncDir)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
# Check that we loaded the data
|
# Check that we loaded the data
|
||||||
@@ -148,8 +148,8 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
|||||||
assert len(nwGUI.theProject.projTree._treeOrder) == 8
|
assert len(nwGUI.theProject.projTree._treeOrder) == 8
|
||||||
assert len(nwGUI.theProject.projTree._treeRoots) == 4
|
assert len(nwGUI.theProject.projTree._treeRoots) == 4
|
||||||
assert nwGUI.theProject.projTree.trashRoot() is None
|
assert nwGUI.theProject.projTree.trashRoot() is None
|
||||||
assert nwGUI.theProject.projPath == nwFuncTemp
|
assert nwGUI.theProject.projPath == fncDir
|
||||||
assert nwGUI.theProject.projMeta == os.path.join(nwFuncTemp, "meta")
|
assert nwGUI.theProject.projMeta == os.path.join(fncDir, "meta")
|
||||||
assert nwGUI.theProject.projFile == "nwProject.nwx"
|
assert nwGUI.theProject.projFile == "nwProject.nwx"
|
||||||
assert nwGUI.theProject.projName == "New Project"
|
assert nwGUI.theProject.projName == "New Project"
|
||||||
assert nwGUI.theProject.bookTitle == ""
|
assert nwGUI.theProject.bookTitle == ""
|
||||||
@@ -379,31 +379,31 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, refDir, tmpDir):
|
|||||||
assert nwGUI.saveProject()
|
assert nwGUI.saveProject()
|
||||||
|
|
||||||
# Check the files
|
# Check the files
|
||||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
projFile = os.path.join(fncDir, "nwProject.nwx")
|
||||||
testFile = os.path.join(nwTempGUI, "1_nwProject.nwx")
|
testFile = os.path.join(nwTempGUI, "1_nwProject.nwx")
|
||||||
refFile = os.path.join(refDir, "gui", "1_nwProject.nwx")
|
refFile = os.path.join(refDir, "gui", "1_nwProject.nwx")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
||||||
|
|
||||||
projFile = os.path.join(nwFuncTemp, "content", "031b4af5197ec.nwd")
|
projFile = os.path.join(fncDir, "content", "031b4af5197ec.nwd")
|
||||||
testFile = os.path.join(nwTempGUI, "1_031b4af5197ec.nwd")
|
testFile = os.path.join(nwTempGUI, "1_031b4af5197ec.nwd")
|
||||||
refFile = os.path.join(refDir, "gui", "1_031b4af5197ec.nwd")
|
refFile = os.path.join(refDir, "gui", "1_031b4af5197ec.nwd")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, refFile)
|
assert cmpFiles(testFile, refFile)
|
||||||
|
|
||||||
projFile = os.path.join(nwFuncTemp, "content", "1a6562590ef19.nwd")
|
projFile = os.path.join(fncDir, "content", "1a6562590ef19.nwd")
|
||||||
testFile = os.path.join(nwTempGUI, "1_1a6562590ef19.nwd")
|
testFile = os.path.join(nwTempGUI, "1_1a6562590ef19.nwd")
|
||||||
refFile = os.path.join(refDir, "gui", "1_1a6562590ef19.nwd")
|
refFile = os.path.join(refDir, "gui", "1_1a6562590ef19.nwd")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, refFile)
|
assert cmpFiles(testFile, refFile)
|
||||||
|
|
||||||
projFile = os.path.join(nwFuncTemp, "content", "0e17daca5f3e1.nwd")
|
projFile = os.path.join(fncDir, "content", "0e17daca5f3e1.nwd")
|
||||||
testFile = os.path.join(nwTempGUI, "1_0e17daca5f3e1.nwd")
|
testFile = os.path.join(nwTempGUI, "1_0e17daca5f3e1.nwd")
|
||||||
refFile = os.path.join(refDir, "gui", "1_0e17daca5f3e1.nwd")
|
refFile = os.path.join(refDir, "gui", "1_0e17daca5f3e1.nwd")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, refFile)
|
assert cmpFiles(testFile, refFile)
|
||||||
|
|
||||||
projFile = os.path.join(nwFuncTemp, "content", "41cfc0d1f2d12.nwd")
|
projFile = os.path.join(fncDir, "content", "41cfc0d1f2d12.nwd")
|
||||||
testFile = os.path.join(nwTempGUI, "1_41cfc0d1f2d12.nwd")
|
testFile = os.path.join(nwTempGUI, "1_41cfc0d1f2d12.nwd")
|
||||||
refFile = os.path.join(refDir, "gui", "1_41cfc0d1f2d12.nwd")
|
refFile = os.path.join(refDir, "gui", "1_41cfc0d1f2d12.nwd")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
@@ -1013,7 +1013,7 @@ def testContextMenu(qtbot, yesToAll, nwLipsum, tmpDir):
|
|||||||
nwGUI.close()
|
nwGUI.close()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testInsertMenu(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
def testInsertMenu(qtbot, monkeypatch, fncDir, tmpDir):
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
nwGUI = nw.main(["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
@@ -1021,7 +1021,7 @@ def testInsertMenu(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
assert nwGUI.newProject({"projPath": nwFuncTemp})
|
assert nwGUI.newProject({"projPath": fncDir})
|
||||||
|
|
||||||
assert nwGUI.treeView._getTreeItem("0e17daca5f3e1") is not None
|
assert nwGUI.treeView._getTreeItem("0e17daca5f3e1") is not None
|
||||||
|
|
||||||
@@ -1205,7 +1205,7 @@ def testInsertMenu(qtbot, monkeypatch, nwFuncTemp, tmpDir):
|
|||||||
assert len(theBits) == 3
|
assert len(theBits) == 3
|
||||||
assert theBits[0] == "File details for the currently open file"
|
assert theBits[0] == "File details for the currently open file"
|
||||||
assert theBits[1] == "Handle: 0e17daca5f3e1"
|
assert theBits[1] == "Handle: 0e17daca5f3e1"
|
||||||
assert theBits[2] == "Location: %s" % os.path.join(nwFuncTemp, "content", "0e17daca5f3e1.nwd")
|
assert theBits[2] == "Location: %s" % os.path.join(fncDir, "content", "0e17daca5f3e1.nwd")
|
||||||
|
|
||||||
# qtbot.stopForInteraction()
|
# qtbot.stopForInteraction()
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
|
|||||||
Reference in New Issue
Block a user