Rename nwRef to refDir

This commit is contained in:
Veronica K. B. Olsen
2020-12-01 10:50:41 +01:00
parent deededb0d9
commit afea7b66bd
6 changed files with 69 additions and 73 deletions
+11 -15
View File
@@ -33,6 +33,15 @@ def tmpDir():
os.mkdir(tempDir) os.mkdir(tempDir)
return tempDir return tempDir
@pytest.fixture(scope="session")
def refDir():
"""The folder where all the reference files are stored for verifying
the results of tests.
"""
testDir = os.path.dirname(__file__)
refDir = os.path.join(testDir, "reference")
return refDir
## ##
# novelWriter Objects # novelWriter Objects
## ##
@@ -56,30 +65,17 @@ def dummyGUI(tmpConf):
# =============================================================================================== # # =============================================================================================== #
##
# Core Test Folders
##
@pytest.fixture(scope="session")
def nwRef():
"""The folder where all the reference files are stored for verifying
the results of tests.
"""
testDir = os.path.dirname(__file__)
refDir = os.path.join(testDir, "reference")
return refDir
## ##
# novelWriter Objects # novelWriter Objects
## ##
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def nwConf(nwRef, tmpDir): def nwConf(refDir, tmpDir):
"""Temporary novelWriter configuration used for the dummy instance """Temporary novelWriter configuration used for the dummy instance
of novelWriter's main GUI. of novelWriter's main GUI.
""" """
theConf = Config() theConf = Config()
theConf.initConfig(nwRef, tmpDir) theConf.initConfig(refDir, tmpDir)
return theConf return theConf
## ##
+11 -11
View File
@@ -8,8 +8,8 @@ import os
from nwtools import cmpFiles from nwtools import cmpFiles
@pytest.mark.core @pytest.mark.core
def testConfigCore(tmpConf, tmpDir, nwRef): def testConfigCore(tmpConf, tmpDir, refDir):
refConf = os.path.join(nwRef, "novelwriter.conf") refConf = os.path.join(refDir, "novelwriter.conf")
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf") testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
assert tmpConf.confPath == tmpDir assert tmpConf.confPath == tmpDir
@@ -38,8 +38,8 @@ def testConfigSetDataPath(tmpConf, tmpDir):
assert not tmpConf.confChanged assert not tmpConf.confChanged
@pytest.mark.core @pytest.mark.core
def testConfigSetWinSize(tmpConf, tmpDir, nwRef): def testConfigSetWinSize(tmpConf, tmpDir, refDir):
refConf = os.path.join(nwRef, "novelwriter.conf") refConf = os.path.join(refDir, "novelwriter.conf")
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf") testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
tmpConf.guiScale = 1.0 tmpConf.guiScale = 1.0
@@ -55,8 +55,8 @@ def testConfigSetWinSize(tmpConf, tmpDir, nwRef):
assert not tmpConf.confChanged assert not tmpConf.confChanged
@pytest.mark.core @pytest.mark.core
def testConfigSetTreeColWidths(tmpConf, tmpDir, nwRef): def testConfigSetTreeColWidths(tmpConf, tmpDir, refDir):
refConf = os.path.join(nwRef, "novelwriter.conf") refConf = os.path.join(refDir, "novelwriter.conf")
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf") testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
assert tmpConf.confPath == tmpDir assert tmpConf.confPath == tmpDir
@@ -77,8 +77,8 @@ def testConfigSetTreeColWidths(tmpConf, tmpDir, nwRef):
assert not tmpConf.confChanged assert not tmpConf.confChanged
@pytest.mark.core @pytest.mark.core
def testConfigSetPanePos(tmpConf, tmpDir, nwRef): def testConfigSetPanePos(tmpConf, tmpDir, refDir):
refConf = os.path.join(nwRef, "novelwriter.conf") refConf = os.path.join(refDir, "novelwriter.conf")
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf") testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
assert tmpConf.confPath == tmpDir assert tmpConf.confPath == tmpDir
@@ -113,8 +113,8 @@ def testConfigSetPanePos(tmpConf, tmpDir, nwRef):
assert not tmpConf.confChanged assert not tmpConf.confChanged
@pytest.mark.core @pytest.mark.core
def testConfigFlags(tmpConf, tmpDir, nwRef): def testConfigFlags(tmpConf, tmpDir, refDir):
refConf = os.path.join(nwRef, "novelwriter.conf") refConf = os.path.join(refDir, "novelwriter.conf")
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf") testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
assert tmpConf.confPath == tmpDir assert tmpConf.confPath == tmpDir
@@ -137,7 +137,7 @@ def testConfigFlags(tmpConf, tmpDir, nwRef):
assert not tmpConf.confChanged assert not tmpConf.confChanged
@pytest.mark.core @pytest.mark.core
def testTextSizes(tmpConf, tmpDir, nwRef): def testTextSizes(tmpConf, tmpDir, refDir):
assert tmpConf.confPath == tmpDir assert tmpConf.confPath == tmpDir
tmpConf.guiScale = 2.0 tmpConf.guiScale = 2.0
+2 -2
View File
@@ -15,13 +15,13 @@ from nw.core.index import NWIndex
from nw.constants import nwItemClass, nwItemLayout from nw.constants import nwItemClass, nwItemLayout
@pytest.mark.core @pytest.mark.core
def testCoreIndex_LoadSave(monkeypatch, nwLipsum, dummyGUI, nwTempProj, nwRef): def testCoreIndex_LoadSave(monkeypatch, nwLipsum, dummyGUI, nwTempProj, refDir):
"""Test core functionality of scaning, saving, loading and checking """Test core functionality of scaning, saving, loading and checking
the index cache file. the index cache file.
""" """
projFile = os.path.join(nwLipsum, "meta", "tagsIndex.json") projFile = os.path.join(nwLipsum, "meta", "tagsIndex.json")
testFile = os.path.join(nwTempProj, "coreIndex_LoadSave_tagsIndex.json") testFile = os.path.join(nwTempProj, "coreIndex_LoadSave_tagsIndex.json")
compFile = os.path.join(nwRef, "coreIndex_LoadSave_tagsIndex.json") compFile = os.path.join(refDir, "coreIndex_LoadSave_tagsIndex.json")
theProject = NWProject(dummyGUI) theProject = NWProject(dummyGUI)
theProject.projTree.setSeed(42) theProject.projTree.setSeed(42)
+28 -28
View File
@@ -30,7 +30,7 @@ typeDelay = 1
stepDelay = 20 stepDelay = 20
@pytest.mark.gui @pytest.mark.gui
def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, nwRef, tmpDir): def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, 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()
@@ -137,7 +137,7 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, nwR
# Check the files # Check the files
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempGUI, "2_nwProject.nwx") testFile = os.path.join(nwTempGUI, "2_nwProject.nwx")
refFile = os.path.join(nwRef, "gui", "2_nwProject.nwx") refFile = os.path.join(refDir, "gui", "2_nwProject.nwx")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [2, 8, 9, 10]) assert cmpFiles(testFile, refFile, [2, 8, 9, 10])
@@ -145,7 +145,7 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, nwR
nwGUI.closeMain() nwGUI.closeMain()
@pytest.mark.gui @pytest.mark.gui
def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, nwTempGUI, nwRef, tmpDir): def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, 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()
@@ -210,7 +210,7 @@ def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, nwTempGUI, nwRef, t
# Check the files # Check the files
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempGUI, "3_nwProject.nwx") testFile = os.path.join(nwTempGUI, "3_nwProject.nwx")
refFile = os.path.join(nwRef, "gui", "3_nwProject.nwx") refFile = os.path.join(refDir, "gui", "3_nwProject.nwx")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [2, 6, 7, 8]) assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
@@ -397,7 +397,7 @@ def testAboutBox(qtbot, monkeypatch, nwFuncTemp, tmpDir):
nwGUI.closeMain() nwGUI.closeMain()
@pytest.mark.gui @pytest.mark.gui
def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, tmpDir): def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, refDir, tmpDir):
nwGUI = nw.main(["--testmode", "--config=%s" % nwLipsum, "--data=%s" % tmpDir]) nwGUI = nw.main(["--testmode", "--config=%s" % nwLipsum, "--data=%s" % tmpDir])
qtbot.addWidget(nwGUI) qtbot.addWidget(nwGUI)
@@ -428,13 +428,13 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, tmpDir):
projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd") projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd")
testFile = os.path.join(nwTempBuild, "1_LoremIpsum.nwd") testFile = os.path.join(nwTempBuild, "1_LoremIpsum.nwd")
refFile = os.path.join(nwRef, "build", "1_LoremIpsum.nwd") refFile = os.path.join(refDir, "build", "1_LoremIpsum.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm") projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm")
testFile = os.path.join(nwTempBuild, "1_LoremIpsum.htm") testFile = os.path.join(nwTempBuild, "1_LoremIpsum.htm")
refFile = os.path.join(nwRef, "build", "1_LoremIpsum.htm") refFile = os.path.join(refDir, "build", "1_LoremIpsum.htm")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
@@ -467,13 +467,13 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, tmpDir):
projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd") projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd")
testFile = os.path.join(nwTempBuild, "2_LoremIpsum.nwd") testFile = os.path.join(nwTempBuild, "2_LoremIpsum.nwd")
refFile = os.path.join(nwRef, "build", "2_LoremIpsum.nwd") refFile = os.path.join(refDir, "build", "2_LoremIpsum.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm") projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm")
testFile = os.path.join(nwTempBuild, "2_LoremIpsum.htm") testFile = os.path.join(nwTempBuild, "2_LoremIpsum.htm")
refFile = os.path.join(nwRef, "build", "2_LoremIpsum.htm") refFile = os.path.join(refDir, "build", "2_LoremIpsum.htm")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
@@ -487,14 +487,14 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, tmpDir):
assert nwBuild._saveDocument(nwBuild.FMT_NWD) assert nwBuild._saveDocument(nwBuild.FMT_NWD)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd") projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd")
testFile = os.path.join(nwTempBuild, "3_LoremIpsum.nwd") testFile = os.path.join(nwTempBuild, "3_LoremIpsum.nwd")
refFile = os.path.join(nwRef, "build", "3_LoremIpsum.nwd") refFile = os.path.join(refDir, "build", "3_LoremIpsum.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
assert nwBuild._saveDocument(nwBuild.FMT_HTM) assert nwBuild._saveDocument(nwBuild.FMT_HTM)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm") projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm")
testFile = os.path.join(nwTempBuild, "3_LoremIpsum.htm") testFile = os.path.join(nwTempBuild, "3_LoremIpsum.htm")
refFile = os.path.join(nwRef, "build", "3_LoremIpsum.htm") refFile = os.path.join(refDir, "build", "3_LoremIpsum.htm")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
@@ -521,14 +521,14 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, tmpDir):
assert nwBuild._saveDocument(nwBuild.FMT_NWD) assert nwBuild._saveDocument(nwBuild.FMT_NWD)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd") projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd")
testFile = os.path.join(nwTempBuild, "4_LoremIpsum.nwd") testFile = os.path.join(nwTempBuild, "4_LoremIpsum.nwd")
refFile = os.path.join(nwRef, "build", "4_LoremIpsum.nwd") refFile = os.path.join(refDir, "build", "4_LoremIpsum.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
assert nwBuild._saveDocument(nwBuild.FMT_HTM) assert nwBuild._saveDocument(nwBuild.FMT_HTM)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm") projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm")
testFile = os.path.join(nwTempBuild, "4_LoremIpsum.htm") testFile = os.path.join(nwTempBuild, "4_LoremIpsum.htm")
refFile = os.path.join(nwRef, "build", "4_LoremIpsum.htm") refFile = os.path.join(refDir, "build", "4_LoremIpsum.htm")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
@@ -536,14 +536,14 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, tmpDir):
assert nwBuild._saveDocument(nwBuild.FMT_JSON_H) assert nwBuild._saveDocument(nwBuild.FMT_JSON_H)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.json") projFile = os.path.join(nwLipsum, "Lorem Ipsum.json")
testFile = os.path.join(nwTempBuild, "4H_LoremIpsum.json") testFile = os.path.join(nwTempBuild, "4H_LoremIpsum.json")
refFile = os.path.join(nwRef, "build", "4H_LoremIpsum.json") refFile = os.path.join(refDir, "build", "4H_LoremIpsum.json")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [8]) assert cmpFiles(testFile, refFile, [8])
assert nwBuild._saveDocument(nwBuild.FMT_JSON_M) assert nwBuild._saveDocument(nwBuild.FMT_JSON_M)
projFile = os.path.join(nwLipsum, "Lorem Ipsum.json") projFile = os.path.join(nwLipsum, "Lorem Ipsum.json")
testFile = os.path.join(nwTempBuild, "4M_LoremIpsum.json") testFile = os.path.join(nwTempBuild, "4M_LoremIpsum.json")
refFile = os.path.join(nwRef, "build", "4M_LoremIpsum.json") refFile = os.path.join(refDir, "build", "4M_LoremIpsum.json")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [8]) assert cmpFiles(testFile, refFile, [8])
@@ -589,7 +589,7 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, tmpDir):
nwGUI.closeMain() nwGUI.closeMain()
@pytest.mark.gui @pytest.mark.gui
def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef, tmpDir): def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, refDir, tmpDir):
nwGUI = nw.main(["--testmode", "--config=%s" % nwLipsum, "--data=%s" % tmpDir]) nwGUI = nw.main(["--testmode", "--config=%s" % nwLipsum, "--data=%s" % tmpDir])
qtbot.addWidget(nwGUI) qtbot.addWidget(nwGUI)
@@ -620,7 +620,7 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
projFile = os.path.join(nwLipsum, "content", "73475cb40a568.nwd") projFile = os.path.join(nwLipsum, "content", "73475cb40a568.nwd")
testFile = os.path.join(nwTempGUI, "4_73475cb40a568.nwd") testFile = os.path.join(nwTempGUI, "4_73475cb40a568.nwd")
refFile = os.path.join(nwRef, "gui", "4_73475cb40a568.nwd") refFile = os.path.join(refDir, "gui", "4_73475cb40a568.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
@@ -646,7 +646,7 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
# This should give us back the file as it was before # This should give us back the file as it was before
projFile = os.path.join(nwLipsum, "content", "71ee45a3c0db9.nwd") projFile = os.path.join(nwLipsum, "content", "71ee45a3c0db9.nwd")
testFile = os.path.join(nwTempGUI, "4_71ee45a3c0db9.nwd") testFile = os.path.join(nwTempGUI, "4_71ee45a3c0db9.nwd")
refFile = os.path.join(nwRef, "gui", "4_73475cb40a568.nwd") refFile = os.path.join(refDir, "gui", "4_73475cb40a568.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [1, 2, 3]) assert cmpFiles(testFile, refFile, [1, 2, 3])
@@ -670,19 +670,19 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
projFile = os.path.join(nwLipsum, "content", "25fc0e7096fc6.nwd") projFile = os.path.join(nwLipsum, "content", "25fc0e7096fc6.nwd")
testFile = os.path.join(nwTempGUI, "5_25fc0e7096fc6.nwd") testFile = os.path.join(nwTempGUI, "5_25fc0e7096fc6.nwd")
refFile = os.path.join(nwRef, "gui", "5_25fc0e7096fc6.nwd") refFile = os.path.join(refDir, "gui", "5_25fc0e7096fc6.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
projFile = os.path.join(nwLipsum, "content", "31489056e0916.nwd") projFile = os.path.join(nwLipsum, "content", "31489056e0916.nwd")
testFile = os.path.join(nwTempGUI, "5_31489056e0916.nwd") testFile = os.path.join(nwTempGUI, "5_31489056e0916.nwd")
refFile = os.path.join(nwRef, "gui", "5_31489056e0916.nwd") refFile = os.path.join(refDir, "gui", "5_31489056e0916.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
projFile = os.path.join(nwLipsum, "content", "98010bd9270f9.nwd") projFile = os.path.join(nwLipsum, "content", "98010bd9270f9.nwd")
testFile = os.path.join(nwTempGUI, "5_98010bd9270f9.nwd") testFile = os.path.join(nwTempGUI, "5_98010bd9270f9.nwd")
refFile = os.path.join(nwRef, "gui", "5_98010bd9270f9.nwd") refFile = os.path.join(refDir, "gui", "5_98010bd9270f9.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
@@ -708,31 +708,31 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
projFile = os.path.join(nwLipsum, "content", "1a6562590ef19.nwd") projFile = os.path.join(nwLipsum, "content", "1a6562590ef19.nwd")
testFile = os.path.join(nwTempGUI, "5_25fc0e7096fc6.nwd") testFile = os.path.join(nwTempGUI, "5_25fc0e7096fc6.nwd")
refFile = os.path.join(nwRef, "gui", "5_25fc0e7096fc6.nwd") refFile = os.path.join(refDir, "gui", "5_25fc0e7096fc6.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [1, 2, 3]) assert cmpFiles(testFile, refFile, [1, 2, 3])
projFile = os.path.join(nwLipsum, "content", "031b4af5197ec.nwd") projFile = os.path.join(nwLipsum, "content", "031b4af5197ec.nwd")
testFile = os.path.join(nwTempGUI, "5_031b4af5197ec.nwd") testFile = os.path.join(nwTempGUI, "5_031b4af5197ec.nwd")
refFile = os.path.join(nwRef, "gui", "5_031b4af5197ec.nwd") refFile = os.path.join(refDir, "gui", "5_031b4af5197ec.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
projFile = os.path.join(nwLipsum, "content", "41cfc0d1f2d12.nwd") projFile = os.path.join(nwLipsum, "content", "41cfc0d1f2d12.nwd")
testFile = os.path.join(nwTempGUI, "5_41cfc0d1f2d12.nwd") testFile = os.path.join(nwTempGUI, "5_41cfc0d1f2d12.nwd")
refFile = os.path.join(nwRef, "gui", "5_41cfc0d1f2d12.nwd") refFile = os.path.join(refDir, "gui", "5_41cfc0d1f2d12.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
projFile = os.path.join(nwLipsum, "content", "2858dcd1057d3.nwd") projFile = os.path.join(nwLipsum, "content", "2858dcd1057d3.nwd")
testFile = os.path.join(nwTempGUI, "5_2858dcd1057d3.nwd") testFile = os.path.join(nwTempGUI, "5_2858dcd1057d3.nwd")
refFile = os.path.join(nwRef, "gui", "5_2858dcd1057d3.nwd") refFile = os.path.join(refDir, "gui", "5_2858dcd1057d3.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
projFile = os.path.join(nwLipsum, "content", "2fca346db6561.nwd") projFile = os.path.join(nwLipsum, "content", "2fca346db6561.nwd")
testFile = os.path.join(nwTempGUI, "5_2fca346db6561.nwd") testFile = os.path.join(nwTempGUI, "5_2fca346db6561.nwd")
refFile = os.path.join(nwRef, "gui", "5_2fca346db6561.nwd") refFile = os.path.join(refDir, "gui", "5_2fca346db6561.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
@@ -1017,7 +1017,7 @@ def testLoadProject(qtbot, monkeypatch, yesToAll, nwMinimal, tmpDir):
nwGUI.close() nwGUI.close()
@pytest.mark.gui @pytest.mark.gui
def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, tmpDir, nwRef, tmpConf): def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, tmpDir, refDir, tmpConf):
nwGUI = nw.main(["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir]) nwGUI = nw.main(["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir])
qtbot.addWidget(nwGUI) qtbot.addWidget(nwGUI)
nwGUI.show() nwGUI.show()
@@ -1203,7 +1203,7 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, tmpDir, nwRef, tmpC
# qtbot.stopForInteraction() # qtbot.stopForInteraction()
nwGUI.closeMain() nwGUI.closeMain()
refConf = os.path.join(nwRef, "novelwriter_prefs.conf") refConf = os.path.join(refDir, "novelwriter_prefs.conf")
projConf = os.path.join(nwGUI.mainConf.confPath, "novelwriter.conf") projConf = os.path.join(nwGUI.mainConf.confPath, "novelwriter.conf")
testConf = os.path.join(tmpDir, "novelwriter_prefs.conf") testConf = os.path.join(tmpDir, "novelwriter_prefs.conf")
copyfile(projConf, testConf) copyfile(projConf, testConf)
+7 -7
View File
@@ -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, nwRef, tmpDir): def testDocEditor(qtbot, yesToAll, nwFuncTemp, 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)
@@ -132,7 +132,7 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, tmpDir):
# Check the files # Check the files
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempGUI, "0_nwProject.nwx") testFile = os.path.join(nwTempGUI, "0_nwProject.nwx")
refFile = os.path.join(nwRef, "gui", "0_nwProject.nwx") refFile = os.path.join(refDir, "gui", "0_nwProject.nwx")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [2, 6, 7, 8]) assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
qtbot.wait(stepDelay) qtbot.wait(stepDelay)
@@ -381,31 +381,31 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, tmpDir):
# Check the files # Check the files
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempGUI, "1_nwProject.nwx") testFile = os.path.join(nwTempGUI, "1_nwProject.nwx")
refFile = os.path.join(nwRef, "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(nwFuncTemp, "content", "031b4af5197ec.nwd")
testFile = os.path.join(nwTempGUI, "1_031b4af5197ec.nwd") testFile = os.path.join(nwTempGUI, "1_031b4af5197ec.nwd")
refFile = os.path.join(nwRef, "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(nwFuncTemp, "content", "1a6562590ef19.nwd")
testFile = os.path.join(nwTempGUI, "1_1a6562590ef19.nwd") testFile = os.path.join(nwTempGUI, "1_1a6562590ef19.nwd")
refFile = os.path.join(nwRef, "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(nwFuncTemp, "content", "0e17daca5f3e1.nwd")
testFile = os.path.join(nwTempGUI, "1_0e17daca5f3e1.nwd") testFile = os.path.join(nwTempGUI, "1_0e17daca5f3e1.nwd")
refFile = os.path.join(nwRef, "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(nwFuncTemp, "content", "41cfc0d1f2d12.nwd")
testFile = os.path.join(nwTempGUI, "1_41cfc0d1f2d12.nwd") testFile = os.path.join(nwTempGUI, "1_41cfc0d1f2d12.nwd")
refFile = os.path.join(nwRef, "gui", "1_41cfc0d1f2d12.nwd") refFile = os.path.join(refDir, "gui", "1_41cfc0d1f2d12.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile) assert cmpFiles(testFile, refFile)
+10 -10
View File
@@ -16,12 +16,12 @@ from nw.core.spellcheck import NWSpellEnchant, NWSpellSimple
from nw.constants import nwConst, nwItemClass, nwItemType, nwItemLayout, nwFiles from nw.constants import nwConst, nwItemClass, nwItemType, nwItemLayout, nwFiles
@pytest.mark.project @pytest.mark.project
def testProjectNewOpenSave(nwFuncTemp, nwTempProj, nwRef, tmpDir, dummyGUI): def testProjectNewOpenSave(nwFuncTemp, nwTempProj, refDir, tmpDir, dummyGUI):
"""Test that a basic project can be created, and opened and saved. """Test that a basic project can be created, and opened and saved.
""" """
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempProj, "1_nwProject.nwx") testFile = os.path.join(nwTempProj, "1_nwProject.nwx")
refFile = os.path.join(nwRef, "proj", "1_nwProject.nwx") refFile = os.path.join(refDir, "proj", "1_nwProject.nwx")
theProject = NWProject(dummyGUI) theProject = NWProject(dummyGUI)
theProject.projTree.setSeed(42) theProject.projTree.setSeed(42)
@@ -62,12 +62,12 @@ def testProjectNewOpenSave(nwFuncTemp, nwTempProj, nwRef, tmpDir, dummyGUI):
assert cmpFiles(testFile, refFile, [2, 6, 7, 8]) assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
@pytest.mark.project @pytest.mark.project
def testProjectNewRoot(nwFuncTemp, nwTempProj, nwRef, dummyGUI): def testProjectNewRoot(nwFuncTemp, nwTempProj, refDir, dummyGUI):
"""Check that new root folders can be added to the project. """Check that new root folders can be added to the project.
""" """
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempProj, "2_nwProject.nwx") testFile = os.path.join(nwTempProj, "2_nwProject.nwx")
refFile = os.path.join(nwRef, "proj", "2_nwProject.nwx") refFile = os.path.join(refDir, "proj", "2_nwProject.nwx")
theProject = NWProject(dummyGUI) theProject = NWProject(dummyGUI)
theProject.projTree.setSeed(42) theProject.projTree.setSeed(42)
@@ -96,12 +96,12 @@ def testProjectNewRoot(nwFuncTemp, nwTempProj, nwRef, dummyGUI):
assert not theProject.projChanged assert not theProject.projChanged
@pytest.mark.project @pytest.mark.project
def testProjectNewFile(nwFuncTemp, nwTempProj, nwRef, dummyGUI): def testProjectNewFile(nwFuncTemp, nwTempProj, refDir, dummyGUI):
"""Check that new files can be added to the project. """Check that new files can be added to the project.
""" """
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempProj, "3_nwProject.nwx") testFile = os.path.join(nwTempProj, "3_nwProject.nwx")
refFile = os.path.join(nwRef, "proj", "3_nwProject.nwx") refFile = os.path.join(refDir, "proj", "3_nwProject.nwx")
theProject = NWProject(dummyGUI) theProject = NWProject(dummyGUI)
theProject.projTree.setSeed(42) theProject.projTree.setSeed(42)
@@ -123,13 +123,13 @@ def testProjectNewFile(nwFuncTemp, nwTempProj, nwRef, dummyGUI):
assert not theProject.projChanged assert not theProject.projChanged
@pytest.mark.project @pytest.mark.project
def testProjectNewCustomA(nwFuncTemp, nwTempProj, nwRef, dummyGUI): def testProjectNewCustomA(nwFuncTemp, nwTempProj, refDir, dummyGUI):
"""Create a new project from a project wizard dictionary. """Create a new project from a project wizard dictionary.
Custom type with chapters and scenes. Custom type with chapters and scenes.
""" """
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempProj, "4_nwProject.nwx") testFile = os.path.join(nwTempProj, "4_nwProject.nwx")
refFile = os.path.join(nwRef, "proj", "4_nwProject.nwx") refFile = os.path.join(refDir, "proj", "4_nwProject.nwx")
projData = { projData = {
"projName": "Test Custom", "projName": "Test Custom",
@@ -162,13 +162,13 @@ def testProjectNewCustomA(nwFuncTemp, nwTempProj, nwRef, dummyGUI):
assert cmpFiles(testFile, refFile, [2, 6, 7, 8]) assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
@pytest.mark.project @pytest.mark.project
def testProjectNewCustomB(nwFuncTemp, nwTempProj, nwRef, dummyGUI): def testProjectNewCustomB(nwFuncTemp, nwTempProj, refDir, dummyGUI):
"""Create a new project from a project wizard dictionary. """Create a new project from a project wizard dictionary.
Custom type without chapters, but with scenes. Custom type without chapters, but with scenes.
""" """
projFile = os.path.join(nwFuncTemp, "nwProject.nwx") projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
testFile = os.path.join(nwTempProj, "5_nwProject.nwx") testFile = os.path.join(nwTempProj, "5_nwProject.nwx")
refFile = os.path.join(nwRef, "proj", "5_nwProject.nwx") refFile = os.path.join(refDir, "proj", "5_nwProject.nwx")
projData = { projData = {
"projName": "Test Custom", "projName": "Test Custom",