New test for NWDoc class

This commit is contained in:
Veronica K. B. Olsen
2020-12-01 22:19:18 +01:00
parent 2018d44ba8
commit 8cc6fa6030
6 changed files with 218 additions and 93 deletions
+61 -61
View File
@@ -72,68 +72,8 @@ def dummyGUI(tmpConf):
theDummy.mainConf = tmpConf
return theDummy
# =============================================================================================== #
##
# novelWriter Objects
##
@pytest.fixture(scope="session")
def nwConf(refDir, tmpDir):
"""Temporary novelWriter configuration used for the dummy instance
of novelWriter's main GUI.
"""
theConf = Config()
theConf.initConfig(refDir, tmpDir)
return theConf
##
# Temporary Test Folders
##
@pytest.fixture(scope="session")
def nwTempProj(tmpDir):
"""A temporary folder for project tests.
"""
projDir = os.path.join(tmpDir, "proj")
if not os.path.isdir(projDir):
os.mkdir(projDir)
return projDir
@pytest.fixture(scope="session")
def nwTempGUI(tmpDir):
"""A temporary folder for GUI tests.
"""
guiDir = os.path.join(tmpDir, "gui")
if not os.path.isdir(guiDir):
os.mkdir(guiDir)
return guiDir
@pytest.fixture(scope="session")
def nwTempBuild(tmpDir):
"""A temporary folder for build tests.
"""
buildDir = os.path.join(tmpDir, "build")
if not os.path.isdir(buildDir):
os.mkdir(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
##
# Temp Folders for Projects
# Temp Project Folders
##
@pytest.fixture(scope="function")
@@ -215,3 +155,63 @@ def yesToAll(monkeypatch):
QMessageBox, "critical", lambda *args, **kwargs: QMessageBox.Yes
)
return
# =============================================================================================== #
##
# novelWriter Objects
##
@pytest.fixture(scope="session")
def nwConf(refDir, tmpDir):
"""Temporary novelWriter configuration used for the dummy instance
of novelWriter's main GUI.
"""
theConf = Config()
theConf.initConfig(refDir, tmpDir)
return theConf
##
# Temporary Test Folders
##
@pytest.fixture(scope="session")
def nwTempProj(tmpDir):
"""A temporary folder for project tests.
"""
projDir = os.path.join(tmpDir, "proj")
if not os.path.isdir(projDir):
os.mkdir(projDir)
return projDir
@pytest.fixture(scope="session")
def nwTempGUI(tmpDir):
"""A temporary folder for GUI tests.
"""
guiDir = os.path.join(tmpDir, "gui")
if not os.path.isdir(guiDir):
os.mkdir(guiDir)
return guiDir
@pytest.fixture(scope="session")
def nwTempBuild(tmpDir):
"""A temporary folder for build tests.
"""
buildDir = os.path.join(tmpDir, "build")
if not os.path.isdir(buildDir):
os.mkdir(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