Clean up a few remnants of old test code

This commit is contained in:
Veronica Berglyd Olsen
2023-06-09 22:06:38 +02:00
parent 112aa8468c
commit 0eb39d2e0a
7 changed files with 14 additions and 40 deletions
-4
View File
@@ -33,7 +33,6 @@ __pycache__
/novelwriter/assets/sample.zip /novelwriter/assets/sample.zip
/sample/cache /sample/cache
/sample/meta /sample/meta
/sample/versions
*.bak *.bak
*.lock *.lock
ToC.txt ToC.txt
@@ -44,9 +43,6 @@ ToC.txt
/tests/temp /tests/temp
/tests/lipsum/cache /tests/lipsum/cache
/tests/lipsum/meta /tests/lipsum/meta
/tests/minimal/cache
/tests/minimal/meta
/tests/oldproj/cache
/.pytest_cache /.pytest_cache
/pytestdebug.log /pytestdebug.log
-21
View File
@@ -200,27 +200,6 @@ def mockRnd(monkeypatch):
# Temp Project Folders # Temp Project Folders
## ##
@pytest.fixture(scope="function")
def nwLipsum():
"""A medium sized novelWriter example project with a lot of Lorem
Ipsum text.
"""
srcDir = _TST_ROOT / "lipsum"
dstDir = _TMP_ROOT / "lipsum"
if dstDir.exists():
shutil.rmtree(dstDir)
shutil.copytree(srcDir, dstDir)
cleanProject(dstDir)
yield str(dstDir)
if dstDir.exists():
shutil.rmtree(dstDir)
return
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def prjLipsum(): def prjLipsum():
"""A medium sized novelWriter example project with a lot of Lorem """A medium sized novelWriter example project with a lot of Lorem
+3 -3
View File
@@ -29,11 +29,11 @@ from novelwriter.dialogs.projdetails import GuiProjectDetails
@pytest.mark.gui @pytest.mark.gui
def testDlgProjDetails_Dialog(qtbot, nwGUI, nwLipsum): def testDlgProjDetails_Dialog(qtbot, nwGUI, prjLipsum):
"""Test the project details dialog. """Test the project details dialog.
""" """
# Create a project to work on # Create a project to work on
assert nwGUI.openProject(nwLipsum) assert nwGUI.openProject(prjLipsum)
assert nwGUI.rebuildIndex(beQuiet=True) assert nwGUI.rebuildIndex(beQuiet=True)
qtbot.wait(100) qtbot.wait(100)
@@ -56,7 +56,7 @@ def testDlgProjDetails_Dialog(qtbot, nwGUI, nwLipsum):
assert projDet.tabMain.sceneCountVal.text() == f"{5:n}" assert projDet.tabMain.sceneCountVal.text() == f"{5:n}"
assert projDet.tabMain.revCountVal.text() == f"{nwGUI.theProject.data.saveCount:n}" assert projDet.tabMain.revCountVal.text() == f"{nwGUI.theProject.data.saveCount:n}"
assert projDet.tabMain.projPathVal.text() == nwLipsum assert projDet.tabMain.projPathVal.text() == str(prjLipsum)
# Contents Page # Contents Page
# ============= # =============
+2 -2
View File
@@ -1203,12 +1203,12 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, m
@pytest.mark.gui @pytest.mark.gui
def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum): def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
"""Test the document editor search functionality. """Test the document editor search functionality.
""" """
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True) monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
assert nwGUI.openProject(nwLipsum) is True assert nwGUI.openProject(prjLipsum) is True
assert nwGUI.openDocument("4c4f28287af27") is True assert nwGUI.openDocument("4c4f28287af27") is True
origText = nwGUI.docEditor.getText() origText = nwGUI.docEditor.getText()
+2 -2
View File
@@ -33,11 +33,11 @@ from novelwriter.core.tohtml import ToHtml
@pytest.mark.gui @pytest.mark.gui
def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum): def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
"""Test the document viewer. """Test the document viewer.
""" """
# Open project # Open project
assert nwGUI.openProject(nwLipsum) assert nwGUI.openProject(prjLipsum)
# Rebuild the index # Rebuild the index
nwGUI.mainMenu.aRebuildIndex.activate(QAction.Trigger) nwGUI.mainMenu.aRebuildIndex.activate(QAction.Trigger)
+4 -4
View File
@@ -34,7 +34,7 @@ from novelwriter.gui.doceditor import GuiDocEditor
@pytest.mark.gui @pytest.mark.gui
def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum): def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"""Test the main menu Edit and Format entries. """Test the main menu Edit and Format entries.
""" """
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True) monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
@@ -42,7 +42,7 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum):
# Test Document Action with No Project # Test Document Action with No Project
assert nwGUI.docEditor.docAction(nwDocAction.COPY) is False assert nwGUI.docEditor.docAction(nwDocAction.COPY) is False
assert nwGUI.openProject(nwLipsum) is True assert nwGUI.openProject(prjLipsum) is True
# Split By Chapter # Split By Chapter
assert nwGUI.openDocument("4c4f28287af27") is True assert nwGUI.openDocument("4c4f28287af27") is True
@@ -342,10 +342,10 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum):
@pytest.mark.gui @pytest.mark.gui
def testGuiMenu_ContextMenus(qtbot, nwGUI, nwLipsum): def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum):
"""Test the context menus. """Test the context menus.
""" """
assert nwGUI.openProject(nwLipsum) assert nwGUI.openProject(prjLipsum)
assert nwGUI.openDocument("4c4f28287af27") assert nwGUI.openDocument("4c4f28287af27")
# Editor Context Menu # Editor Context Menu
+3 -4
View File
@@ -19,7 +19,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import os
import time import time
import pytest import pytest
@@ -152,10 +151,10 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, projPath):
@pytest.mark.gui @pytest.mark.gui
def testGuiOutline_Content(qtbot, nwGUI, nwLipsum): def testGuiOutline_Content(qtbot, nwGUI, prjLipsum):
"""Test the outline view. """Test the outline view.
""" """
assert nwGUI.openProject(nwLipsum) assert nwGUI.openProject(prjLipsum)
nwGUI.rebuildIndex() nwGUI.rebuildIndex()
nwGUI._changeView(nwView.OUTLINE) nwGUI._changeView(nwView.OUTLINE)
@@ -192,7 +191,7 @@ def testGuiOutline_Content(qtbot, nwGUI, nwLipsum):
for dTitle, hLevel in docList: for dTitle, hLevel in docList:
aHandle = nwGUI.theProject.newFile(dTitle, newHandle) aHandle = nwGUI.theProject.newFile(dTitle, newHandle)
hHash = "#"*hLevel hHash = "#"*hLevel
writeFile(os.path.join(nwLipsum, "content", f"{aHandle}.nwd"), f"{hHash} {dTitle}\n\n") writeFile(prjLipsum / "content" / f"{aHandle}.nwd", f"{hHash} {dTitle}\n\n")
nwGUI.projView.projTree.revealNewTreeItem(aHandle) nwGUI.projView.projTree.revealNewTreeItem(aHandle)
nwGUI.rebuildIndex() nwGUI.rebuildIndex()