From 83a9c6660fb05b1d153108e7cd01b2759ad9960e Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 18 May 2019 13:39:15 +0200 Subject: [PATCH 1/5] Added cursor position to item class. --- nw/project/item.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nw/project/item.py b/nw/project/item.py index b41342c9..7ea631ac 100644 --- a/nw/project/item.py +++ b/nw/project/item.py @@ -38,9 +38,11 @@ class NWItem(): self.itemStatus = 0 self.isExpanded = False + # Document Meta Data self.charCount = 0 self.wordCount = 0 self.paraCount = 0 + self.cursorPos = 0 return @@ -64,6 +66,7 @@ class NWItem(): xSub = self._subPack(xPack,"charCount", text=str(self.charCount), none=False) xSub = self._subPack(xPack,"wordCount", text=str(self.wordCount), none=False) xSub = self._subPack(xPack,"paraCount", text=str(self.paraCount), none=False) + xSub = self._subPack(xPack,"cursorPos", text=str(self.cursorPos), none=False) return xPack def _subPack(self, xParent, name, attrib=None, text=None, none=True): @@ -90,6 +93,7 @@ class NWItem(): elif tagName == "charCount": self.setCharCount(tagValue) elif tagName == "wordCount": self.setWordCount(tagValue) elif tagName == "paraCount": self.setParaCount(tagValue) + elif tagName == "cursorPos": self.setCursorPos(tagValue) else: logger.error("Unknown tag '%s'" % tagName) return @@ -166,7 +170,7 @@ class NWItem(): return ## - # Set Stats + # Set Document Meta Data ## def setCharCount(self, theCount): @@ -184,4 +188,9 @@ class NWItem(): self.paraCount = theCount return + def setCursorPos(self, thePosition): + thePosition = checkInt(thePosition,0) + self.cursorPos = thePosition + return + # END Class NWItem From cb71da5200f4d86af1779561948cf3b53be58b5e Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 18 May 2019 13:43:49 +0200 Subject: [PATCH 2/5] Move around the class methods a bit --- nw/gui/doceditor.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 0f5ded96..ec1802aa 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -100,7 +100,7 @@ class GuiDocEditor(QTextEdit): return ## - # Class Methods + # Setters and Getters ## def setDocumentChanged(self, bValue): @@ -116,6 +116,14 @@ class GuiDocEditor(QTextEdit): self.setDocumentChanged(False) return True + def getText(self): + theText = self.toPlainText() + return theText + + ## + # Spell Checking + ## + def setPwl(self, pwlFile): if pwlFile is not None: self.pwlFile = pwlFile @@ -134,9 +142,13 @@ class GuiDocEditor(QTextEdit): self.rehighlightDocument() return True - def getText(self): - theText = self.toPlainText() - return theText + def rehighlightDocument(self): + self.hLight.rehighlight() + return + + ## + # General Class Methods + ## def changeWidth(self): """Automatically adjust the margins so the text is centred, but only if Config.textFixedW is @@ -169,10 +181,6 @@ class GuiDocEditor(QTextEdit): return False return True - def rehighlightDocument(self): - self.hLight.rehighlight() - return - ## # Document Events and Maintenance ## From 19b2521b73ffe5c6795bddeeb5fc4d283a23f86b Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 18 May 2019 13:52:45 +0200 Subject: [PATCH 3/5] Cursor position is now saved and loaded with the document. --- nw/gui/doceditor.py | 10 ++++++++++ nw/gui/winmain.py | 4 ++++ sample/sampleNovel/data_6/36b6aa9b697b_main.nwd | 2 +- sample/sampleNovel/nwProject.nwx | 13 +++++++++++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index ec1802aa..ad90fe13 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -120,6 +120,16 @@ class GuiDocEditor(QTextEdit): theText = self.toPlainText() return theText + def setCursorPosition(self, thePosition): + theCursor = self.textCursor() + theCursor.setPosition(thePosition) + self.setTextCursor(theCursor) + return True + + def getCursorPosition(self): + theCursor = self.textCursor() + return theCursor.position() + ## # Spell Checking ## diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 87386287..72aa6977 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -206,15 +206,19 @@ class GuiMain(QMainWindow): self.saveDocument() self.stackPane.setCurrentIndex(self.stackDoc) self.docEditor.setText(self.theDocument.openDocument(tHandle)) + self.docEditor.setCursorPosition(self.theDocument.theItem.cursorPos) self.docEditor.changeWidth() + self.docEditor.setFocus() return True def saveDocument(self): if self.theDocument.theItem is not None: docHtml = self.docEditor.getText() + cursPos = self.docEditor.getCursorPosition() self.theDocument.theItem.setCharCount(self.docEditor.charCount) self.theDocument.theItem.setWordCount(self.docEditor.wordCount) self.theDocument.theItem.setParaCount(self.docEditor.paraCount) + self.theDocument.theItem.setCursorPos(cursPos) self.theDocument.saveDocument(docHtml) self.docEditor.setDocumentChanged(False) return True diff --git a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd index a185866f..8c9d288a 100644 --- a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd +++ b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd @@ -13,7 +13,7 @@ Some text here would look good as well, and maybe some "dialogue"? So, this is some __text__ that we’ve been adding to this document. It is utterly meaningless text, _but_ since this is just dummy text, that doesn’t really matter. The text is perfectly happy to live in this document reggardless. -This paragraph is also meaningless. At least a bit. +This paragraph is also meaningless. At least a bit. # ## diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 30997158..acaad669 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -27,6 +27,7 @@ 23 5 1 + 0 Some Chapter @@ -45,6 +46,7 @@ 2571 377 5 + 0 File With Stuff @@ -53,9 +55,10 @@ 1 False SCENE - 417 + 405 71 5 + 421 New File @@ -67,6 +70,7 @@ 69 17 1 + 0 Characters @@ -92,6 +96,7 @@ 42 8 1 + 0 Jane Smith @@ -103,6 +108,7 @@ 51 9 1 + 0 Locations @@ -121,6 +127,7 @@ 66 13 1 + 0 Trash @@ -139,6 +146,7 @@ 0 0 0 + 0 New File @@ -150,6 +158,7 @@ 0 0 0 + 0 From 2768c46976e6b85be9f14550255e755fbd1af198 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 18 May 2019 15:02:58 +0200 Subject: [PATCH 4/5] Updated tests and added a better way to save temp files --- tests/conftest.py | 36 +++++++++++++ .../1_1489056e0916_main.nwd} | 0 .../1_nwProject.nwx} | 3 +- .../2_nwProject.nwx} | 3 +- .../3_nwProject.nwx} | 3 +- tests/reference/novelwriter.conf | 8 +-- .../1_nwProject.nwx} | 3 +- .../2_nwProject.nwx} | 1 + tests/test_config.py | 44 ++++++++-------- tests/test_gui.py | 50 ++++++++----------- tests/test_project.py | 40 +++++++-------- 11 files changed, 111 insertions(+), 80 deletions(-) create mode 100644 tests/conftest.py rename tests/reference/{gui_1489056e0916_main.nwd => gui/1_1489056e0916_main.nwd} (100%) rename tests/reference/{gui_nwProject.nwx => gui/1_nwProject.nwx} (96%) rename tests/reference/{projedit_nwProject.nwx => gui/2_nwProject.nwx} (97%) rename tests/reference/{itemedit_nwProject.nwx => gui/3_nwProject.nwx} (96%) rename tests/reference/{new_nwProject.nwx => proj/1_nwProject.nwx} (93%) rename tests/reference/{roots_nwProject.nwx => proj/2_nwProject.nwx} (98%) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..830b620c --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +"""novelWriter Test Config +""" + +import pytest, shutil +from os import path, mkdir + +@pytest.fixture(scope="session") +def nwTemp(): + testDir = path.dirname(__file__) + tempDir = path.join(testDir,"temp") + if path.isdir(tempDir): + shutil.rmtree(tempDir) + if not path.isdir(tempDir): + mkdir(tempDir) + return tempDir + +@pytest.fixture(scope="session") +def nwTempProj(nwTemp): + projDir = path.join(nwTemp,"proj") + if not path.isdir(projDir): + mkdir(projDir) + return projDir + +@pytest.fixture(scope="session") +def nwTempGUI(nwTemp): + guiDir = path.join(nwTemp,"gui") + if not path.isdir(guiDir): + mkdir(guiDir) + return guiDir + +@pytest.fixture(scope="session") +def nwRef(): + testDir = path.dirname(__file__) + refDir = path.join(testDir,"reference") + return refDir diff --git a/tests/reference/gui_1489056e0916_main.nwd b/tests/reference/gui/1_1489056e0916_main.nwd similarity index 100% rename from tests/reference/gui_1489056e0916_main.nwd rename to tests/reference/gui/1_1489056e0916_main.nwd diff --git a/tests/reference/gui_nwProject.nwx b/tests/reference/gui/1_nwProject.nwx similarity index 96% rename from tests/reference/gui_nwProject.nwx rename to tests/reference/gui/1_nwProject.nwx index 80caebae..75ab919f 100644 --- a/tests/reference/gui_nwProject.nwx +++ b/tests/reference/gui/1_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -32,6 +32,7 @@ 0 0 0 + 0 Characters diff --git a/tests/reference/projedit_nwProject.nwx b/tests/reference/gui/2_nwProject.nwx similarity index 97% rename from tests/reference/projedit_nwProject.nwx rename to tests/reference/gui/2_nwProject.nwx index 2cd49256..74949967 100644 --- a/tests/reference/projedit_nwProject.nwx +++ b/tests/reference/gui/2_nwProject.nwx @@ -1,5 +1,5 @@ - + Project Name Project Title @@ -34,6 +34,7 @@ 0 0 0 + 0 Characters diff --git a/tests/reference/itemedit_nwProject.nwx b/tests/reference/gui/3_nwProject.nwx similarity index 96% rename from tests/reference/itemedit_nwProject.nwx rename to tests/reference/gui/3_nwProject.nwx index b55ba18e..632419cb 100644 --- a/tests/reference/itemedit_nwProject.nwx +++ b/tests/reference/gui/3_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -32,6 +32,7 @@ 0 0 0 + 0 Characters diff --git a/tests/reference/novelwriter.conf b/tests/reference/novelwriter.conf index 00e800be..645ec486 100644 --- a/tests/reference/novelwriter.conf +++ b/tests/reference/novelwriter.conf @@ -1,10 +1,10 @@ [Main] -timestamp = 2019-05-12 12:04:16 +timestamp = 2019-05-18 15:02:22 [Sizes] geometry = 1100, 650 -treecols = 120, 30, 50 -mainpane = 300, 800 +treecols = 120, 30, 129 +mainpane = 299, 797 [Project] autosaveproject = 60 @@ -25,7 +25,7 @@ repdots = True spellcheck = en_GB [Path] -recent0 = +recent0 = /home/vkbo/Code/novelWriter/tests/temp/gui recent1 = recent2 = recent3 = diff --git a/tests/reference/new_nwProject.nwx b/tests/reference/proj/1_nwProject.nwx similarity index 93% rename from tests/reference/new_nwProject.nwx rename to tests/reference/proj/1_nwProject.nwx index e9a65102..91f8998d 100644 --- a/tests/reference/new_nwProject.nwx +++ b/tests/reference/proj/1_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -53,6 +53,7 @@ 0 0 0 + 0 diff --git a/tests/reference/roots_nwProject.nwx b/tests/reference/proj/2_nwProject.nwx similarity index 98% rename from tests/reference/roots_nwProject.nwx rename to tests/reference/proj/2_nwProject.nwx index 8cad23c9..8a101717 100644 --- a/tests/reference/roots_nwProject.nwx +++ b/tests/reference/proj/2_nwProject.nwx @@ -53,6 +53,7 @@ 0 0 0 + 0 Timeline diff --git a/tests/test_config.py b/tests/test_config.py index 4301886a..528b7dcf 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,40 +4,34 @@ import nw, pytest from nwtools import * -from os import path, unlink +from os import path from nw.config import Config -theConf = Config() -testDir = path.dirname(__file__) -testTemp = path.join(testDir,"temp") -testRef = path.join(testDir,"reference") -tmpConf = path.join(testTemp,"novelwriter.conf") -refConf = path.join(testRef, "novelwriter.conf") - -ensureDir(testTemp) - -# Clean out old stuff -if path.isfile(tmpConf): - unlink(tmpConf) +theConf = Config() @pytest.mark.core -def testConfigInit(): - assert theConf.initConfig(testTemp) +def testConfigInit(nwTemp,nwRef): + tmpConf = path.join(nwTemp,"novelwriter.conf") + refConf = path.join(nwRef, "novelwriter.conf") + assert theConf.initConfig(nwTemp) assert cmpFiles(tmpConf, refConf, [2]) assert not theConf.confChanged @pytest.mark.core -def testConfigSave(): +def testConfigSave(nwTemp,nwRef): + tmpConf = path.join(nwTemp,"novelwriter.conf") + refConf = path.join(nwRef, "novelwriter.conf") + assert theConf.confPath == nwTemp assert theConf.saveConfig() assert cmpFiles(tmpConf, refConf, [2]) assert not theConf.confChanged @pytest.mark.core -def testConfigSetConfPath(): +def testConfigSetConfPath(nwTemp): assert theConf.setConfPath(None) assert not theConf.setConfPath(path.join("somewhere","over","the","rainbow")) - assert theConf.setConfPath(path.join(testTemp,"novelwriter.conf")) - assert theConf.confPath == testTemp + assert theConf.setConfPath(path.join(nwTemp,"novelwriter.conf")) + assert theConf.confPath == nwTemp assert theConf.confFile == "novelwriter.conf" assert not theConf.confChanged @@ -47,7 +41,9 @@ def testConfigLoad(): assert not theConf.confChanged @pytest.mark.core -def testConfigSetWinSize(): +def testConfigSetWinSize(nwTemp,nwRef): + tmpConf = path.join(nwTemp,"novelwriter.conf") + refConf = path.join(nwRef, "novelwriter.conf") assert theConf.setWinSize(1105, 655) assert not theConf.confChanged assert theConf.setWinSize(70,70) @@ -58,7 +54,9 @@ def testConfigSetWinSize(): assert not theConf.confChanged @pytest.mark.core -def testConfigSetTreeColWidths(): +def testConfigSetTreeColWidths(nwTemp,nwRef): + tmpConf = path.join(nwTemp,"novelwriter.conf") + refConf = path.join(nwRef, "novelwriter.conf") assert theConf.setTreeColWidths([0, 0, 0]) assert theConf.confChanged assert theConf.setTreeColWidths([120, 30, 50]) @@ -67,7 +65,9 @@ def testConfigSetTreeColWidths(): assert not theConf.confChanged @pytest.mark.core -def testConfigSetMainPanePos(): +def testConfigSetMainPanePos(nwTemp,nwRef): + tmpConf = path.join(nwTemp,"novelwriter.conf") + refConf = path.join(nwRef, "novelwriter.conf") assert theConf.setMainPanePos([0, 0]) assert theConf.confChanged assert theConf.setMainPanePos([300, 800]) diff --git a/tests/test_gui.py b/tests/test_gui.py index c5584edf..a1154398 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -14,14 +14,10 @@ from nw.enum import * keyDelay = 10 stepDelay = 50 -testDir = path.dirname(__file__) -testRef = path.join(testDir,"reference") @pytest.mark.gui -def testMainWindows(qtbot, tmpdir): - confDir = str(tmpdir.mkdir("conf")) - projDir = str(tmpdir.mkdir("project")) - nwGUI = nw.main(["--testmode","--config=%s" % confDir]) +def testMainWindows(qtbot, nwTempGUI, nwRef): + nwGUI = nw.main(["--testmode","--config=%s" % nwRef]) qtbot.addWidget(nwGUI) nwGUI.show() qtbot.waitForWindowShown(nwGUI) @@ -29,12 +25,12 @@ def testMainWindows(qtbot, tmpdir): # Create new, save, open project nwGUI.theProject.handleSeed = 42 - assert nwGUI.theProject.setProjectPath(projDir) + assert nwGUI.theProject.setProjectPath(nwTempGUI) assert nwGUI.newProject() - assert nwGUI.theProject.setProjectPath(projDir) + assert nwGUI.theProject.setProjectPath(nwTempGUI) assert nwGUI.saveProject() qtbot.wait(stepDelay) - assert nwGUI.openProject(projDir) + assert nwGUI.openProject(nwTempGUI) qtbot.wait(stepDelay) # Check that tree items have been created @@ -108,18 +104,16 @@ def testMainWindows(qtbot, tmpdir): qtbot.wait(stepDelay) # Check the files - projFile = path.join(projDir,"nwProject.nwx") - assert cmpFiles(projFile, path.join(testRef,"gui_nwProject.nwx"), [2]) - sceneFile = path.join(projDir,"data_3","1489056e0916_main.nwd") - assert cmpFiles(sceneFile, path.join(testRef,"gui_1489056e0916_main.nwd")) + projFile = path.join(nwTempGUI,"nwProject.nwx") + assert cmpFiles(projFile, path.join(nwRef,"gui","1_nwProject.nwx"), [2]) + sceneFile = path.join(nwTempGUI,"data_3","1489056e0916_main.nwd") + assert cmpFiles(sceneFile, path.join(nwRef,"gui","1_1489056e0916_main.nwd")) # qtbot.stopForInteraction() @pytest.mark.gui -def testProjectEditor(qtbot, tmpdir): - confDir = str(tmpdir.mkdir("conf")) - projDir = str(tmpdir.mkdir("project")) - nwGUI = nw.main(["--testmode","--config=%s" % confDir]) +def testProjectEditor(qtbot, nwTempGUI, nwRef): + nwGUI = nw.main(["--testmode","--config=%s" % nwRef]) qtbot.addWidget(nwGUI) nwGUI.show() qtbot.waitForWindowShown(nwGUI) @@ -127,9 +121,9 @@ def testProjectEditor(qtbot, tmpdir): # Create new, save, open project nwGUI.theProject.handleSeed = 42 - assert nwGUI.theProject.setProjectPath(projDir) + assert nwGUI.theProject.setProjectPath(nwTempGUI) assert nwGUI.newProject() - assert nwGUI.theProject.setProjectPath(projDir) + assert nwGUI.theProject.setProjectPath(nwTempGUI) projEdit = GuiProjectEditor(nwGUI, nwGUI.theProject) qtbot.addWidget(projEdit) @@ -162,16 +156,14 @@ def testProjectEditor(qtbot, tmpdir): qtbot.wait(stepDelay) # Check the files - projFile = path.join(projDir,"nwProject.nwx") - assert cmpFiles(projFile, path.join(testRef,"projedit_nwProject.nwx"), [2]) + projFile = path.join(nwTempGUI,"nwProject.nwx") + assert cmpFiles(projFile, path.join(nwRef,"gui","2_nwProject.nwx"), [2]) # qtbot.stopForInteraction() @pytest.mark.gui -def testItemEditor(qtbot, tmpdir): - confDir = str(tmpdir.mkdir("conf")) - projDir = str(tmpdir.mkdir("project")) - nwGUI = nw.main(["--testmode","--config=%s" % confDir]) +def testItemEditor(qtbot, nwTempGUI, nwRef): + nwGUI = nw.main(["--testmode","--config=%s" % nwRef]) qtbot.addWidget(nwGUI) nwGUI.show() qtbot.waitForWindowShown(nwGUI) @@ -179,9 +171,9 @@ def testItemEditor(qtbot, tmpdir): # Create new, save, open project nwGUI.theProject.handleSeed = 42 - assert nwGUI.theProject.setProjectPath(projDir) + assert nwGUI.theProject.setProjectPath(nwTempGUI) assert nwGUI.newProject() - assert nwGUI.theProject.setProjectPath(projDir) + assert nwGUI.theProject.setProjectPath(nwTempGUI) itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916") qtbot.addWidget(itemEdit) @@ -211,7 +203,7 @@ def testItemEditor(qtbot, tmpdir): qtbot.wait(stepDelay) # Check the files - projFile = path.join(projDir,"nwProject.nwx") - assert cmpFiles(projFile, path.join(testRef,"itemedit_nwProject.nwx"), [2]) + projFile = path.join(nwTempGUI,"nwProject.nwx") + assert cmpFiles(projFile, path.join(nwRef,"gui","3_nwProject.nwx"), [2]) # qtbot.stopForInteraction() diff --git a/tests/test_project.py b/tests/test_project.py index 14406287..db925c02 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -3,7 +3,7 @@ """ import nw, pytest, types -from os import path, unlink +from os import path from nwtools import * from nwdummy import DummyMain @@ -13,42 +13,40 @@ from nw.project.project import NWProject from nw.project.item import NWItem from nw.enum import nwItemClass -theConf = Config() -theMain = DummyMain() +theConf = Config() +theMain = DummyMain() theMain.mainConf = theConf -testDir = path.dirname(__file__) -testTemp = path.join(testDir,"temp") -testRef = path.join(testDir,"reference") -testProj = path.join(testTemp,"proj") -ensureDir(testTemp) -ensureDir(testProj) - -theConf.initConfig(testRef) theProject = NWProject(theMain) theProject.handleSeed = 42 -projFile = path.join(testProj,"nwProject.nwx") - @pytest.mark.project -def testProjectNew(): +def testProjectNew(nwTempProj,nwRef): + projFile = path.join(nwTempProj,"nwProject.nwx") + refFile = path.join(nwRef,"proj","1_nwProject.nwx") + assert theConf.initConfig(nwRef) assert theProject.newProject() - assert theProject.setProjectPath(testProj) + assert theProject.setProjectPath(nwTempProj) assert theProject.saveProject() - assert cmpFiles(projFile, path.join(testRef,"new_nwProject.nwx"), [2]) + assert cmpFiles(projFile, refFile, [2]) @pytest.mark.project -def testProjectOpen(): +def testProjectOpen(nwTempProj): + projFile = path.join(nwTempProj,"nwProject.nwx") assert theProject.openProject(projFile) @pytest.mark.project -def testProjectSave(): +def testProjectSave(nwTempProj,nwRef): + projFile = path.join(nwTempProj,"nwProject.nwx") + refFile = path.join(nwRef,"proj","1_nwProject.nwx") assert theProject.saveProject() - assert cmpFiles(projFile, path.join(testRef,"new_nwProject.nwx"), [2]) + assert cmpFiles(projFile, refFile, [2]) assert not theProject.projChanged @pytest.mark.project -def testProjectNewRoot(): +def testProjectNewRoot(nwTempProj,nwRef): + projFile = path.join(nwTempProj,"nwProject.nwx") + refFile = path.join(nwRef,"proj","2_nwProject.nwx") assert theProject.openProject(projFile) assert isinstance(theProject.newRoot("Novel", nwItemClass.NOVEL), type(None)) assert isinstance(theProject.newRoot("Plot", nwItemClass.PLOT), type(None)) @@ -60,5 +58,5 @@ def testProjectNewRoot(): assert isinstance(theProject.newRoot("Custom2", nwItemClass.CUSTOM), str) assert theProject.projChanged assert theProject.saveProject() - assert cmpFiles(projFile, path.join(testRef,"roots_nwProject.nwx"), [2]) + assert cmpFiles(projFile, refFile, [2]) assert not theProject.projChanged From 6cc2152e599f03a17bddcdceec886c25845280e7 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 18 May 2019 15:07:34 +0200 Subject: [PATCH 5/5] Don't overwrite reference config file --- tests/reference/novelwriter.conf | 8 ++++---- tests/test_gui.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/reference/novelwriter.conf b/tests/reference/novelwriter.conf index 645ec486..5b27daa9 100644 --- a/tests/reference/novelwriter.conf +++ b/tests/reference/novelwriter.conf @@ -1,10 +1,10 @@ [Main] -timestamp = 2019-05-18 15:02:22 +timestamp = 2019-05-18 15:06:44 [Sizes] geometry = 1100, 650 -treecols = 120, 30, 129 -mainpane = 299, 797 +treecols = 120, 30, 50 +mainpane = 300, 800 [Project] autosaveproject = 60 @@ -25,7 +25,7 @@ repdots = True spellcheck = en_GB [Path] -recent0 = /home/vkbo/Code/novelWriter/tests/temp/gui +recent0 = recent1 = recent2 = recent3 = diff --git a/tests/test_gui.py b/tests/test_gui.py index a1154398..c9655a0a 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -17,7 +17,7 @@ stepDelay = 50 @pytest.mark.gui def testMainWindows(qtbot, nwTempGUI, nwRef): - nwGUI = nw.main(["--testmode","--config=%s" % nwRef]) + nwGUI = nw.main(["--testmode","--config=%s" % nwTempGUI]) qtbot.addWidget(nwGUI) nwGUI.show() qtbot.waitForWindowShown(nwGUI) @@ -113,7 +113,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef): @pytest.mark.gui def testProjectEditor(qtbot, nwTempGUI, nwRef): - nwGUI = nw.main(["--testmode","--config=%s" % nwRef]) + nwGUI = nw.main(["--testmode","--config=%s" % nwTempGUI]) qtbot.addWidget(nwGUI) nwGUI.show() qtbot.waitForWindowShown(nwGUI) @@ -163,7 +163,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef): @pytest.mark.gui def testItemEditor(qtbot, nwTempGUI, nwRef): - nwGUI = nw.main(["--testmode","--config=%s" % nwRef]) + nwGUI = nw.main(["--testmode","--config=%s" % nwTempGUI]) qtbot.addWidget(nwGUI) nwGUI.show() qtbot.waitForWindowShown(nwGUI)