Fix tests for variable change, and change monkeypatches to use the context manager

This commit is contained in:
Veronica K. B. Olsen
2021-02-18 19:21:46 +01:00
parent 8b0ac6e81e
commit e4d03f9581
28 changed files with 274 additions and 296 deletions
+16 -2
View File
@@ -121,17 +121,31 @@ def tmpConf(tmpDir):
return theConf
@pytest.fixture(scope="function")
def dummyGUI(tmpConf):
def fncConf(fncDir):
"""Create a temporary novelWriter configuration object.
"""
confFile = os.path.join(fncDir, "novelwriter.conf")
if os.path.isfile(confFile):
os.unlink(confFile)
theConf = Config()
theConf.initConfig(fncDir, fncDir)
theConf.setLastPath("")
return theConf
@pytest.fixture(scope="function")
def dummyGUI(monkeypatch, tmpConf):
"""Create a dummy instance of novelWriter's main GUI class.
"""
monkeypatch.setattr("nw.CONFIG", tmpConf)
theDummy = DummyMain()
theDummy.mainConf = tmpConf
return theDummy
@pytest.fixture(scope="function")
def nwGUI(qtbot, fncDir):
def nwGUI(qtbot, monkeypatch, fncDir, fncConf):
"""Create an instance of the novelWriter GUI.
"""
monkeypatch.setattr("nw.CONFIG", fncConf)
nwGUI = nw.main(["--testmode", "--config=%s" % fncDir, "--data=%s" % fncDir])
qtbot.addWidget(nwGUI)
nwGUI.show()