Completed coverage of setProjectPath and made all os imports explicit
This commit is contained in:
+46
-46
@@ -5,13 +5,13 @@
|
||||
import sys
|
||||
import pytest
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from os import path, mkdir
|
||||
from nwdummy import DummyMain
|
||||
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
sys.path.insert(1, path.abspath(path.join(path.dirname(__file__), path.pardir)))
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
|
||||
|
||||
from nw.config import Config # noqa: E402
|
||||
|
||||
@@ -25,12 +25,12 @@ def nwTemp():
|
||||
presistent after the test so that the status of generated files can
|
||||
be checked. The folder is instead cleared before a new test session.
|
||||
"""
|
||||
testDir = path.dirname(__file__)
|
||||
tempDir = path.join(testDir, "temp")
|
||||
if path.isdir(tempDir):
|
||||
testDir = os.path.dirname(__file__)
|
||||
tempDir = os.path.join(testDir, "temp")
|
||||
if os.path.isdir(tempDir):
|
||||
shutil.rmtree(tempDir)
|
||||
if not path.isdir(tempDir):
|
||||
mkdir(tempDir)
|
||||
if not os.path.isdir(tempDir):
|
||||
os.mkdir(tempDir)
|
||||
return tempDir
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@@ -38,8 +38,8 @@ def nwRef():
|
||||
"""The folder where all the reference files are stored for verifying
|
||||
the results of tests.
|
||||
"""
|
||||
testDir = path.dirname(__file__)
|
||||
refDir = path.join(testDir, "reference")
|
||||
testDir = os.path.dirname(__file__)
|
||||
refDir = os.path.join(testDir, "reference")
|
||||
return refDir
|
||||
|
||||
##
|
||||
@@ -80,40 +80,40 @@ def nwDummy(nwRef, nwTemp, nwConf):
|
||||
def nwTempProj(nwTemp):
|
||||
"""A temporary folder for project tests.
|
||||
"""
|
||||
projDir = path.join(nwTemp, "proj")
|
||||
if not path.isdir(projDir):
|
||||
mkdir(projDir)
|
||||
projDir = os.path.join(nwTemp, "proj")
|
||||
if not os.path.isdir(projDir):
|
||||
os.mkdir(projDir)
|
||||
return projDir
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def nwTempGUI(nwTemp):
|
||||
"""A temporary folder for GUI tests.
|
||||
"""
|
||||
guiDir = path.join(nwTemp, "gui")
|
||||
if not path.isdir(guiDir):
|
||||
mkdir(guiDir)
|
||||
guiDir = os.path.join(nwTemp, "gui")
|
||||
if not os.path.isdir(guiDir):
|
||||
os.mkdir(guiDir)
|
||||
return guiDir
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def nwTempBuild(nwTemp):
|
||||
"""A temporary folder for build tests.
|
||||
"""
|
||||
buildDir = path.join(nwTemp, "build")
|
||||
if not path.isdir(buildDir):
|
||||
mkdir(buildDir)
|
||||
buildDir = os.path.join(nwTemp, "build")
|
||||
if not os.path.isdir(buildDir):
|
||||
os.mkdir(buildDir)
|
||||
return buildDir
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def nwFuncTemp(nwTemp):
|
||||
"""A temporary folder for a single test function.
|
||||
"""
|
||||
funcDir = path.join(nwTemp, "ftemp")
|
||||
if path.isdir(funcDir):
|
||||
funcDir = os.path.join(nwTemp, "ftemp")
|
||||
if os.path.isdir(funcDir):
|
||||
shutil.rmtree(funcDir)
|
||||
if not path.isdir(funcDir):
|
||||
mkdir(funcDir)
|
||||
if not os.path.isdir(funcDir):
|
||||
os.mkdir(funcDir)
|
||||
yield funcDir
|
||||
if path.isdir(funcDir):
|
||||
if os.path.isdir(funcDir):
|
||||
shutil.rmtree(funcDir)
|
||||
return
|
||||
|
||||
@@ -125,20 +125,20 @@ def nwFuncTemp(nwTemp):
|
||||
def nwMinimal(nwTemp):
|
||||
"""A minimal novelWriter example project.
|
||||
"""
|
||||
testDir = path.dirname(__file__)
|
||||
minimalStore = path.join(testDir, "minimal")
|
||||
minimalDir = path.join(nwTemp, "minimal")
|
||||
if path.isdir(minimalDir):
|
||||
testDir = os.path.dirname(__file__)
|
||||
minimalStore = os.path.join(testDir, "minimal")
|
||||
minimalDir = os.path.join(nwTemp, "minimal")
|
||||
if os.path.isdir(minimalDir):
|
||||
shutil.rmtree(minimalDir)
|
||||
shutil.copytree(minimalStore, minimalDir)
|
||||
cacheDir = path.join(minimalDir, "cache")
|
||||
if path.isdir(cacheDir):
|
||||
cacheDir = os.path.join(minimalDir, "cache")
|
||||
if os.path.isdir(cacheDir):
|
||||
shutil.rmtree(cacheDir)
|
||||
metaDir = path.join(minimalDir, "meta")
|
||||
if path.isdir(metaDir):
|
||||
metaDir = os.path.join(minimalDir, "meta")
|
||||
if os.path.isdir(metaDir):
|
||||
shutil.rmtree(metaDir)
|
||||
yield minimalDir
|
||||
if path.isdir(minimalDir):
|
||||
if os.path.isdir(minimalDir):
|
||||
shutil.rmtree(minimalDir)
|
||||
return
|
||||
|
||||
@@ -147,20 +147,20 @@ def nwLipsum(nwTemp):
|
||||
"""A medium sized novelWriter example project with a lot of Lorem
|
||||
Ipsum dummy text.
|
||||
"""
|
||||
testDir = path.dirname(__file__)
|
||||
lipsumStore = path.join(testDir, "lipsum")
|
||||
lipsumDir = path.join(nwTemp, "lipsum")
|
||||
if path.isdir(lipsumDir):
|
||||
testDir = os.path.dirname(__file__)
|
||||
lipsumStore = os.path.join(testDir, "lipsum")
|
||||
lipsumDir = os.path.join(nwTemp, "lipsum")
|
||||
if os.path.isdir(lipsumDir):
|
||||
shutil.rmtree(lipsumDir)
|
||||
shutil.copytree(lipsumStore, lipsumDir)
|
||||
cacheDir = path.join(lipsumDir, "cache")
|
||||
if path.isdir(cacheDir):
|
||||
cacheDir = os.path.join(lipsumDir, "cache")
|
||||
if os.path.isdir(cacheDir):
|
||||
shutil.rmtree(cacheDir)
|
||||
metaDir = path.join(lipsumDir, "meta")
|
||||
if path.isdir(metaDir):
|
||||
metaDir = os.path.join(lipsumDir, "meta")
|
||||
if os.path.isdir(metaDir):
|
||||
shutil.rmtree(metaDir)
|
||||
yield lipsumDir
|
||||
if path.isdir(lipsumDir):
|
||||
if os.path.isdir(lipsumDir):
|
||||
shutil.rmtree(lipsumDir)
|
||||
return
|
||||
|
||||
@@ -168,14 +168,14 @@ def nwLipsum(nwTemp):
|
||||
def nwOldProj(nwTemp):
|
||||
"""A minimal movelWriter project using the old folder structure.
|
||||
"""
|
||||
testDir = path.dirname(__file__)
|
||||
oldProjStore = path.join(testDir, "oldproj")
|
||||
oldProjDir = path.join(nwTemp, "oldproj")
|
||||
if path.isdir(oldProjDir):
|
||||
testDir = os.path.dirname(__file__)
|
||||
oldProjStore = os.path.join(testDir, "oldproj")
|
||||
oldProjDir = os.path.join(nwTemp, "oldproj")
|
||||
if os.path.isdir(oldProjDir):
|
||||
shutil.rmtree(oldProjDir)
|
||||
shutil.copytree(oldProjStore, oldProjDir)
|
||||
yield oldProjDir
|
||||
if path.isdir(oldProjDir):
|
||||
if os.path.isdir(oldProjDir):
|
||||
shutil.rmtree(oldProjDir)
|
||||
return
|
||||
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pstats
|
||||
import os
|
||||
|
||||
from os import path
|
||||
|
||||
profDir = path.abspath(path.join(path.dirname(__file__), path.pardir, "prof"))
|
||||
profDir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, "prof"))
|
||||
|
||||
print("")
|
||||
print("Profiles directory: %s" % profDir)
|
||||
print("")
|
||||
|
||||
profMainWindows = pstats.Stats(path.join(profDir, "testMainWindows.prof"))
|
||||
profMainWindows = pstats.Stats(os.path.join(profDir, "testMainWindows.prof"))
|
||||
profMainWindows.sort_stats("cumtime")
|
||||
profMainWindows.print_stats("nw/")
|
||||
|
||||
+16
-15
@@ -3,13 +3,14 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import os
|
||||
|
||||
from nwtools import cmpFiles
|
||||
from os import path
|
||||
|
||||
@pytest.mark.core
|
||||
def testConfigCore(tmpConf, nwTemp, nwRef):
|
||||
refConf = path.join(nwRef, "novelwriter.conf")
|
||||
testConf = path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
refConf = os.path.join(nwRef, "novelwriter.conf")
|
||||
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
|
||||
assert tmpConf.confPath == nwTemp
|
||||
assert tmpConf.saveConfig()
|
||||
@@ -22,8 +23,8 @@ def testConfigCore(tmpConf, nwTemp, nwRef):
|
||||
@pytest.mark.core
|
||||
def testConfigSetConfPath(tmpConf, nwTemp):
|
||||
assert tmpConf.setConfPath(None)
|
||||
assert not tmpConf.setConfPath(path.join("somewhere", "over", "the", "rainbow"))
|
||||
assert tmpConf.setConfPath(path.join(nwTemp, "novelwriter.conf"))
|
||||
assert not tmpConf.setConfPath(os.path.join("somewhere", "over", "the", "rainbow"))
|
||||
assert tmpConf.setConfPath(os.path.join(nwTemp, "novelwriter.conf"))
|
||||
assert tmpConf.confPath == nwTemp
|
||||
assert tmpConf.confFile == "novelwriter.conf"
|
||||
assert not tmpConf.confChanged
|
||||
@@ -31,15 +32,15 @@ def testConfigSetConfPath(tmpConf, nwTemp):
|
||||
@pytest.mark.core
|
||||
def testConfigSetDataPath(tmpConf, nwTemp):
|
||||
assert tmpConf.setDataPath(None)
|
||||
assert not tmpConf.setDataPath(path.join("somewhere", "over", "the", "rainbow"))
|
||||
assert not tmpConf.setDataPath(os.path.join("somewhere", "over", "the", "rainbow"))
|
||||
assert tmpConf.setDataPath(nwTemp)
|
||||
assert tmpConf.dataPath == nwTemp
|
||||
assert not tmpConf.confChanged
|
||||
|
||||
@pytest.mark.core
|
||||
def testConfigSetWinSize(tmpConf, nwTemp, nwRef):
|
||||
refConf = path.join(nwRef, "novelwriter.conf")
|
||||
testConf = path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
refConf = os.path.join(nwRef, "novelwriter.conf")
|
||||
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
tmpConf.guiScale = 1.0
|
||||
|
||||
assert tmpConf.confPath == nwTemp
|
||||
@@ -55,8 +56,8 @@ def testConfigSetWinSize(tmpConf, nwTemp, nwRef):
|
||||
|
||||
@pytest.mark.core
|
||||
def testConfigSetTreeColWidths(tmpConf, nwTemp, nwRef):
|
||||
refConf = path.join(nwRef, "novelwriter.conf")
|
||||
testConf = path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
refConf = os.path.join(nwRef, "novelwriter.conf")
|
||||
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
|
||||
assert tmpConf.confPath == nwTemp
|
||||
tmpConf.guiScale = 1.0
|
||||
@@ -77,8 +78,8 @@ def testConfigSetTreeColWidths(tmpConf, nwTemp, nwRef):
|
||||
|
||||
@pytest.mark.core
|
||||
def testConfigSetPanePos(tmpConf, nwTemp, nwRef):
|
||||
refConf = path.join(nwRef, "novelwriter.conf")
|
||||
testConf = path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
refConf = os.path.join(nwRef, "novelwriter.conf")
|
||||
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
|
||||
assert tmpConf.confPath == nwTemp
|
||||
|
||||
@@ -113,8 +114,8 @@ def testConfigSetPanePos(tmpConf, nwTemp, nwRef):
|
||||
|
||||
@pytest.mark.core
|
||||
def testConfigFlags(tmpConf, nwTemp, nwRef):
|
||||
refConf = path.join(nwRef, "novelwriter.conf")
|
||||
testConf = path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
refConf = os.path.join(nwRef, "novelwriter.conf")
|
||||
testConf = os.path.join(tmpConf.confPath, "novelwriter.conf")
|
||||
|
||||
assert tmpConf.confPath == nwTemp
|
||||
|
||||
@@ -150,7 +151,7 @@ def testTextSizes(tmpConf, nwTemp, nwRef):
|
||||
|
||||
@pytest.mark.core
|
||||
def testConfigErrors(tmpConf):
|
||||
nonPath = path.join("somewhere", "over", "the", "rainbow")
|
||||
nonPath = os.path.join("somewhere", "over", "the", "rainbow")
|
||||
assert tmpConf.initConfig(nonPath, nonPath)
|
||||
assert tmpConf.hasError
|
||||
assert not tmpConf.loadConfig()
|
||||
|
||||
+76
-77
@@ -5,12 +5,11 @@
|
||||
import nw
|
||||
import pytest
|
||||
import json
|
||||
import os
|
||||
|
||||
from shutil import copyfile
|
||||
from nwtools import cmpFiles, getGuiItem
|
||||
|
||||
from os import path
|
||||
|
||||
from PyQt5.QtCore import Qt, QItemSelectionModel
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QTreeWidgetItem, QListWidgetItem, QDialog, QAction,
|
||||
@@ -130,9 +129,9 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, nwR
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
# Check the files
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempGUI, "2_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "gui", "2_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempGUI, "2_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "gui", "2_nwProject.nwx")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [2, 8, 9, 10])
|
||||
|
||||
@@ -189,9 +188,9 @@ def testItemEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
# Check the files
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempGUI, "3_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "gui", "3_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempGUI, "3_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "gui", "3_nwProject.nwx")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
||||
|
||||
@@ -273,7 +272,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
jsonStats = path.join(nwFuncTemp, "sessionStats.json")
|
||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||
jsonData = json.loads(inFile.read())
|
||||
|
||||
@@ -289,7 +288,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
jsonStats = path.join(nwFuncTemp, "sessionStats.json")
|
||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||
jsonData = json.loads(inFile.read())
|
||||
|
||||
@@ -306,7 +305,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
jsonStats = path.join(nwFuncTemp, "sessionStats.json")
|
||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||
jsonData = json.loads(inFile.read())
|
||||
|
||||
@@ -323,7 +322,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
jsonStats = path.join(nwFuncTemp, "sessionStats.json")
|
||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||
jsonData = json.loads(inFile.read())
|
||||
|
||||
@@ -336,7 +335,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
jsonStats = path.join(nwFuncTemp, "sessionStats.json")
|
||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||
jsonData = json.loads(inFile.read())
|
||||
|
||||
@@ -348,7 +347,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
jsonStats = path.join(nwFuncTemp, "sessionStats.json")
|
||||
jsonStats = os.path.join(nwFuncTemp, "sessionStats.json")
|
||||
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
|
||||
jsonData = json.loads(inFile.read())
|
||||
|
||||
@@ -419,15 +418,15 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, nwTemp):
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
||||
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.nwd")
|
||||
testFile = path.join(nwTempBuild, "1_LoremIpsum.nwd")
|
||||
refFile = path.join(nwRef, "build", "1_LoremIpsum.nwd")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd")
|
||||
testFile = os.path.join(nwTempBuild, "1_LoremIpsum.nwd")
|
||||
refFile = os.path.join(nwRef, "build", "1_LoremIpsum.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.htm")
|
||||
testFile = path.join(nwTempBuild, "1_LoremIpsum.htm")
|
||||
refFile = path.join(nwRef, "build", "1_LoremIpsum.htm")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm")
|
||||
testFile = os.path.join(nwTempBuild, "1_LoremIpsum.htm")
|
||||
refFile = os.path.join(nwRef, "build", "1_LoremIpsum.htm")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
@@ -458,15 +457,15 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, nwTemp):
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
||||
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.nwd")
|
||||
testFile = path.join(nwTempBuild, "2_LoremIpsum.nwd")
|
||||
refFile = path.join(nwRef, "build", "2_LoremIpsum.nwd")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd")
|
||||
testFile = os.path.join(nwTempBuild, "2_LoremIpsum.nwd")
|
||||
refFile = os.path.join(nwRef, "build", "2_LoremIpsum.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.htm")
|
||||
testFile = path.join(nwTempBuild, "2_LoremIpsum.htm")
|
||||
refFile = path.join(nwRef, "build", "2_LoremIpsum.htm")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm")
|
||||
testFile = os.path.join(nwTempBuild, "2_LoremIpsum.htm")
|
||||
refFile = os.path.join(nwRef, "build", "2_LoremIpsum.htm")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
@@ -491,31 +490,31 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, nwTemp):
|
||||
|
||||
# Save files that can be compared
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.nwd")
|
||||
testFile = path.join(nwTempBuild, "3_LoremIpsum.nwd")
|
||||
refFile = path.join(nwRef, "build", "3_LoremIpsum.nwd")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.nwd")
|
||||
testFile = os.path.join(nwTempBuild, "3_LoremIpsum.nwd")
|
||||
refFile = os.path.join(nwRef, "build", "3_LoremIpsum.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.htm")
|
||||
testFile = path.join(nwTempBuild, "3_LoremIpsum.htm")
|
||||
refFile = path.join(nwRef, "build", "3_LoremIpsum.htm")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.htm")
|
||||
testFile = os.path.join(nwTempBuild, "3_LoremIpsum.htm")
|
||||
refFile = os.path.join(nwRef, "build", "3_LoremIpsum.htm")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
# Check the JSON files too at this stage
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_JSON_H)
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.json")
|
||||
testFile = path.join(nwTempBuild, "3H_LoremIpsum.json")
|
||||
refFile = path.join(nwRef, "build", "3H_LoremIpsum.json")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.json")
|
||||
testFile = os.path.join(nwTempBuild, "3H_LoremIpsum.json")
|
||||
refFile = os.path.join(nwRef, "build", "3H_LoremIpsum.json")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [8])
|
||||
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_JSON_M)
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.json")
|
||||
testFile = path.join(nwTempBuild, "3M_LoremIpsum.json")
|
||||
refFile = path.join(nwRef, "build", "3M_LoremIpsum.json")
|
||||
projFile = os.path.join(nwLipsum, "Lorem Ipsum.json")
|
||||
testFile = os.path.join(nwTempBuild, "3M_LoremIpsum.json")
|
||||
refFile = os.path.join(nwRef, "build", "3M_LoremIpsum.json")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [8])
|
||||
|
||||
@@ -526,10 +525,10 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, nwTemp):
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_PDF)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_MD)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_TXT)
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.odt"))
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.pdf"))
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.md"))
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.txt"))
|
||||
assert os.path.isfile(os.path.join(nwLipsum, "Lorem Ipsum.odt"))
|
||||
assert os.path.isfile(os.path.join(nwLipsum, "Lorem Ipsum.pdf"))
|
||||
assert os.path.isfile(os.path.join(nwLipsum, "Lorem Ipsum.md"))
|
||||
assert os.path.isfile(os.path.join(nwLipsum, "Lorem Ipsum.txt"))
|
||||
|
||||
# Close the build tool
|
||||
htmlText = nwBuild.htmlText
|
||||
@@ -581,9 +580,9 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
|
||||
|
||||
assert nwGUI.theProject.projTree["73475cb40a568"] is not None
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "73475cb40a568.nwd")
|
||||
testFile = path.join(nwTempGUI, "4_73475cb40a568.nwd")
|
||||
refFile = path.join(nwRef, "gui", "4_73475cb40a568.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "73475cb40a568.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "4_73475cb40a568.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "4_73475cb40a568.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
@@ -607,9 +606,9 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
|
||||
assert nwGUI.theProject.projTree["71ee45a3c0db9"] is not None
|
||||
|
||||
# This should give us back the file as it was before
|
||||
projFile = path.join(nwLipsum, "content", "71ee45a3c0db9.nwd")
|
||||
testFile = path.join(nwTempGUI, "4_71ee45a3c0db9.nwd")
|
||||
refFile = path.join(nwRef, "gui", "4_73475cb40a568.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "71ee45a3c0db9.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "4_71ee45a3c0db9.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "4_73475cb40a568.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [1])
|
||||
|
||||
@@ -627,21 +626,21 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
|
||||
assert nwGUI.theProject.projTree["31489056e0916"] is not None
|
||||
assert nwGUI.theProject.projTree["98010bd9270f9"] is not None
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "25fc0e7096fc6.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_25fc0e7096fc6.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_25fc0e7096fc6.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "25fc0e7096fc6.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_25fc0e7096fc6.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_25fc0e7096fc6.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "31489056e0916.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_31489056e0916.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_31489056e0916.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "31489056e0916.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_31489056e0916.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_31489056e0916.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "98010bd9270f9.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_98010bd9270f9.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_98010bd9270f9.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "98010bd9270f9.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_98010bd9270f9.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_98010bd9270f9.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
@@ -661,33 +660,33 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
|
||||
assert nwGUI.theProject.projTree["2858dcd1057d3"] is not None
|
||||
assert nwGUI.theProject.projTree["2fca346db6561"] is not None
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "1a6562590ef19.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_25fc0e7096fc6.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_25fc0e7096fc6.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "1a6562590ef19.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_25fc0e7096fc6.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_25fc0e7096fc6.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [1])
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "031b4af5197ec.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_031b4af5197ec.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_031b4af5197ec.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "031b4af5197ec.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_031b4af5197ec.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_031b4af5197ec.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "41cfc0d1f2d12.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_41cfc0d1f2d12.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_41cfc0d1f2d12.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "41cfc0d1f2d12.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_41cfc0d1f2d12.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_41cfc0d1f2d12.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "2858dcd1057d3.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_2858dcd1057d3.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_2858dcd1057d3.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "2858dcd1057d3.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_2858dcd1057d3.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_2858dcd1057d3.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwLipsum, "content", "2fca346db6561.nwd")
|
||||
testFile = path.join(nwTempGUI, "5_2fca346db6561.nwd")
|
||||
refFile = path.join(nwRef, "gui", "5_2fca346db6561.nwd")
|
||||
projFile = os.path.join(nwLipsum, "content", "2fca346db6561.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "5_2fca346db6561.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "5_2fca346db6561.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
@@ -795,7 +794,7 @@ def testNewProjectWizard(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp):
|
||||
|
||||
qtbot.wait(stepDelay)
|
||||
qtbot.mouseClick(storagePage.browseButton, Qt.LeftButton, delay=100)
|
||||
projPath = path.join(nwMinimal, "Test Minimal")
|
||||
projPath = os.path.join(nwMinimal, "Test Minimal")
|
||||
assert storagePage.projPath.text() == projPath
|
||||
|
||||
# Setting projPath should activate the button
|
||||
@@ -939,7 +938,7 @@ def testLoadProject(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp):
|
||||
nwLoad._keyPressDelete()
|
||||
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
|
||||
|
||||
getFile = path.join(nwMinimal, "nwProject.nwx")
|
||||
getFile = os.path.join(nwMinimal, "nwProject.nwx")
|
||||
monkeypatch.setattr(QFileDialog, "getOpenFileName", lambda *args, **kwargs: (getFile, None))
|
||||
qtbot.mouseClick(nwLoad.browseButton, Qt.LeftButton)
|
||||
assert nwLoad.openPath == nwMinimal
|
||||
@@ -1109,9 +1108,9 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
||||
# qtbot.stopForInteraction()
|
||||
nwGUI.closeMain()
|
||||
|
||||
refConf = path.join(nwRef, "novelwriter_prefs.conf")
|
||||
projConf = path.join(nwGUI.mainConf.confPath, "novelwriter.conf")
|
||||
testConf = path.join(nwTemp, "novelwriter_prefs.conf")
|
||||
refConf = os.path.join(nwRef, "novelwriter_prefs.conf")
|
||||
projConf = os.path.join(nwGUI.mainConf.confPath, "novelwriter.conf")
|
||||
testConf = os.path.join(nwTemp, "novelwriter_prefs.conf")
|
||||
copyfile(projConf, testConf)
|
||||
ignoreLines = [
|
||||
2, # Timestamp
|
||||
|
||||
+31
-31
@@ -5,11 +5,11 @@
|
||||
import nw
|
||||
import pytest
|
||||
import logging
|
||||
import os
|
||||
|
||||
from shutil import copyfile
|
||||
from nwtools import cmpFiles
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtCore import Qt, QUrl, QPoint, QItemSelectionModel
|
||||
from PyQt5.QtGui import QTextCursor, QColor, QPixmap, QIcon
|
||||
from PyQt5.QtWidgets import (
|
||||
@@ -57,19 +57,19 @@ def testLaunch(qtbot, nwFuncTemp, nwTemp):
|
||||
nwGUI.close()
|
||||
|
||||
# Log file
|
||||
logFile = path.join(nwTemp, "logFile.log")
|
||||
bakFile = path.join(nwTemp, "logFile.log.bak")
|
||||
logFile = os.path.join(nwTemp, "logFile.log")
|
||||
bakFile = os.path.join(nwTemp, "logFile.log.bak")
|
||||
|
||||
nwGUI = nw.main(
|
||||
["--testmode", "--logfile=%s" % logFile, "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp]
|
||||
)
|
||||
assert path.isfile(logFile)
|
||||
assert os.path.isfile(logFile)
|
||||
|
||||
nwGUI = nw.main(
|
||||
["--testmode", "--logfile=%s" % logFile, "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp]
|
||||
)
|
||||
assert path.isfile(bakFile)
|
||||
assert path.isfile(logFile)
|
||||
assert os.path.isfile(bakFile)
|
||||
assert os.path.isfile(logFile)
|
||||
nwGUI.closeMain()
|
||||
nwGUI.close()
|
||||
|
||||
@@ -116,9 +116,9 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
||||
assert not nwGUI.theProject.spellCheck
|
||||
|
||||
# Check the files
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempGUI, "0_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "gui", "0_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempGUI, "0_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "gui", "0_nwProject.nwx")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
||||
qtbot.wait(stepDelay)
|
||||
@@ -135,7 +135,7 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
||||
assert len(nwGUI.theProject.projTree._treeRoots) == 4
|
||||
assert nwGUI.theProject.projTree.trashRoot() is None
|
||||
assert nwGUI.theProject.projPath == nwFuncTemp
|
||||
assert nwGUI.theProject.projMeta == path.join(nwFuncTemp, "meta")
|
||||
assert nwGUI.theProject.projMeta == os.path.join(nwFuncTemp, "meta")
|
||||
assert nwGUI.theProject.projFile == "nwProject.nwx"
|
||||
assert nwGUI.theProject.projName == "New Project"
|
||||
assert nwGUI.theProject.bookTitle == ""
|
||||
@@ -358,33 +358,33 @@ def testDocEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
||||
assert nwGUI.saveProject()
|
||||
|
||||
# Check the files
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempGUI, "1_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "gui", "1_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempGUI, "1_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "gui", "1_nwProject.nwx")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
||||
|
||||
projFile = path.join(nwFuncTemp, "content", "031b4af5197ec.nwd")
|
||||
testFile = path.join(nwTempGUI, "1_031b4af5197ec.nwd")
|
||||
refFile = path.join(nwRef, "gui", "1_031b4af5197ec.nwd")
|
||||
projFile = os.path.join(nwFuncTemp, "content", "031b4af5197ec.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "1_031b4af5197ec.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "1_031b4af5197ec.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwFuncTemp, "content", "1a6562590ef19.nwd")
|
||||
testFile = path.join(nwTempGUI, "1_1a6562590ef19.nwd")
|
||||
refFile = path.join(nwRef, "gui", "1_1a6562590ef19.nwd")
|
||||
projFile = os.path.join(nwFuncTemp, "content", "1a6562590ef19.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "1_1a6562590ef19.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "1_1a6562590ef19.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwFuncTemp, "content", "0e17daca5f3e1.nwd")
|
||||
testFile = path.join(nwTempGUI, "1_0e17daca5f3e1.nwd")
|
||||
refFile = path.join(nwRef, "gui", "1_0e17daca5f3e1.nwd")
|
||||
projFile = os.path.join(nwFuncTemp, "content", "0e17daca5f3e1.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "1_0e17daca5f3e1.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "1_0e17daca5f3e1.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
projFile = path.join(nwFuncTemp, "content", "41cfc0d1f2d12.nwd")
|
||||
testFile = path.join(nwTempGUI, "1_41cfc0d1f2d12.nwd")
|
||||
refFile = path.join(nwRef, "gui", "1_41cfc0d1f2d12.nwd")
|
||||
projFile = os.path.join(nwFuncTemp, "content", "41cfc0d1f2d12.nwd")
|
||||
testFile = os.path.join(nwTempGUI, "1_41cfc0d1f2d12.nwd")
|
||||
refFile = os.path.join(nwRef, "gui", "1_41cfc0d1f2d12.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
@@ -625,7 +625,7 @@ def testProjectTree(qtbot, yesToAll, nwMinimal, nwTemp):
|
||||
nwGUI.openDocument("73475cb40a568")
|
||||
nwGUI.docEditor.setText("# Hello World\n")
|
||||
nwGUI.saveDocument()
|
||||
assert path.isfile(path.join(nwMinimal, "content", "73475cb40a568.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwMinimal, "content", "73475cb40a568.nwd"))
|
||||
|
||||
# Delete the items we added earlier
|
||||
nwTree.clearSelection()
|
||||
@@ -640,17 +640,17 @@ def testProjectTree(qtbot, yesToAll, nwMinimal, nwTemp):
|
||||
assert "71ee45a3c0db9" not in nwGUI.theProject.projTree._treeOrder
|
||||
|
||||
# The file is in trash, empty it
|
||||
assert path.isfile(path.join(nwMinimal, "content", "73475cb40a568.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwMinimal, "content", "73475cb40a568.nwd"))
|
||||
assert nwTree.emptyTrash()
|
||||
assert not nwTree.emptyTrash() # Already empty
|
||||
assert not path.isfile(path.join(nwMinimal, "content", "73475cb40a568.nwd"))
|
||||
assert not os.path.isfile(os.path.join(nwMinimal, "content", "73475cb40a568.nwd"))
|
||||
assert "73475cb40a568" not in nwGUI.theProject.projTree._treeOrder
|
||||
|
||||
# Close the project
|
||||
nwGUI.closeProject()
|
||||
|
||||
# Add an orphaned file
|
||||
orphFile = path.join(nwMinimal, "content", "1234567890abc.nwd")
|
||||
orphFile = os.path.join(nwMinimal, "content", "1234567890abc.nwd")
|
||||
with open(orphFile, mode="w+", encoding="utf8") as outFile:
|
||||
outFile.write("# Hello World\n")
|
||||
|
||||
@@ -1102,7 +1102,7 @@ def testInsertMenu(qtbot, monkeypatch, nwFuncTemp, nwTemp):
|
||||
assert not nwGUI.importDocument()
|
||||
|
||||
# Then a valid path, but bot a file that exists
|
||||
theFile = path.join(nwTemp, "import.txt")
|
||||
theFile = os.path.join(nwTemp, "import.txt")
|
||||
monkeypatch.setattr(QFileDialog, "getOpenFileName", lambda *args, **kwards: [theFile])
|
||||
assert not nwGUI.importDocument()
|
||||
|
||||
@@ -1145,7 +1145,7 @@ def testInsertMenu(qtbot, monkeypatch, nwFuncTemp, nwTemp):
|
||||
assert len(theBits) == 3
|
||||
assert theBits[0] == "File details for the currently open file"
|
||||
assert theBits[1] == "Handle: 0e17daca5f3e1"
|
||||
assert theBits[2] == "Location: %s" % path.join(nwFuncTemp, "content", "0e17daca5f3e1.nwd")
|
||||
assert theBits[2] == "Location: %s" % os.path.join(nwFuncTemp, "content", "0e17daca5f3e1.nwd")
|
||||
|
||||
# qtbot.stopForInteraction()
|
||||
nwGUI.closeMain()
|
||||
|
||||
+170
-81
@@ -3,7 +3,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from os import path, mkdir, listdir
|
||||
import os
|
||||
|
||||
from shutil import copyfile
|
||||
from zipfile import ZipFile
|
||||
|
||||
@@ -18,9 +19,9 @@ from nw.constants import nwItemClass, nwItemType, nwItemLayout, nwFiles
|
||||
def testProjectNewOpenSave(nwFuncTemp, nwTempProj, nwRef, nwTemp, nwDummy):
|
||||
"""Test that a basic project can be created, and opened and saved.
|
||||
"""
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempProj, "1_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "proj", "1_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempProj, "1_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "proj", "1_nwProject.nwx")
|
||||
|
||||
theProject = NWProject(nwDummy)
|
||||
theProject.projTree.setSeed(42)
|
||||
@@ -64,9 +65,9 @@ def testProjectNewOpenSave(nwFuncTemp, nwTempProj, nwRef, nwTemp, nwDummy):
|
||||
def testProjectNewRoot(nwFuncTemp, nwTempProj, nwRef, nwDummy):
|
||||
"""Check that new root folders can be added to the project.
|
||||
"""
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempProj, "2_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "proj", "2_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempProj, "2_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "proj", "2_nwProject.nwx")
|
||||
|
||||
theProject = NWProject(nwDummy)
|
||||
theProject.projTree.setSeed(42)
|
||||
@@ -98,9 +99,9 @@ def testProjectNewRoot(nwFuncTemp, nwTempProj, nwRef, nwDummy):
|
||||
def testProjectNewFile(nwFuncTemp, nwTempProj, nwRef, nwDummy):
|
||||
"""Check that new files can be added to the project.
|
||||
"""
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempProj, "3_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "proj", "3_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempProj, "3_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "proj", "3_nwProject.nwx")
|
||||
|
||||
theProject = NWProject(nwDummy)
|
||||
theProject.projTree.setSeed(42)
|
||||
@@ -126,9 +127,9 @@ def testProjectNewCustomA(nwFuncTemp, nwTempProj, nwRef, nwDummy):
|
||||
"""Create a new project from a project wizard dictionary.
|
||||
Custom type with chapters and scenes.
|
||||
"""
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempProj, "4_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "proj", "4_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempProj, "4_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "proj", "4_nwProject.nwx")
|
||||
|
||||
projData = {
|
||||
"projName": "Test Custom",
|
||||
@@ -165,9 +166,9 @@ def testProjectNewCustomB(nwFuncTemp, nwTempProj, nwRef, nwDummy):
|
||||
"""Create a new project from a project wizard dictionary.
|
||||
Custom type without chapters, but with scenes.
|
||||
"""
|
||||
projFile = path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = path.join(nwTempProj, "5_nwProject.nwx")
|
||||
refFile = path.join(nwRef, "proj", "5_nwProject.nwx")
|
||||
projFile = os.path.join(nwFuncTemp, "nwProject.nwx")
|
||||
testFile = os.path.join(nwTempProj, "5_nwProject.nwx")
|
||||
refFile = os.path.join(nwRef, "proj", "5_nwProject.nwx")
|
||||
|
||||
projData = {
|
||||
"projName": "Test Custom",
|
||||
@@ -200,9 +201,9 @@ def testProjectNewCustomB(nwFuncTemp, nwTempProj, nwRef, nwDummy):
|
||||
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
||||
|
||||
@pytest.mark.project
|
||||
def testProjectNewSample(nwFuncTemp, nwRef, nwConf, nwDummy):
|
||||
def testProjectNewSampleA(nwFuncTemp, nwConf, nwDummy, nwTemp):
|
||||
"""Check that we can create a new project can be created from the
|
||||
provided sample project.
|
||||
provided sample project via a zip file.
|
||||
"""
|
||||
projData = {
|
||||
"projName": "Test Sample",
|
||||
@@ -217,11 +218,99 @@ def testProjectNewSample(nwFuncTemp, nwRef, nwConf, nwDummy):
|
||||
theProject.projTree.setSeed(42)
|
||||
theProject.mainConf = nwConf
|
||||
|
||||
# Sample set, but no path
|
||||
assert not theProject.newProject({"popSample": True})
|
||||
|
||||
# Force the lookup path for assets to our temp folder
|
||||
srcSample = os.path.abspath(os.path.join(nwConf.appRoot, "sample"))
|
||||
dstSample = os.path.join(nwTemp, "sample.zip")
|
||||
nwConf.assetPath = nwTemp
|
||||
|
||||
# Create and open a defective zip file
|
||||
with open(dstSample, mode="w+") as outFile:
|
||||
outFile.write("foo")
|
||||
|
||||
assert not theProject.newProject(projData)
|
||||
os.unlink(dstSample)
|
||||
|
||||
# Create a real zip file, and unpack it
|
||||
with ZipFile(dstSample, "w") as zipObj:
|
||||
zipObj.write(os.path.join(srcSample, "nwProject.nwx"), "nwProject.nwx")
|
||||
for docFile in os.listdir(os.path.join(srcSample, "content")):
|
||||
srcDoc = os.path.join(srcSample, "content", docFile)
|
||||
zipObj.write(srcDoc, "content/"+docFile)
|
||||
|
||||
assert theProject.newProject(projData)
|
||||
assert theProject.openProject(nwFuncTemp)
|
||||
assert theProject.projName == "Sample Project"
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
os.unlink(dstSample)
|
||||
|
||||
@pytest.mark.project
|
||||
def testProjectNewSampleB(monkeypatch, nwFuncTemp, nwConf, nwDummy, nwTemp):
|
||||
"""Check that we can create a new project can be created from the
|
||||
provided sample project folder.
|
||||
"""
|
||||
projData = {
|
||||
"projName": "Test Sample",
|
||||
"projTitle": "Test Novel",
|
||||
"projAuthors": "Jane Doe\nJohn Doh\n",
|
||||
"projPath": nwFuncTemp,
|
||||
"popSample": True,
|
||||
"popMinimal": False,
|
||||
"popCustom": False,
|
||||
}
|
||||
theProject = NWProject(nwDummy)
|
||||
theProject.projTree.setSeed(42)
|
||||
theProject.mainConf = nwConf
|
||||
|
||||
# Make sure we do not pick up the nw/assets/sample.zip file
|
||||
nwConf.assetPath = nwTemp
|
||||
|
||||
# Set a fake project file name
|
||||
monkeypatch.setattr(nwFiles, "PROJ_FILE", "nothing.nwx")
|
||||
assert not theProject.newProject(projData)
|
||||
|
||||
monkeypatch.setattr(nwFiles, "PROJ_FILE", "nwProject.nwx")
|
||||
assert theProject.newProject(projData)
|
||||
assert theProject.openProject(nwFuncTemp)
|
||||
assert theProject.projName == "Sample Project"
|
||||
assert theProject.saveProject()
|
||||
assert theProject.closeProject()
|
||||
|
||||
# Misdirect the appRoot path so neither is possible
|
||||
nwConf.appRoot = nwTemp
|
||||
assert not theProject.newProject(projData)
|
||||
|
||||
@pytest.mark.project
|
||||
def testProjectMethods(monkeypatch, nwMinimal, nwDummy):
|
||||
"""Test other project class methods and functions.
|
||||
"""
|
||||
theProject = NWProject(nwDummy)
|
||||
theProject.projTree.setSeed(42)
|
||||
assert theProject.openProject(nwMinimal)
|
||||
assert theProject.projPath == nwMinimal
|
||||
|
||||
# Setting project path
|
||||
assert theProject.setProjectPath(None)
|
||||
assert theProject.projPath is None
|
||||
assert theProject.setProjectPath("")
|
||||
assert theProject.projPath is None
|
||||
assert theProject.setProjectPath("~")
|
||||
assert theProject.projPath == os.path.expanduser("~")
|
||||
|
||||
# Create a new folder and populate it
|
||||
projPath = os.path.join(nwMinimal, "dummy1")
|
||||
assert theProject.setProjectPath(projPath, newProject=True)
|
||||
|
||||
# Make the os.mkdir fail
|
||||
def altMkdir(*args):
|
||||
raise Exception("Oops!")
|
||||
|
||||
monkeypatch.setattr("os.mkdir", altMkdir)
|
||||
projPath = os.path.join(nwMinimal, "dummy2")
|
||||
assert not theProject.setProjectPath(projPath, newProject=True)
|
||||
|
||||
@pytest.mark.project
|
||||
def testDocMeta(nwDummy, nwLipsum):
|
||||
@@ -252,7 +341,7 @@ def testDocMeta(nwDummy, nwLipsum):
|
||||
|
||||
@pytest.mark.project
|
||||
def testSpellEnchant(nwTemp, nwConf):
|
||||
wList = path.join(nwTemp, "wordlist.txt")
|
||||
wList = os.path.join(nwTemp, "wordlist.txt")
|
||||
with open(wList, mode="w") as wFile:
|
||||
wFile.write("a_word\nb_word\nc_word\n")
|
||||
|
||||
@@ -277,7 +366,7 @@ def testSpellEnchant(nwTemp, nwConf):
|
||||
|
||||
@pytest.mark.project
|
||||
def testSpellSimple(nwTemp, nwConf):
|
||||
wList = path.join(nwTemp, "wordlist.txt")
|
||||
wList = os.path.join(nwTemp, "wordlist.txt")
|
||||
with open(wList, mode="w") as wFile:
|
||||
wFile.write("a_word\nb_word\nc_word\n")
|
||||
|
||||
@@ -320,7 +409,7 @@ def testProjectOptions(nwDummy, nwLipsum):
|
||||
assert str(theOpts.theState) == r"{}"
|
||||
|
||||
# Read Invalid Settings and Filter
|
||||
stateFile = path.join(theProject.projMeta, nwFiles.OPTS_FILE)
|
||||
stateFile = os.path.join(theProject.projMeta, nwFiles.OPTS_FILE)
|
||||
with open(stateFile, mode="w", encoding="utf8") as outFile:
|
||||
outFile.write(
|
||||
r'{"GuiProjectSettings": {"winWidth": 100, "winHeight": 50}, "NoGroup": {"NoName": 0}}'
|
||||
@@ -376,28 +465,28 @@ def testProjectOrphanedFiles(nwDummy, nwLipsum):
|
||||
assert theProject.closeProject()
|
||||
|
||||
# First Item with Meta Data
|
||||
orphPath = path.join(nwLipsum, "content", "636b6aa9b697b.nwd")
|
||||
orphPath = os.path.join(nwLipsum, "content", "636b6aa9b697b.nwd")
|
||||
with open(orphPath, mode="w", encoding="utf8") as outFile:
|
||||
outFile.write(r"%%~ 5eaea4e8cdee8:15c4492bd5107:WORLD:NOTE:Mars")
|
||||
outFile.write("\n")
|
||||
|
||||
# Second Item without Meta Data
|
||||
orphPath = path.join(nwLipsum, "content", "736b6aa9b697b.nwd")
|
||||
orphPath = os.path.join(nwLipsum, "content", "736b6aa9b697b.nwd")
|
||||
with open(orphPath, mode="w", encoding="utf8") as outFile:
|
||||
outFile.write("\n")
|
||||
|
||||
# Invalid File Name
|
||||
dummyPath = path.join(nwLipsum, "content", "636b6aa9b697b.txt")
|
||||
dummyPath = os.path.join(nwLipsum, "content", "636b6aa9b697b.txt")
|
||||
with open(dummyPath, mode="w", encoding="utf8") as outFile:
|
||||
outFile.write("\n")
|
||||
|
||||
# Invalid File Name
|
||||
dummyPath = path.join(nwLipsum, "content", "636b6aa9b697bb.nwd")
|
||||
dummyPath = os.path.join(nwLipsum, "content", "636b6aa9b697bb.nwd")
|
||||
with open(dummyPath, mode="w", encoding="utf8") as outFile:
|
||||
outFile.write("\n")
|
||||
|
||||
# Invalid File Name
|
||||
dummyPath = path.join(nwLipsum, "content", "abcdefghijklm.nwd")
|
||||
dummyPath = os.path.join(nwLipsum, "content", "abcdefghijklm.nwd")
|
||||
with open(dummyPath, mode="w", encoding="utf8") as outFile:
|
||||
outFile.write("\n")
|
||||
|
||||
@@ -441,84 +530,84 @@ def testProjectOldFormat(nwDummy, nwOldProj):
|
||||
|
||||
# Create dummy files for known legacy files
|
||||
deleteFiles = [
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.0"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.1"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.2"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.3"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.4"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.5"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.6"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.7"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.8"),
|
||||
path.join(nwOldProj, "cache", "nwProject.nwx.9"),
|
||||
path.join(nwOldProj, "meta", "mainOptions.json"),
|
||||
path.join(nwOldProj, "meta", "exportOptions.json"),
|
||||
path.join(nwOldProj, "meta", "outlineOptions.json"),
|
||||
path.join(nwOldProj, "meta", "timelineOptions.json"),
|
||||
path.join(nwOldProj, "meta", "docMergeOptions.json"),
|
||||
path.join(nwOldProj, "meta", "sessionLogOptions.json"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.0"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.1"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.2"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.3"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.4"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.5"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.6"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.7"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.8"),
|
||||
os.path.join(nwOldProj, "cache", "nwProject.nwx.9"),
|
||||
os.path.join(nwOldProj, "meta", "mainOptions.json"),
|
||||
os.path.join(nwOldProj, "meta", "exportOptions.json"),
|
||||
os.path.join(nwOldProj, "meta", "outlineOptions.json"),
|
||||
os.path.join(nwOldProj, "meta", "timelineOptions.json"),
|
||||
os.path.join(nwOldProj, "meta", "docMergeOptions.json"),
|
||||
os.path.join(nwOldProj, "meta", "sessionLogOptions.json"),
|
||||
]
|
||||
|
||||
# Add some files that shouldn't be there
|
||||
deleteFiles.append(path.join(nwOldProj, "data_f", "whatnow.nwd"))
|
||||
deleteFiles.append(path.join(nwOldProj, "data_f", "whatnow.txt"))
|
||||
deleteFiles.append(os.path.join(nwOldProj, "data_f", "whatnow.nwd"))
|
||||
deleteFiles.append(os.path.join(nwOldProj, "data_f", "whatnow.txt"))
|
||||
|
||||
# Add some folders that shouldn't be there
|
||||
mkdir(path.join(nwOldProj, "stuff"))
|
||||
mkdir(path.join(nwOldProj, "data_1", "stuff"))
|
||||
os.mkdir(os.path.join(nwOldProj, "stuff"))
|
||||
os.mkdir(os.path.join(nwOldProj, "data_1", "stuff"))
|
||||
|
||||
# Create dummy files
|
||||
mkdir(path.join(nwOldProj, "cache"))
|
||||
os.mkdir(os.path.join(nwOldProj, "cache"))
|
||||
for aFile in deleteFiles:
|
||||
with open(aFile, mode="w+", encoding="utf8") as outFile:
|
||||
outFile.write("Hi")
|
||||
for aFile in deleteFiles:
|
||||
assert path.isfile(aFile)
|
||||
assert os.path.isfile(aFile)
|
||||
|
||||
# Open project and check that files that are not supposed to be
|
||||
# there have been removed
|
||||
assert theProject.openProject(nwOldProj)
|
||||
for aFile in deleteFiles:
|
||||
assert not path.isfile(aFile)
|
||||
assert not os.path.isfile(aFile)
|
||||
|
||||
assert not path.isdir(path.join(nwOldProj, "data_1", "stuff"))
|
||||
assert not path.isdir(path.join(nwOldProj, "data_1"))
|
||||
assert not path.isdir(path.join(nwOldProj, "data_7"))
|
||||
assert not path.isdir(path.join(nwOldProj, "data_8"))
|
||||
assert not path.isdir(path.join(nwOldProj, "data_9"))
|
||||
assert not path.isdir(path.join(nwOldProj, "data_a"))
|
||||
assert not path.isdir(path.join(nwOldProj, "data_f"))
|
||||
assert not os.path.isdir(os.path.join(nwOldProj, "data_1", "stuff"))
|
||||
assert not os.path.isdir(os.path.join(nwOldProj, "data_1"))
|
||||
assert not os.path.isdir(os.path.join(nwOldProj, "data_7"))
|
||||
assert not os.path.isdir(os.path.join(nwOldProj, "data_8"))
|
||||
assert not os.path.isdir(os.path.join(nwOldProj, "data_9"))
|
||||
assert not os.path.isdir(os.path.join(nwOldProj, "data_a"))
|
||||
assert not os.path.isdir(os.path.join(nwOldProj, "data_f"))
|
||||
|
||||
# Check stuff that has been moved
|
||||
assert path.isdir(path.join(nwOldProj, "junk"))
|
||||
assert path.isdir(path.join(nwOldProj, "junk", "stuff"))
|
||||
assert path.isfile(path.join(nwOldProj, "junk", "whatnow.nwd"))
|
||||
assert path.isfile(path.join(nwOldProj, "junk", "whatnow.txt"))
|
||||
assert os.path.isdir(os.path.join(nwOldProj, "junk"))
|
||||
assert os.path.isdir(os.path.join(nwOldProj, "junk", "stuff"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "junk", "whatnow.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "junk", "whatnow.txt"))
|
||||
|
||||
# Check that files we want to keep are in the right place
|
||||
assert path.isdir(path.join(nwOldProj, "cache"))
|
||||
assert path.isdir(path.join(nwOldProj, "content"))
|
||||
assert path.isdir(path.join(nwOldProj, "meta"))
|
||||
assert os.path.isdir(os.path.join(nwOldProj, "cache"))
|
||||
assert os.path.isdir(os.path.join(nwOldProj, "content"))
|
||||
assert os.path.isdir(os.path.join(nwOldProj, "meta"))
|
||||
|
||||
assert path.isfile(path.join(nwOldProj, "content", "f528d831f5b24.nwd"))
|
||||
assert path.isfile(path.join(nwOldProj, "content", "88124a4292d8b.nwd"))
|
||||
assert path.isfile(path.join(nwOldProj, "content", "91239bf2f8b69.nwd"))
|
||||
assert path.isfile(path.join(nwOldProj, "content", "19752e7f9d8af.nwd"))
|
||||
assert path.isfile(path.join(nwOldProj, "content", "a764d5acf5a21.nwd"))
|
||||
assert path.isfile(path.join(nwOldProj, "content", "9058ae29f0dfd.nwd"))
|
||||
assert path.isfile(path.join(nwOldProj, "content", "7ff63b8afc4cd.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "content", "f528d831f5b24.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "content", "88124a4292d8b.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "content", "91239bf2f8b69.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "content", "19752e7f9d8af.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "content", "a764d5acf5a21.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "content", "9058ae29f0dfd.nwd"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "content", "7ff63b8afc4cd.nwd"))
|
||||
|
||||
assert path.isfile(path.join(nwOldProj, "meta", "tagsIndex.json"))
|
||||
assert path.isfile(path.join(nwOldProj, "meta", "sessionInfo.log"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "meta", "tagsIndex.json"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "meta", "sessionInfo.log"))
|
||||
|
||||
# Close the project
|
||||
theProject.closeProject()
|
||||
|
||||
# Check that new files have been created
|
||||
assert path.isfile(path.join(nwOldProj, "meta", "guiOptions.json"))
|
||||
assert path.isfile(path.join(nwOldProj, "meta", "sessionStats.log"))
|
||||
assert path.isfile(path.join(nwOldProj, "ToC.json"))
|
||||
assert path.isfile(path.join(nwOldProj, "ToC.txt"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "meta", "guiOptions.json"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "meta", "sessionStats.log"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "ToC.json"))
|
||||
assert os.path.isfile(os.path.join(nwOldProj, "ToC.txt"))
|
||||
|
||||
@pytest.mark.project
|
||||
def testProjectBackup(nwDummy, nwMinimal, nwTemp):
|
||||
@@ -541,7 +630,7 @@ def testProjectBackup(nwDummy, nwMinimal, nwTemp):
|
||||
assert not theProject.zipIt(doNotify=False)
|
||||
|
||||
# Non-existent folder
|
||||
theProject.mainConf.backupPath = path.join(nwTemp, "nonexistent")
|
||||
theProject.mainConf.backupPath = os.path.join(nwTemp, "nonexistent")
|
||||
theProject.projName = "Test Minimal"
|
||||
assert not theProject.zipIt(doNotify=False)
|
||||
|
||||
@@ -553,7 +642,7 @@ def testProjectBackup(nwDummy, nwMinimal, nwTemp):
|
||||
theProject.mainConf.backupPath = nwTemp
|
||||
assert theProject.zipIt(doNotify=False)
|
||||
|
||||
theFiles = listdir(path.join(nwTemp, "Test Minimal"))
|
||||
theFiles = os.listdir(os.path.join(nwTemp, "Test Minimal"))
|
||||
assert len(theFiles) == 1
|
||||
|
||||
theZip = theFiles[0]
|
||||
@@ -561,10 +650,10 @@ def testProjectBackup(nwDummy, nwMinimal, nwTemp):
|
||||
assert theZip[-4:] == ".zip"
|
||||
|
||||
# Extract the archive
|
||||
with ZipFile(path.join(nwTemp, "Test Minimal", theZip), "r") as inZip:
|
||||
inZip.extractall(path.join(nwTemp, "extract"))
|
||||
with ZipFile(os.path.join(nwTemp, "Test Minimal", theZip), "r") as inZip:
|
||||
inZip.extractall(os.path.join(nwTemp, "extract"))
|
||||
|
||||
# Check that the main project file was restored
|
||||
assert cmpFiles(
|
||||
path.join(nwMinimal, "nwProject.nwx"), path.join(nwTemp, "extract", "nwProject.nwx")
|
||||
os.path.join(nwMinimal, "nwProject.nwx"), os.path.join(nwTemp, "extract", "nwProject.nwx")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user