diff --git a/tests/conftest.py b/tests/conftest.py index 9ca87f06..6b95d569 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,18 +20,19 @@ along with this program. If not, see . """ from __future__ import annotations -import sys -import pytest -import shutil import logging +import shutil +import sys from pathlib import Path -from tools import cleanProject -from mocked import MockGuiMain, MockTheme +import pytest from PyQt5.QtWidgets import QMessageBox +from tests.mocked import MockGuiMain, MockTheme +from tests.tools import cleanProject + sys.path.insert(1, str(Path(__file__).parent.parent.absolute())) from novelwriter import CONFIG, SHARED, main # noqa: E402 diff --git a/tests/test_base/test_base_common.py b/tests/test_base/test_base_common.py index dfe5cdb0..0bfa6dad 100644 --- a/tests/test_base/test_base_common.py +++ b/tests/test_base/test_base_common.py @@ -54,8 +54,6 @@ def testBaseCommon_checkStringNone(): assert checkStringNone(1.0, "NotNone") == "NotNone" assert checkStringNone(True, "NotNone") == "NotNone" -# END Test testBaseCommon_checkStringNone - @pytest.mark.base def testBaseCommon_checkString(): @@ -69,8 +67,6 @@ def testBaseCommon_checkString(): assert checkString(1.0, "default") == "default" assert checkString(True, "default") == "default" -# END Test testBaseCommon_checkString - @pytest.mark.base def testBaseCommon_checkInt(): @@ -85,8 +81,6 @@ def testBaseCommon_checkInt(): assert checkInt("1", 3) == 1 assert checkInt("1.0", 3) == 3 -# END Test testBaseCommon_checkInt - @pytest.mark.base def testBaseCommon_checkFloat(): @@ -101,8 +95,6 @@ def testBaseCommon_checkFloat(): assert checkFloat("1", 3.0) == 1.0 assert checkFloat("1.0", 3.0) == 1.0 -# END Test testBaseCommon_checkFloat - @pytest.mark.base def testBaseCommon_checkBool(): @@ -150,8 +142,6 @@ def testBaseCommon_checkBool(): assert checkBool(2.0, True) is True assert checkBool(2.0, False) is False -# END Test testBaseCommon_checkBool - @pytest.mark.base def testBaseCommon_checkUuid(): @@ -163,8 +153,6 @@ def testBaseCommon_checkUuid(): assert checkUuid("e2be99af-f9bf-4403-857a-c3d1ac25abeaa", None) is None # type: ignore assert checkUuid(testUuid, None) == testUuid # type: ignore -# END Test testBaseCommon_checkUuid - @pytest.mark.base def testBaseCommon_checkPath(): @@ -175,8 +163,6 @@ def testBaseCommon_checkPath(): assert checkPath("", None) is None # type: ignore assert checkPath(" ", None) is None # type: ignore -# END Test testBaseCommon_checkPath - @pytest.mark.base def testBaseCommon_isHandle(): @@ -188,8 +174,6 @@ def testBaseCommon_isHandle(): assert isHandle(None) is False assert isHandle("STUFF") is False -# END Test testBaseCommon_isHandle - @pytest.mark.base def testBaseCommon_isTitleTag(): @@ -205,8 +189,6 @@ def testBaseCommon_isTitleTag(): assert isTitleTag(None) is False assert isTitleTag("STUFF") is False -# END Test testBaseCommon_isTitleTag - @pytest.mark.base def testBaseCommon_isItemClass(): @@ -228,8 +210,6 @@ def testBaseCommon_isItemClass(): assert isItemClass(None) is False assert isItemClass("STUFF") is False -# END Test testBaseCommon_isItemClass - @pytest.mark.base def testBaseCommon_isItemType(): @@ -247,8 +227,6 @@ def testBaseCommon_isItemType(): assert isItemType(None) is False # type: ignore assert isItemType("STUFF") is False -# END Test testBaseCommon_isItemType - @pytest.mark.base def testBaseCommon_isItemLayout(): @@ -271,8 +249,6 @@ def testBaseCommon_isItemLayout(): assert isItemLayout(None) is False # type: ignore assert isItemLayout("STUFF") is False -# END Test testBaseCommon_isItemLayout - @pytest.mark.base def testBaseCommon_isListInstance(): @@ -289,8 +265,6 @@ def testBaseCommon_isListInstance(): assert isListInstance([1], str) is False assert isListInstance(["stuff"], int) is False -# END Test testBaseCommon_isListInstance - @pytest.mark.base def testBaseCommon_hexToInt(): @@ -302,8 +276,6 @@ def testBaseCommon_hexToInt(): assert hexToInt("0xffffq") == 0 assert hexToInt("0xffffq", 12) == 12 -# END Test testBaseCommon_hexToInt - @pytest.mark.base def testBaseCommon_minmax(): @@ -311,8 +283,6 @@ def testBaseCommon_minmax(): for i in range(-5, 15): assert 0 <= minmax(i, 0, 10) <= 10 -# END Test testBaseCommon_minmax - @pytest.mark.base def testBaseCommon_checkIntTuple(): @@ -320,8 +290,6 @@ def testBaseCommon_checkIntTuple(): assert checkIntTuple(0, (0, 1, 2), 3) == 0 assert checkIntTuple(5, (0, 1, 2), 3) == 3 -# END Test testBaseCommon_checkIntTuple - @pytest.mark.base def testBaseCommon_formatTimeStamp(): @@ -330,8 +298,6 @@ def testBaseCommon_formatTimeStamp(): assert formatTimeStamp(tTime, False) == "1970-01-01 00:00:00" assert formatTimeStamp(tTime, True) == "1970-01-01 00.00.00" -# END Test testBaseCommon_formatTimeStamp - @pytest.mark.base def testBaseCommon_formatTime(): @@ -352,8 +318,6 @@ def testBaseCommon_formatTime(): assert formatTime(86400) == "1-00:00:00" assert formatTime(360000) == "4-04:00:00" -# END Test testBaseCommon_formatTime - @pytest.mark.base def testBaseCommon_formatVersion(): @@ -363,8 +327,6 @@ def testBaseCommon_formatVersion(): assert formatVersion("1.2b2") == "1.2 Beta 2" assert formatVersion("1.2rc3") == "1.2 RC 3" -# END Test testBaseCommon_formatVersion - @pytest.mark.base def testBaseCommon_formatFileFilter(): @@ -375,8 +337,6 @@ def testBaseCommon_formatFileFilter(): "Stuff (*.stuff);;Text files (*.txt);;All files (*)" ) -# END Test testBaseCommon_formatFileFilter - @pytest.mark.base def testBaseCommon_simplified(): @@ -385,8 +345,6 @@ def testBaseCommon_simplified(): assert simplified(" Hello World ") == "Hello World" assert simplified("\tHello\n\r\tWorld") == "Hello World" -# END Test testBaseCommon_simplified - @pytest.mark.base def testBaseCommon_elide(): @@ -405,8 +363,6 @@ def testBaseCommon_elide(): assert elide("Hello World!", 1) == " ..." assert elide("Hello World!", 0) == " ..." -# END Test testBaseCommon_elide - @pytest.mark.base def testBaseCommon_yesNo(): @@ -432,8 +388,6 @@ def testBaseCommon_yesNo(): assert yesNo(1.0) == "yes" # type: ignore assert yesNo(2.0) == "yes" # type: ignore -# END Test testBaseCommon_yesNo - @pytest.mark.base def testBaseCommon_formatInt(): @@ -455,8 +409,6 @@ def testBaseCommon_formatInt(): assert formatInt(None) == "ERR" # type: ignore assert formatInt("42") == "ERR" # type: ignore -# END Test testBaseCommon_formatInt - @pytest.mark.base def testBaseCommon_transferCase(): @@ -469,8 +421,6 @@ def testBaseCommon_transferCase(): assert transferCase("SOURCE", "target") == "TARGET" assert transferCase("source", "TARGET") == "target" -# END Test testBaseCommon_transferCase - @pytest.mark.base def testBaseCommon_fuzzyTime(): @@ -504,8 +454,6 @@ def testBaseCommon_fuzzyTime(): assert fuzzyTime(47336399) == "a year ago" assert fuzzyTime(47336400) == "2 years ago" -# END Test testBaseCommon_fuzzyTime - @pytest.mark.core def testBaseCommon_numberToRoman(): @@ -531,8 +479,6 @@ def testBaseCommon_numberToRoman(): assert numberToRoman(2010, False) == "MMX" assert numberToRoman(999, True) == "cmxcix" -# END Test testBaseCommon_numberToRoman - @pytest.mark.base def testBaseCommon_cssCol(): @@ -540,8 +486,6 @@ def testBaseCommon_cssCol(): assert cssCol(QColor(0, 0, 0, 0)) == "rgba(0, 0, 0, 0)" assert cssCol(QColor(10, 20, 30, 40)) == "rgba(10, 20, 30, 40)" -# END Test testBaseCommon_cssCol - @pytest.mark.base def testBaseCommon_jsonEncode(): @@ -623,8 +567,6 @@ def testBaseCommon_jsonEncode(): '}' ) -# END Test testBaseCommon_jsonEncode - @pytest.mark.base def testBaseCommon_xmlIndent(): @@ -650,8 +592,6 @@ def testBaseCommon_xmlIndent(): xmlIndent(data) # type: ignore assert data == "foobar" -# END Test testBaseCommon_xmlIndent - @pytest.mark.base def testBaseCommon_readTextFile(monkeypatch, fncPath, ipsumText): @@ -667,8 +607,6 @@ def testBaseCommon_readTextFile(monkeypatch, fncPath, ipsumText): mp.setattr("pathlib.Path.read_text", causeOSError) assert readTextFile(testFile) == "" -# END Test testBaseCommon_readTextFile - @pytest.mark.base def testBaseCommon_makeFileNameSafe(): @@ -680,8 +618,6 @@ def testBaseCommon_makeFileNameSafe(): assert makeFileNameSafe("æøå") == "æøå" assert makeFileNameSafe("Stuff œfi2⁵") == "Stuff œfi25" -# END Test testBaseCommon_makeFileNameSafe - @pytest.mark.base def testBaseCommon_getFileSize(fncPath): @@ -693,8 +629,6 @@ def testBaseCommon_getFileSize(fncPath): assert getFileSize(fncPath / "one.txt") == 6 assert getFileSize(fncPath / "two.txt") == 0 -# END Test testBaseCommon_getFileSize - @pytest.mark.base def testBaseCommon_openExternalPath(monkeypatch, tstPaths): @@ -711,8 +645,6 @@ def testBaseCommon_openExternalPath(monkeypatch, tstPaths): assert openExternalPath(tstPaths.tmpDir) is True assert lastUrl.startswith("file://") -# END Test testBaseCommon_openExternalPath - @pytest.mark.base def testBaseCommon_NWConfigParser(fncPath): @@ -801,5 +733,3 @@ def testBaseCommon_NWConfigParser(fncPath): assert cfgParser.rdIntList("nope", "list2", [1]) == [1] assert cfgParser.rdIntList("main", "blabla", [1]) == [1] - -# END Test testBaseCommon_NWConfigParser diff --git a/tests/test_base/test_base_config.py b/tests/test_base/test_base_config.py index 7c9cc88d..8af01057 100644 --- a/tests/test_base/test_base_config.py +++ b/tests/test_base/test_base_config.py @@ -21,18 +21,19 @@ along with this program. If not, see . from __future__ import annotations import sys -import pytest -from shutil import copyfile from pathlib import Path +from shutil import copyfile -from mocked import causeOSError, MockApp -from tools import cmpFiles, writeFile +import pytest from novelwriter import CONFIG from novelwriter.config import Config, RecentProjects from novelwriter.constants import nwFiles +from tests.mocked import MockApp, causeOSError +from tests.tools import cmpFiles, writeFile + @pytest.mark.base def testBaseConfig_Constructor(monkeypatch): @@ -88,8 +89,6 @@ def testBaseConfig_Constructor(monkeypatch): tstConf = Config() assert tstConf._appPath == tstConf._appRoot -# END Test testBaseConfig_Constructor - @pytest.mark.base def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths): @@ -153,8 +152,6 @@ def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths): assert newConf.doReplaceDQuote is False assert newConf.doReplaceSQuote is False -# END Test testBaseConfig_InitLoadSave - @pytest.mark.base def testBaseConfig_Localisation(fncPath, tstPaths): @@ -191,8 +188,6 @@ def testBaseConfig_Localisation(fncPath, tstPaths): languages = tstConf.listLanguages(tstConf.LANG_NW) assert languages == [("en_GB", "British English"), ("fr", "Français")] -# END Test testBaseConfig_Localisation - @pytest.mark.base def testBaseConfig_Methods(fncPath): @@ -237,8 +232,6 @@ def testBaseConfig_Methods(fncPath): # Recent Projects assert isinstance(tstConf.recentProjects, RecentProjects) -# END Test testBaseConfig_Methods - @pytest.mark.base def testBaseConfig_SettersGetters(fncPath): @@ -361,8 +354,6 @@ def testBaseConfig_SettersGetters(fncPath): assert tstConf.getTextMargin() == 80 assert tstConf.getTabWidth() == 80 -# END Test testBaseConfig_SettersGetters - @pytest.mark.base def testBaseConfig_Internal(monkeypatch, fncPath): @@ -383,8 +374,6 @@ def testBaseConfig_Internal(monkeypatch, fncPath): tstConf._checkOptionalPackages() assert tstConf.hasEnchant is False -# END Test testBaseConfig_Internal - @pytest.mark.base def testBaseConfig_RecentCache(monkeypatch, tstPaths): @@ -446,5 +435,3 @@ def testBaseConfig_RecentCache(monkeypatch, tstPaths): assert recent.listEntries() == [ (str(pathOne), "Proj One", 100, 1600002000), ] - -# END Test testBaseConfig_RecentCache diff --git a/tests/test_base/test_base_error.py b/tests/test_base/test_base_error.py index 1f8c2205..4d9990f2 100644 --- a/tests/test_base/test_base_error.py +++ b/tests/test_base/test_base_error.py @@ -22,10 +22,10 @@ from __future__ import annotations import pytest -from mocked import causeException - from novelwriter.error import NWErrorMessage, exceptionHandler +from tests.mocked import causeException + @pytest.mark.base def testBaseError_Dialog(qtbot, monkeypatch, nwGUI): @@ -61,8 +61,6 @@ def testBaseError_Dialog(qtbot, monkeypatch, nwGUI): nwErr.close() nwGUI.closeMain() -# END Test testBaseError_Dialog - @pytest.mark.base def testBaseError_Handler(qtbot, monkeypatch, nwGUI): @@ -98,5 +96,3 @@ def testBaseError_Handler(qtbot, monkeypatch, nwGUI): exceptionHandler(Exception, "Error Message", None) # type: ignore nwGUI.closeMain() - -# END Test testBaseError_Handler diff --git a/tests/test_base/test_base_init.py b/tests/test_base/test_base_init.py index e828ce76..2b7ebc47 100644 --- a/tests/test_base/test_base_init.py +++ b/tests/test_base/test_base_init.py @@ -20,13 +20,14 @@ along with this program. If not, see . """ from __future__ import annotations -import sys -import pytest import logging +import sys -from mocked import MockGuiMain +import pytest -from novelwriter import CONFIG, main, logger +from novelwriter import CONFIG, logger, main + +from tests.mocked import MockGuiMain @pytest.mark.base @@ -71,8 +72,6 @@ def testBaseInit_Launch(caplog, monkeypatch, fncPath): main([f"--config={fncPath}", f"--data={fncPath}"]) assert ex.value.code == 0 -# END Test testBaseInit_Launch - @pytest.mark.base def testBaseInit_Options(monkeypatch, fncPath): @@ -136,8 +135,6 @@ def testBaseInit_Options(monkeypatch, fncPath): ) assert nwGUI.closeMain() == "closeMain" -# END Test testBaseInit_Options - @pytest.mark.base def testBaseInit_Imports(caplog, monkeypatch, fncPath): @@ -164,5 +161,3 @@ def testBaseInit_Imports(caplog, monkeypatch, fncPath): assert "At least Python" in caplog.messages[0] assert "At least Qt5" in caplog.messages[1] assert "At least PyQt5" in caplog.messages[2] - -# END Test testBaseInit_Imports diff --git a/tests/test_base/test_base_shared.py b/tests/test_base/test_base_shared.py index 6cdb8dfe..6676a465 100644 --- a/tests/test_base/test_base_shared.py +++ b/tests/test_base/test_base_shared.py @@ -22,13 +22,13 @@ from __future__ import annotations import pytest -from tools import buildTestProject -from mocked import MockGuiMain, MockTheme - from PyQt5.QtWidgets import QFileDialog, QMessageBox, QWidget -from novelwriter.shared import SharedData from novelwriter.core.project import NWProject +from novelwriter.shared import SharedData + +from tests.mocked import MockGuiMain, MockTheme +from tests.tools import buildTestProject @pytest.mark.base @@ -62,8 +62,6 @@ def testBaseSharedData_Init(): assert shared.projectIdleTime == 0.0 assert shared.projectLock is None -# END Test testBaseSharedData_Init - @pytest.mark.base def testBaseSharedData_Projects(monkeypatch, caplog, fncPath): @@ -123,8 +121,6 @@ def testBaseSharedData_Projects(monkeypatch, caplog, fncPath): mp.setattr(QFileDialog, "getOpenFileName", lambda *a, **k: (a[2], "")) assert shared.getProjectPath(QWidget(), fncPath, allowZip=True) == fncPath -# END Test testBaseSharedData_Projects - @pytest.mark.base def testBaseSharedData_Alerts(qtbot, monkeypatch, caplog): @@ -171,5 +167,3 @@ def testBaseSharedData_Alerts(qtbot, monkeypatch, caplog): # Question box assert shared.question("Why?") is True assert shared.lastAlert == "Why?" - -# END Test testBaseSharedData_Alerts diff --git a/tests/test_core/test_core_buildsettings.py b/tests/test_core/test_core_buildsettings.py index 10c63253..df891745 100644 --- a/tests/test_core/test_core_buildsettings.py +++ b/tests/test_core/test_core_buildsettings.py @@ -21,20 +21,21 @@ along with this program. If not, see . from __future__ import annotations import json -import uuid -import pytest import shutil +import uuid from pathlib import Path -from novelwriter import CONFIG -from tools import C, buildTestProject -from mocked import causeOSError +import pytest -from novelwriter.enum import nwBuildFmt, nwItemClass +from novelwriter import CONFIG from novelwriter.constants import nwFiles -from novelwriter.core.project import NWProject from novelwriter.core.buildsettings import BuildCollection, BuildSettings, FilterMode +from novelwriter.core.project import NWProject +from novelwriter.enum import nwBuildFmt, nwItemClass + +from tests.mocked import causeOSError +from tests.tools import C, buildTestProject def isUUID(value): @@ -140,8 +141,6 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path): assert more["build"] == "Build Name" assert more["format"] == nwBuildFmt.HTML.name -# END Test testCoreBuildSettings_ClassAttributes - @pytest.mark.core def testCoreBuildSettings_BuildValues(): @@ -216,8 +215,6 @@ def testCoreBuildSettings_BuildValues(): assert more["settings"][boolSetting] is True assert more["settings"][floatSetting] == 2.5 -# END Test testCoreBuildSettings_BuildValues - @pytest.mark.core def testCoreBuildSettings_Filters(mockGUI, fncPath: Path, mockRnd): @@ -364,8 +361,6 @@ def testCoreBuildSettings_Filters(mockGUI, fncPath: Path, mockRnd): # No valid project provided assert build.buildItemFilter(None) == {} # type: ignore -# END Test testCoreBuildSettings_Filters - @pytest.mark.core def testCoreBuildSettings_Collection(monkeypatch, mockGUI, fncPath: Path, mockRnd): @@ -471,5 +466,3 @@ def testCoreBuildSettings_Collection(monkeypatch, mockGUI, fncPath: Path, mockRn ] assert another.lastBuild == buildIDOne assert another.defaultBuild == buildIDTwo - -# END Test testCoreBuildSettings_Collection diff --git a/tests/test_core/test_core_coretools.py b/tests/test_core/test_core_coretools.py index fbceb229..a0aa86e0 100644 --- a/tests/test_core/test_core_coretools.py +++ b/tests/test_core/test_core_coretools.py @@ -125,8 +125,6 @@ def testCoreTools_DocMerger(monkeypatch, mockGUI, fncPath, tstPaths, mockRnd, ip # Just for debugging docMerger.writeTargetDoc() -# END Test testCoreTools_DocMerger - @pytest.mark.core def testCoreTools_DocSplitter(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText): @@ -264,8 +262,6 @@ def testCoreTools_DocSplitter(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText) project.saveProject() -# END Test testCoreTools_DocSplitter - @pytest.mark.core def testCoreTools_DocDuplicator(mockGUI, fncPath, tstPaths, mockRnd): @@ -401,8 +397,6 @@ def testCoreTools_DocDuplicator(mockGUI, fncPath, tstPaths, mockRnd): copyfile(projFile, testFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) -# END Test testCoreTools_DocDuplicator - @pytest.mark.core def testCoreTools_DocSearch(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText): @@ -479,8 +473,6 @@ def testCoreTools_DocSearch(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText): assert pruneResult(search.iterSearch(project, "Lorem"), 2) == [(15, 5, "Lorem")] search.setCaseSensitive(False) -# END Test testCoreTools_DocSearch - @pytest.mark.core def testCoreTools_ProjectBuilderWrapper(monkeypatch, caplog, fncPath, mockGUI): @@ -509,8 +501,6 @@ def testCoreTools_ProjectBuilderWrapper(monkeypatch, caplog, fncPath, mockGUI): assert builder.buildProject({"path": fncPath}) is False assert "The target folder is not empty." in caplog.text -# END Test testCoreTools_ProjectBuilderWrapper - @pytest.mark.core def testCoreTools_ProjectBuilderA(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd): @@ -544,8 +534,6 @@ def testCoreTools_ProjectBuilderA(monkeypatch, fncPath, tstPaths, mockGUI, mockR copyfile(projFile, testFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) -# END Test testCoreTools_ProjectBuilderA - @pytest.mark.core def testCoreTools_ProjectBuilderB(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd): @@ -579,8 +567,6 @@ def testCoreTools_ProjectBuilderB(monkeypatch, fncPath, tstPaths, mockGUI, mockR copyfile(projFile, testFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) -# END Test testCoreTools_ProjectBuilderB - @pytest.mark.core def testCoreTools_ProjectBuilderCopyPlain(monkeypatch, caplog, mockGUI, prjLipsum, fncPath): @@ -645,8 +631,6 @@ def testCoreTools_ProjectBuilderCopyPlain(monkeypatch, caplog, mockGUI, prjLipsu assert dstProject.data.autoCount < 5 assert dstProject.data.editTime < 10 -# END Test testCoreTools_ProjectBuilderCopyPlain - @pytest.mark.core def testCoreTools_ProjectBuilderCopyZipped(monkeypatch, caplog, mockGUI, fncPath, mockRnd): @@ -723,8 +707,6 @@ def testCoreTools_ProjectBuilderCopyZipped(monkeypatch, caplog, mockGUI, fncPath assert dstProject.data.autoCount < 5 assert dstProject.data.editTime < 10 -# END Test testCoreTools_ProjectBuilderCopyZipped - @pytest.mark.core def testCoreTools_ProjectBuilderSample(monkeypatch, mockGUI, fncPath, tstPaths): @@ -769,5 +751,3 @@ def testCoreTools_ProjectBuilderSample(monkeypatch, mockGUI, fncPath, tstPaths): # Can't create to the same target again assert builder.buildProject(data) is False dstSample.unlink() - -# END Test testCoreTools_ProjectBuilderSample diff --git a/tests/test_core/test_core_docbuild.py b/tests/test_core/test_core_docbuild.py index 928d5d73..6054b272 100644 --- a/tests/test_core/test_core_docbuild.py +++ b/tests/test_core/test_core_docbuild.py @@ -182,8 +182,6 @@ def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstP "Build: Failed to build '04468803b92e1'", ] -# END Test testCoreDocBuild_OpenDocument - @pytest.mark.core def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): @@ -252,8 +250,6 @@ def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): assert docBuild.error == "OSError: Mock OSError" assert not docFile.is_file() -# END Test testCoreDocBuild_HTML - @pytest.mark.core def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): @@ -322,8 +318,6 @@ def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths assert docBuild.error == "OSError: Mock OSError" assert not docFile.is_file() -# END Test testCoreDocBuild_Markdown - @pytest.mark.core def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): @@ -392,8 +386,6 @@ def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): assert docBuild.error == "OSError: Mock OSError" assert not docFile.is_file() -# END Test testCoreDocBuild_NWD - @pytest.mark.core def testCoreDocBuild_Custom(mockGUI, fncPath: Path): @@ -457,8 +449,6 @@ def testCoreDocBuild_Custom(mockGUI, fncPath: Path): ) docFile.unlink() -# END Test testCoreDocBuild_Custom - @pytest.mark.core def testCoreDocBuild_IterBuild(mockGUI, fncPath: Path, mockRnd): @@ -600,5 +590,3 @@ def testCoreDocBuild_IterBuild(mockGUI, fncPath: Path, mockRnd): assert "meta" in data assert "text" in data docFile.unlink() - -# END Test testCoreDocBuild_IterBuild diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index 3dbdd454..7382995f 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -22,12 +22,12 @@ from __future__ import annotations import pytest -from tools import C, MOCK_TIME, buildTestProject, readFile, writeFile -from mocked import causeOSError - -from novelwriter.enum import nwItemClass, nwItemLayout -from novelwriter.core.project import NWProject from novelwriter.core.document import NWDocument +from novelwriter.core.project import NWProject +from novelwriter.enum import nwItemClass, nwItemLayout + +from tests.mocked import causeOSError +from tests.tools import MOCK_TIME, C, buildTestProject, readFile, writeFile @pytest.mark.core @@ -189,8 +189,6 @@ def testCoreDocument_LoadSave(monkeypatch, mockGUI, fncPath, mockRnd): assert doc.deleteDocument() is True assert not docPath.exists() -# END Test testCoreDocument_Load - @pytest.mark.core def testCoreDocument_Methods(monkeypatch, mockGUI, fncPath, mockRnd): @@ -234,5 +232,3 @@ def testCoreDocument_Methods(monkeypatch, mockGUI, fncPath, mockRnd): ) assert doc.readDocument() == "### Test File\n\nText ...\n\n" - -# END Test testCoreDocument_Methods diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 71f4bc5d..176174bd 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -156,8 +156,6 @@ def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, mockGUI, tstPaths): # Regression test for issue #1718 project.closeProject() -# END Test testCoreIndex_LoadSave - @pytest.mark.core def testCoreIndex_ScanThis(mockGUI): @@ -214,8 +212,6 @@ def testCoreIndex_ScanThis(mockGUI): project.closeProject() -# END Test testCoreIndex_ScanThis - @pytest.mark.core def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd): @@ -305,8 +301,6 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreIndex_CheckThese - @pytest.mark.core def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd): @@ -550,8 +544,6 @@ def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreIndex_ScanText - @pytest.mark.core def testCoreIndex_CommentKeys(monkeypatch, mockGUI, fncPath, mockRnd): @@ -589,8 +581,6 @@ def testCoreIndex_CommentKeys(monkeypatch, mockGUI, fncPath, mockRnd): # Check invalid comment style assert index.newCommentKey(C.hSceneDoc, None) == "err" # type: ignore -# END Test testCoreIndex_CommentKeys - @pytest.mark.core def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd): @@ -931,8 +921,6 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd): assert project.saveProject() is True project.closeProject() -# END Test testCoreIndex_ExtractData - @pytest.mark.core def testCoreIndex_TagsIndex(): @@ -1119,8 +1107,6 @@ def testCoreIndex_TagsIndex(): } }) -# END Test testCoreIndex_TagsIndex - @pytest.mark.core def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd): @@ -1391,8 +1377,6 @@ def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd): } }) -# END Test testCoreIndex_ItemIndex - @pytest.mark.core def testCoreIndex_checkModKey(): @@ -1425,8 +1409,6 @@ def testCoreIndex_checkModKey(): assert _checkModKey("note", "a1.2") is False assert _checkModKey("note", "a1_2") is True -# END Test testCoreIndex_checkModKey - @pytest.mark.core def testCoreIndex_processComment(): @@ -1477,5 +1459,3 @@ def testCoreIndex_processComment(): assert processComment("% note.term: Hi") == (nwComment.NOTE, "term", "Hi", 7, 12) assert processComment("% note. term : Hi") == (nwComment.PLAIN, "", "note. term : Hi", 0, 0) assert processComment("% note . term : Hi") == (nwComment.PLAIN, "", "note . term : Hi", 0, 0) - -# END Test testCoreIndex_processComment diff --git a/tests/test_core/test_core_item.py b/tests/test_core/test_core_item.py index 65cf7b5f..3e0fd0bb 100644 --- a/tests/test_core/test_core_item.py +++ b/tests/test_core/test_core_item.py @@ -21,15 +21,16 @@ along with this program. If not, see . from __future__ import annotations import copy + import pytest from PyQt5.QtGui import QIcon -from tools import C, buildTestProject - -from novelwriter.enum import nwItemClass, nwItemType, nwItemLayout from novelwriter.core.item import NWItem from novelwriter.core.project import NWProject +from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType + +from tests.tools import C, buildTestProject @pytest.mark.core @@ -180,8 +181,6 @@ def testCoreItem_Setters(mockGUI, mockRnd, fncPath): item.saveInitialCount() assert item.initCount == 234 -# END Test testCoreItem_Setters - @pytest.mark.core def testCoreItem_Methods(mockGUI, mockRnd, fncPath): @@ -326,8 +325,6 @@ def testCoreItem_Methods(mockGUI, mockRnd, fncPath): del scItem assert cpItem.pack() == cpData -# END Test testCoreItem_Methods - @pytest.mark.core def testCoreItem_TypeSetter(mockGUI): @@ -355,8 +352,6 @@ def testCoreItem_TypeSetter(mockGUI): item.setType(nwItemType.ROOT) assert item.itemType == nwItemType.ROOT -# END Test testCoreItem_TypeSetter - @pytest.mark.core def testCoreItem_ClassSetter(mockGUI): @@ -461,8 +456,6 @@ def testCoreItem_ClassSetter(mockGUI): item.setClass(nwItemClass.NOVEL) assert item.itemClass == nwItemClass.NOVEL -# END Test testCoreItem_ClassSetter - @pytest.mark.core def testCoreItem_LayoutSetter(mockGUI): @@ -490,8 +483,6 @@ def testCoreItem_LayoutSetter(mockGUI): item.setLayout(nwItemLayout.NOTE) assert item.itemLayout == nwItemLayout.NOTE -# END Test testCoreItem_LayoutSetter - @pytest.mark.core def testCoreItem_ClassDefaults(mockGUI): @@ -546,8 +537,6 @@ def testCoreItem_ClassDefaults(mockGUI): assert item.itemStatus is not None assert item.itemImport is not None -# END Test testCoreItem_ClassDefaults - @pytest.mark.core def testCoreItem_PackUnpack(mockGUI, caplog, mockRnd): @@ -761,5 +750,3 @@ def testCoreItem_PackUnpack(mockGUI, caplog, mockRnd): "import": "i000001", } } - -# END Test testCoreItem_PackUnpack diff --git a/tests/test_core/test_core_options.py b/tests/test_core/test_core_options.py index fd291d08..0852cc5f 100644 --- a/tests/test_core/test_core_options.py +++ b/tests/test_core/test_core_options.py @@ -21,15 +21,16 @@ along with this program. If not, see . from __future__ import annotations import json -import pytest -from mocked import causeOSError +import pytest from novelwriter.constants import nwFiles from novelwriter.core.options import OptionState from novelwriter.core.project import NWProject from novelwriter.gui.noveltree import NovelTreeColumn +from tests.mocked import causeOSError + @pytest.mark.core def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath): @@ -102,8 +103,6 @@ def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath): }, } -# END Test testCoreOptions_LoadSave - @pytest.mark.core def testCoreOptions_SetGet(mockGUI): @@ -151,5 +150,3 @@ def testCoreOptions_SetGet(mockGUI): assert options.getFloat("SomeGroup", "mockItem", None) is None # type: ignore assert options.getBool("SomeGroup", "mockItem", None) is None # type: ignore assert options.getEnum("SomeGroup", "mockItem", NovelTreeColumn, None) is None # type: ignore - -# END Test testCoreOptions_SetGet diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index 3304fc14..ba617017 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -20,25 +20,25 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - from shutil import copyfile from zipfile import ZipFile -from mocked import causeOSError -from tools import C, cmpFiles, buildTestProject, XML_IGNORE +import pytest from PyQt5.QtWidgets import QMessageBox from novelwriter import CONFIG, SHARED -from novelwriter.enum import nwItemClass from novelwriter.constants import nwFiles -from novelwriter.core.item import NWItem -from novelwriter.core.tree import NWTree from novelwriter.core.index import NWIndex -from novelwriter.core.project import NWProject, NWProjectState +from novelwriter.core.item import NWItem from novelwriter.core.options import OptionState +from novelwriter.core.project import NWProject, NWProjectState from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState +from novelwriter.core.tree import NWTree +from novelwriter.enum import nwItemClass + +from tests.mocked import causeOSError +from tests.tools import XML_IGNORE, C, buildTestProject, cmpFiles @pytest.mark.core @@ -88,8 +88,6 @@ def testCoreProject_NewRoot(fncPath, tstPaths, mockGUI, mockRnd): assert "0000000000016" not in project.tree assert "0000000000017" not in project.tree -# END Test testCoreProject_NewRoot - @pytest.mark.core def testCoreProject_NewFileFolder(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd): @@ -192,8 +190,6 @@ def testCoreProject_NewFileFolder(monkeypatch, fncPath, tstPaths, mockGUI, mockR project.closeProject() -# END Test testCoreProject_NewFileFolder - @pytest.mark.core def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd): @@ -302,8 +298,6 @@ def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreProject_Open - @pytest.mark.core def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath): @@ -331,8 +325,6 @@ def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath): assert project.saveProject(autoSave=True) is True project.closeProject() -# END Test testCoreProject_Save - @pytest.mark.core def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd): @@ -397,8 +389,6 @@ def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd): ] assert nItem.itemParent is None -# END Test testCoreProject_AccessItems - @pytest.mark.core def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd): @@ -507,8 +497,6 @@ def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd): project.setTreeOrder(oldOrder) assert project.tree.handles() == oldOrder -# END Test testCoreProject_Methods - @pytest.mark.core def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths): @@ -566,5 +554,3 @@ def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths): fncPath / "nwProject.nwx", tstPaths.tmpDir / "extract" / "nwProject.nwx" ) - -# END Test testCoreProject_Backup diff --git a/tests/test_core/test_core_projectxml.py b/tests/test_core/test_core_projectxml.py index de277dfa..1119d338 100644 --- a/tests/test_core/test_core_projectxml.py +++ b/tests/test_core/test_core_projectxml.py @@ -246,8 +246,6 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, mockGUI, tstPaths, fncPath): copyfile(outFile, tstFile) assert cmpFiles(tstFile, refFile) -# END Test testCoreProjectXML_ReadCurrent - @pytest.mark.core def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockGUI, mockRnd): @@ -393,8 +391,6 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy10 - @pytest.mark.core def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockGUI, mockRnd): @@ -540,8 +536,6 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy11 - @pytest.mark.core def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockGUI, mockRnd): @@ -690,8 +684,6 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy12 - @pytest.mark.core def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockGUI, mockRnd): @@ -840,8 +832,6 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy13 - @pytest.mark.core def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockGUI, mockRnd): @@ -990,5 +980,3 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockGUI, mockRnd): compFile = tstPaths.refDir / "projectXML_ReadLegacy14.nwx" copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) - -# END Test testCoreProjectXML_ReadLegacy14 diff --git a/tests/test_core/test_core_sessions.py b/tests/test_core/test_core_sessions.py index 2ba49959..e9c8fcd5 100644 --- a/tests/test_core/test_core_sessions.py +++ b/tests/test_core/test_core_sessions.py @@ -20,18 +20,18 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - -from time import sleep from pathlib import Path +from time import sleep -from tools import buildTestProject -from mocked import causeOSError +import pytest from novelwriter.constants import nwFiles from novelwriter.core.project import NWProject from novelwriter.core.sessions import NWSessionLog +from tests.mocked import causeOSError +from tests.tools import buildTestProject + @pytest.mark.core def testCoreSessions_Main(monkeypatch, mockGUI, fncPath): @@ -111,5 +111,3 @@ def testCoreSessions_Main(monkeypatch, mockGUI, fncPath): with monkeypatch.context() as mp: mp.setattr("novelwriter.core.storage.NWStorage.getMetaFile", lambda *a: None) assert len(list(sessLog.iterRecords())) == 0 - -# END Test testCoreSessions_Main diff --git a/tests/test_core/test_core_spellcheck.py b/tests/test_core/test_core_spellcheck.py index 401df109..b3ea1dd1 100644 --- a/tests/test_core/test_core_spellcheck.py +++ b/tests/test_core/test_core_spellcheck.py @@ -21,18 +21,19 @@ along with this program. If not, see . from __future__ import annotations import sys -import pytest -import enchant from pathlib import Path -from tools import buildTestProject -from mocked import causeOSError +import enchant +import pytest from novelwriter.constants import nwFiles from novelwriter.core.project import NWProject from novelwriter.core.spellcheck import FakeEnchant, NWSpellEnchant, UserDictionary +from tests.mocked import causeOSError +from tests.tools import buildTestProject + @pytest.mark.core def testCoreSpell_UserDictionary(monkeypatch, mockGUI, fncPath): @@ -102,8 +103,6 @@ def testCoreSpell_UserDictionary(monkeypatch, mockGUI, fncPath): userDict.load() assert sorted(userDict) == ["bar", "foo"] -# END Test testCoreSpell_UserDictionary - @pytest.mark.core def testCoreSpell_FakeEnchant(monkeypatch, mockGUI, fncPath): @@ -137,8 +136,6 @@ def testCoreSpell_FakeEnchant(monkeypatch, mockGUI, fncPath): assert fkChk.suggest("whatchamajig") == [] assert fkChk.add_to_session("whatchamajig") is None -# END Test testCoreSpell_FakeEnchant - @pytest.mark.core def testCoreSpell_Enchant(monkeypatch, mockGUI, fncPath): @@ -189,5 +186,3 @@ def testCoreSpell_Enchant(monkeypatch, mockGUI, fncPath): mp.setattr("enchant.Broker.request_dict", lambda *a: None) spChk.setLanguage("en_US") assert isinstance(spChk._enchant, FakeEnchant) - -# END Test testCoreSpell_Enchant diff --git a/tests/test_core/test_core_status.py b/tests/test_core/test_core_status.py index 7c6b2fc4..e3869043 100644 --- a/tests/test_core/test_core_status.py +++ b/tests/test_core/test_core_status.py @@ -22,13 +22,13 @@ from __future__ import annotations import pytest -from tools import C - from PyQt5.QtGui import QColor, QIcon from novelwriter.core.status import NWStatus, StatusEntry, _ShapeCache from novelwriter.enum import nwStatusShape +from tests.tools import C + statusKeys = [C.sNew, C.sNote, C.sDraft, C.sFinished] importKeys = [C.iNew, C.iMinor, C.iMajor, C.iMain] @@ -59,8 +59,6 @@ def testCoreStatus_StatusEntry(): assert other.icon is not icon # Not the same icon, but a copy assert other.count == 42 -# END Test testCoreStatus_StatusEntry - @pytest.mark.core def testCoreStatus_Internal(mockGUI, mockRnd): @@ -116,8 +114,6 @@ def testCoreStatus_Internal(mockGUI, mockRnd): assert nImport._checkKey("s654321") == "i00000b" # Status key not accepted assert nImport._checkKey("i123456") == "i123456" # Import key accepted -# END Test testCoreStatus_Internal - @pytest.mark.core def testCoreStatus_Iterator(mockGUI, mockRnd): @@ -162,8 +158,6 @@ def testCoreStatus_Iterator(mockGUI, mockRnd): # Content : Count assert [e.count for _, e in nStatus.iterItems()] == [0, 1, 2, 3] -# END Test testCoreStatus_Iterator - @pytest.mark.core def testCoreStatus_Entries(mockGUI, mockRnd): @@ -309,8 +303,6 @@ def testCoreStatus_Entries(mockGUI, mockRnd): assert list(nStatus._store.keys()) == [statusKeys[3], statusKeys[2]] assert nStatus._default == statusKeys[3] -# END Test testCoreStatus_Entries - @pytest.mark.core def testCoreStatus_Pack(mockGUI, mockRnd): @@ -362,8 +354,6 @@ def testCoreStatus_Pack(mockGUI, mockRnd): }), ] -# END Test testCoreStatus_Pack - @pytest.mark.core def testCoreStatus_ShapeCache(): @@ -413,5 +403,3 @@ def testCoreStatus_ShapeCache(): assert shapes.getShape(nwStatusShape.BLOCK_2) is block2 assert shapes.getShape(nwStatusShape.BLOCK_3) is block3 assert shapes.getShape(nwStatusShape.BLOCK_4) is block4 - -# END Test testCoreStatus_ShapeCache diff --git a/tests/test_core/test_core_storage.py b/tests/test_core/test_core_storage.py index 76520078..ee6e50a0 100644 --- a/tests/test_core/test_core_storage.py +++ b/tests/test_core/test_core_storage.py @@ -21,20 +21,21 @@ along with this program. If not, see . from __future__ import annotations import json -import pytest from pathlib import Path from zipfile import ZipFile -from mocked import causeOSError -from tools import C, buildTestProject +import pytest from novelwriter import CONFIG from novelwriter.constants import nwFiles from novelwriter.core.document import NWDocument from novelwriter.core.project import NWProject from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter -from novelwriter.core.storage import NWStorage, NWStorageOpen, NWStorageCreate, _LegacyStorage +from novelwriter.core.storage import NWStorage, NWStorageCreate, NWStorageOpen, _LegacyStorage + +from tests.mocked import causeOSError +from tests.tools import C, buildTestProject class MockProject: @@ -82,8 +83,6 @@ def testCoreStorage_CreateNewProject(mockGUI, fncPath): project.closeProject() -# END Test testCoreStorage_CreateNewProject - @pytest.mark.core def testCoreStorage_InitProjectStorage(monkeypatch, mockGUI, fncPath, mockRnd): @@ -163,8 +162,6 @@ def testCoreStorage_InitProjectStorage(monkeypatch, mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreStorage_InitProjectStorage - @pytest.mark.core def testCoreStorage_InitProjectStorage_Invalid(mockGUI, fncPath): @@ -202,8 +199,6 @@ def testCoreStorage_InitProjectStorage_Invalid(mockGUI, fncPath): project.closeProject() -# END Test testCoreStorage_InitProjectStorage_Invalid - @pytest.mark.core def testCoreStorage_LockFile(monkeypatch, fncPath): @@ -265,8 +260,6 @@ def testCoreStorage_LockFile(monkeypatch, fncPath): assert storage._clearLockFile() is True assert not lockFilePath.exists() -# END Test testCoreStorage_LockFile - @pytest.mark.core def testCoreStorage_ZipIt(monkeypatch, mockGUI, fncPath, tstPaths, mockRnd): @@ -301,8 +294,6 @@ def testCoreStorage_ZipIt(monkeypatch, mockGUI, fncPath, tstPaths, mockRnd): project.closeProject() -# END Test testCoreStorage_ZipIt - @pytest.mark.core def testCoreStorage_LegacyDataFolder(monkeypatch, fncPath): @@ -369,8 +360,6 @@ def testCoreStorage_LegacyDataFolder(monkeypatch, fncPath): for c in "0123456789abcdef": assert (fncPath / "content" / f"{c}00000000000{c}.nwd").exists() -# END Test testCoreStorage_LegacyDataFolder - @pytest.mark.core def testCoreStorage_DeprecatedFiles(monkeypatch, fncPath): @@ -412,8 +401,6 @@ def testCoreStorage_DeprecatedFiles(monkeypatch, fncPath): for depFile in remove: assert not depFile.exists() -# END Test testCoreStorage_DeprecatedFiles - @pytest.mark.core def testCoreStorage_OldFormatConvert(monkeypatch, mockGUI, fncPath): @@ -529,5 +516,3 @@ def testCoreStorage_OldFormatConvert(monkeypatch, mockGUI, fncPath): "LABEL": [False, 267], "LINE": [True, 40] } - -# END Test testCoreStorage_OldFormatConvert diff --git a/tests/test_core/test_core_tohtml.py b/tests/test_core/test_core_tohtml.py index ba596b86..a5df4696 100644 --- a/tests/test_core/test_core_tohtml.py +++ b/tests/test_core/test_core_tohtml.py @@ -129,8 +129,6 @@ def testCoreToHtml_ConvertHeaders(mockGUI): html.doConvert() assert html.result == "

Heading Two

\n" -# END Test testCoreToHtml_ConvertHeaders - @pytest.mark.core def testCoreToHtml_ConvertParagraphs(mockGUI): @@ -301,8 +299,6 @@ def testCoreToHtml_ConvertParagraphs(mockGUI): "text here

\n" ) -# END Test testCoreToHtml_ConvertParagraphs - @pytest.mark.core def testCoreToHtml_ConvertDirect(mockGUI): @@ -447,8 +443,6 @@ def testCoreToHtml_ConvertDirect(mockGUI): "

Some text ...

\n" ) -# END Test testCoreToHtml_ConvertDirect - @pytest.mark.core def testCoreToHtml_SpecialCases(mockGUI): @@ -521,8 +515,6 @@ def testCoreToHtml_SpecialCases(mockGUI): "

Test text **bold** and more.

\n" ) -# END Test testCoreToHtml_SpecialCases - @pytest.mark.core def testCoreToHtml_Save(mockGUI, fncPath): @@ -619,8 +611,6 @@ def testCoreToHtml_Save(mockGUI, fncPath): assert data["text"]["css"] == hStyle assert len(data["text"]["html"]) == len(resText) -# END Test testCoreToHtml_Save - @pytest.mark.core def testCoreToHtml_Methods(mockGUI): @@ -668,8 +658,6 @@ def testCoreToHtml_Methods(mockGUI): html.setStyles(False) assert html.getStyleSheet() == [] -# END Test testCoreToHtml_Methods - @pytest.mark.core def testCoreToHtml_Format(mockGUI): @@ -726,5 +714,3 @@ def testCoreToHtml_Format(mockGUI): "Bod, " "Jane" ) - -# END Test testCoreToHtml_Format diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py index 82fd6814..0d70eab1 100644 --- a/tests/test_core/test_core_tokenizer.py +++ b/tests/test_core/test_core_tokenizer.py @@ -148,8 +148,6 @@ def testCoreToken_Setters(mockGUI): tokens.setBlockIndent(60.0) assert tokens._blockIndent == 10.0 -# END Test testCoreToken_Setters - @pytest.mark.core def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath): @@ -236,8 +234,6 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath): with pytest.raises(NotImplementedError): tokens.doConvert() -# END Test testCoreToken_TextOps - @pytest.mark.core def testCoreToken_StripEscape(): @@ -247,8 +243,6 @@ def testCoreToken_StripEscape(): assert stripEscape(text1) == "This is text with escapes: ** ~~ __" assert stripEscape(text2) == "This is text with escapes: ** ~~ __" -# END Test testCoreToken_StripEscape - @pytest.mark.core def testCoreToken_HeaderFormat(mockGUI): @@ -438,8 +432,6 @@ def testCoreToken_HeaderFormat(mockGUI): ] assert tokens.allMarkdown[-1] == "##! Prologue\n\n" -# END Test testCoreToken_HeaderFormat - @pytest.mark.core def testCoreToken_HeaderStyle(mockGUI): @@ -701,8 +693,6 @@ def testCoreToken_HeaderStyle(mockGUI): assert processStyle("#! My Novel\n", False) == Tokenizer.A_CENTRE | Tokenizer.A_PBB assert processStyle("##! Prologue\n", False) == Tokenizer.A_NONE -# END Test testCoreToken_HeaderStyle - @pytest.mark.core def testCoreToken_MetaFormat(mockGUI): @@ -800,8 +790,6 @@ def testCoreToken_MetaFormat(mockGUI): (Tokenizer.T_EMPTY, 0, "", [], Tokenizer.A_NONE), ] -# END Test testCoreToken_MetaFormat - @pytest.mark.core def testCoreToken_MarginFormat(mockGUI): @@ -854,8 +842,6 @@ def testCoreToken_MarginFormat(mockGUI): "Right-indent, right-aligned\n\n\n" ) -# END Test testCoreToken_MarginFormat - @pytest.mark.core def testCoreToken_ExtractFormats(mockGUI): @@ -963,8 +949,6 @@ def testCoreToken_ExtractFormats(mockGUI): (38, tokens.FMT_B_E, ""), (41, tokens.FMT_I_E, ""), ] -# END Test testCoreToken_ExtractFormats - @pytest.mark.core def testCoreToken_TextFormat(mockGUI): @@ -1084,8 +1068,6 @@ def testCoreToken_TextFormat(mockGUI): "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n\n" ) -# END Test testCoreToken_TextFormat - @pytest.mark.core def testCoreToken_SpecialFormat(mockGUI): @@ -1286,8 +1268,6 @@ def testCoreToken_SpecialFormat(mockGUI): (Tokenizer.T_EMPTY, 1, "", [], Tokenizer.A_NONE), ] -# END Test testCoreToken_SpecialFormat - @pytest.mark.core def testCoreToken_ProcessHeaders(mockGUI): @@ -1509,8 +1489,6 @@ def testCoreToken_ProcessHeaders(mockGUI): tokens.tokenizeText() assert tokens._noSep is False -# END Test testCoreToken_ProcessHeaders - @pytest.mark.core def testCoreToken_BuildOutline(mockGUI, ipsumText): @@ -1576,9 +1554,6 @@ def testCoreToken_BuildOutline(mockGUI, ipsumText): } -# END Test testCoreToken_BuildOutline - - @pytest.mark.core def testCoreToken_CountStats(mockGUI, ipsumText): """Test stats counter of the Tokenizer class.""" @@ -1784,8 +1759,6 @@ def testCoreToken_CountStats(mockGUI, ipsumText): "allWordChars": 3289, "textWordChars": 2990, "titleWordChars": 38 } -# END Test testCoreToken_CountStats - @pytest.mark.core def testCoreToken_SceneSeparators(mockGUI): @@ -1937,8 +1910,6 @@ def testCoreToken_SceneSeparators(mockGUI): "Text\n\n" ) -# END Test testCoreToken_SceneSeparators - @pytest.mark.core def testCoreToken_HeaderVisibility(mockGUI): @@ -2051,8 +2022,6 @@ def testCoreToken_HeaderVisibility(mockGUI): "Text\n\n" ) -# END Test testCoreToken_HeaderVisibility - @pytest.mark.core def testCoreToken_CounterHandling(mockGUI): @@ -2138,8 +2107,6 @@ def testCoreToken_CounterHandling(mockGUI): "Text\n\n" ) -# END Test testCoreToken_CounterHandling - @pytest.mark.core def testCoreToken_HeadingFormatter(fncPath, mockGUI, mockRnd): @@ -2245,5 +2212,3 @@ def testCoreToken_HeadingFormatter(fncPath, mockGUI, mockRnd): # Chapter w/Fallback Focus cFormat = f"Chapter {nwHeadFmt.CH_NUM}, Scene {nwHeadFmt.SC_NUM} - {nwHeadFmt.CHAR_FOCUS}" assert formatter.apply(cFormat, "Hi Bob", 0) == "Chapter 2, Scene 3 - Focus" - -# END Test testCoreToken_HeadingFormatter diff --git a/tests/test_core/test_core_tomd.py b/tests/test_core/test_core_tomd.py index db575262..7524502c 100644 --- a/tests/test_core/test_core_tomd.py +++ b/tests/test_core/test_core_tomd.py @@ -71,8 +71,6 @@ def testCoreToMarkdown_ConvertHeaders(mockGUI): toMD.doConvert() assert toMD.result == "## Prologue\n\n" -# END Test testCoreToMarkdown_ConvertHeaders - @pytest.mark.core def testCoreToMarkdown_ConvertParagraphs(mockGUI): @@ -209,8 +207,6 @@ def testCoreToMarkdown_ConvertParagraphs(mockGUI): "1. Footnote text A.\n\n" ) -# END Test testCoreToMarkdown_ConvertParagraphs - @pytest.mark.core def testCoreToMarkdown_ConvertDirect(mockGUI): @@ -250,8 +246,6 @@ def testCoreToMarkdown_ConvertDirect(mockGUI): toMD.doConvert() assert toMD.result == "\n\n" -# END Test testCoreToMarkdown_ConvertDirect - @pytest.mark.core def testCoreToMarkdown_Save(mockGUI, fncPath): @@ -304,8 +298,6 @@ def testCoreToMarkdown_Save(mockGUI, fncPath): toMD.saveMarkdown(saveFile) assert saveFile.read_text(encoding="utf-8") == "".join(resText) -# END Test testCoreToMarkdown_Save - @pytest.mark.core def testCoreToMarkdown_Format(mockGUI): @@ -317,5 +309,3 @@ def testCoreToMarkdown_Format(mockGUI): assert toMD._formatKeywords("tag: Jane", toMD.A_NONE) == "**Tag:** Jane\n\n" assert toMD._formatKeywords("tag: Jane, John", toMD.A_NONE) == "**Tag:** Jane, John\n\n" assert toMD._formatKeywords("tag: Jane", toMD.A_Z_BTMMRG) == "**Tag:** Jane \n" - -# END Test testCoreToMarkdown_Format diff --git a/tests/test_core/test_core_toodt.py b/tests/test_core/test_core_toodt.py index 4231b884..bc7bbf27 100644 --- a/tests/test_core/test_core_toodt.py +++ b/tests/test_core/test_core_toodt.py @@ -105,9 +105,6 @@ def testCoreToOdt_Init(mockGUI): assert odt._xText.tag == _mkTag("office", "text") -# END Test testCoreToOdt_Init - - @pytest.mark.core def testCoreToOdt_TextFormatting(mockGUI): """Test formatting of paragraphs.""" @@ -236,8 +233,6 @@ def testCoreToOdt_TextFormatting(mockGUI): '' ) -# END Test testCoreToOdt_TextFormatting - @pytest.mark.core def testCoreToOdt_ConvertHeaders(mockGUI): @@ -325,8 +320,6 @@ def testCoreToOdt_ConvertHeaders(mockGUI): '' ) -# END Test testCoreToOdt_ConvertHeaders - @pytest.mark.core def testCoreToOdt_ConvertParagraphs(mockGUI): @@ -675,8 +668,6 @@ def testCoreToOdt_ConvertParagraphs(mockGUI): '' ) -# END Test testCoreToOdt_ConvertParagraphs - @pytest.mark.core def testCoreToOdt_ConvertDirect(mockGUI): @@ -730,8 +721,6 @@ def testCoreToOdt_ConvertDirect(mockGUI): '' ) -# END Test testCoreToOdt_ConvertDirect - @pytest.mark.core def testCoreToOdt_SaveFlat(mockGUI, fncPath, tstPaths): @@ -787,8 +776,6 @@ def testCoreToOdt_SaveFlat(mockGUI, fncPath, tstPaths): copyfile(flatFile, testFile) assert cmpFiles(testFile, compFile, ignoreStart=ODT_IGNORE) -# END Test testCoreToOdt_SaveFlat - @pytest.mark.core def testCoreToOdt_SaveFull(mockGUI, fncPath, tstPaths): @@ -867,8 +854,6 @@ def testCoreToOdt_SaveFull(mockGUI, fncPath, tstPaths): assert cmpFiles(metaFile, metaComp, ignoreStart=ODT_IGNORE) assert cmpFiles(stylFile, stylComp) -# END Test testCoreToOdt_SaveFull - @pytest.mark.core def testCoreToOdt_Format(mockGUI): @@ -900,8 +885,6 @@ def testCoreToOdt_Format(mockGUI): "Characters: Bod, Jane", [(0, ToOdt.FMT_B_B, ""), (11, ToOdt.FMT_B_E, "")] ) -# END Test testCoreToOdt_Format - @pytest.mark.core def testCoreToOdt_ODTParagraphStyle(): @@ -1123,8 +1106,6 @@ def testCoreToOdt_ODTParagraphStyle(): assert aStyle.checkNew(oStyle) is True assert aStyle.getID() != oStyle.getID() -# END Test testCoreToOdt_ODTParagraphStyle - @pytest.mark.core def testCoreToOdt_ODTTextStyle(): @@ -1248,8 +1229,6 @@ def testCoreToOdt_ODTTextStyle(): '' ) -# END Test testCoreToOdt_ODTTextStyle - @pytest.mark.core def testCoreToOdt_XMLParagraph(): @@ -1439,8 +1418,6 @@ def testCoreToOdt_XMLParagraph(): assert xmlPar.checkError() == (1, "1 char(s) were not written: 'AB'") -# END Test testCoreToOdt_XMLParagraph - @pytest.mark.core def testCoreToOdt_MkTag(): @@ -1448,5 +1425,3 @@ def testCoreToOdt_MkTag(): assert _mkTag("office", "text") == "{urn:oasis:names:tc:opendocument:xmlns:office:1.0}text" assert _mkTag("style", "text") == "{urn:oasis:names:tc:opendocument:xmlns:style:1.0}text" assert _mkTag("blabla", "text") == "text" - -# END Test testCoreToOdt_MkTag diff --git a/tests/test_core/test_core_tree.py b/tests/test_core/test_core_tree.py index 9e6e146e..421522e2 100644 --- a/tests/test_core/test_core_tree.py +++ b/tests/test_core/test_core_tree.py @@ -20,20 +20,21 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest import random from pathlib import Path -from tools import C, buildTestProject -from mocked import causeOSError +import pytest -from novelwriter.enum import nwItemClass, nwItemType, nwItemLayout from novelwriter.common import isHandle from novelwriter.constants import nwFiles from novelwriter.core.item import NWItem -from novelwriter.core.tree import NWTree from novelwriter.core.project import NWProject +from novelwriter.core.tree import NWTree +from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType + +from tests.mocked import causeOSError +from tests.tools import C, buildTestProject @pytest.fixture(scope="function") @@ -263,8 +264,6 @@ def testCoreTree_BuildTree(mockGUI, mockItems): assert "a000000000003" not in tree assert tree.trashRoot is None -# END Test testCoreTree_BuildTree - @pytest.mark.core def testCoreTree_PackUnpack(mockGUI, mockItems): @@ -292,8 +291,6 @@ def testCoreTree_PackUnpack(mockGUI, mockItems): tree.unpack(packed) assert tree.handles() == aHandles -# END Test testCoreTree_PackUnpack - @pytest.mark.core def testCoreTree_CheckConsistency(caplog: pytest.LogCaptureFixture, mockGUI, fncPath, mockRnd): @@ -361,8 +358,6 @@ def testCoreTree_CheckConsistency(caplog: pytest.LogCaptureFixture, mockGUI, fnc nHandle = project.tree.findRoot(nwItemClass.NOVEL) assert project.tree[nHandle].itemName == "Recovered" # type: ignore -# END Test testCoreTree_CheckConsistency - @pytest.mark.core def testCoreTree_Methods(monkeypatch, mockGUI, mockItems): @@ -442,8 +437,6 @@ def testCoreTree_Methods(monkeypatch, mockGUI, mockItems): "c000000000001", "b000000000001", "a000000000001" ] -# END Test testCoreTree_Methods - @pytest.mark.core def testCoreTree_MakeHandles(mockGUI): @@ -471,8 +464,6 @@ def testCoreTree_MakeHandles(mockGUI): tHandle = tree._makeHandle() assert tHandle == handles[3] -# END Test testCoreTree_MakeHandles - @pytest.mark.core def testCoreTree_Stats(mockGUI, mockItems): @@ -491,8 +482,6 @@ def testCoreTree_Stats(mockGUI, mockItems): assert novelWords == 550 assert noteWords == 400 -# END Test testCoreTree_Stats - @pytest.mark.core def testCoreTree_Reorder(caplog, mockGUI, mockItems): @@ -526,8 +515,6 @@ def testCoreTree_Reorder(caplog, mockGUI, mockItems): assert tree.handles() == bHandle assert "Handle 'stuff' in old tree order is not in new order" in caplog.text -# END Test testCoreTree_Reorder - @pytest.mark.core def testCoreTree_ToCFile(monkeypatch, fncPath, mockGUI, mockItems): @@ -582,5 +569,3 @@ def testCoreTree_ToCFile(monkeypatch, fncPath, mockGUI, mockItems): f"{pathB} NOVEL DOCUMENT Scene One\n" f"{pathC} CHARACTER NOTE Jane Doe\n" ) - -# END Test testCoreTree_ToCFile diff --git a/tests/test_dialogs/test_dlg_about.py b/tests/test_dialogs/test_dlg_about.py index f3fbf0cb..01748dcd 100644 --- a/tests/test_dialogs/test_dlg_about.py +++ b/tests/test_dialogs/test_dlg_about.py @@ -20,10 +20,10 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - from pathlib import Path +import pytest + from PyQt5.QtWidgets import QAction, QMessageBox from novelwriter import SHARED @@ -49,8 +49,6 @@ def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI): msgAbout.close() -# END Test testDlgAbout_NWDialog - @pytest.mark.gui def testDlgAbout_QtDialog(monkeypatch, nwGUI): @@ -61,5 +59,3 @@ def testDlgAbout_QtDialog(monkeypatch, nwGUI): # All it can do is check against a crash nwGUI.showAboutQtDialog() nwGUI.mainMenu.aAboutQt.activate(QAction.Trigger) - -# END Test testDlgAbout_QtDialog diff --git a/tests/test_dialogs/test_dlg_dialogs.py b/tests/test_dialogs/test_dlg_dialogs.py index 2a25f65e..68b28b95 100644 --- a/tests/test_dialogs/test_dlg_dialogs.py +++ b/tests/test_dialogs/test_dlg_dialogs.py @@ -23,10 +23,10 @@ from __future__ import annotations import pytest from PyQt5.QtCore import QItemSelectionModel -from PyQt5.QtWidgets import QListWidgetItem, QDialog +from PyQt5.QtWidgets import QDialog, QListWidgetItem -from novelwriter.dialogs.quotes import GuiQuoteSelect from novelwriter.dialogs.editlabel import GuiEditLabel +from novelwriter.dialogs.quotes import GuiQuoteSelect @pytest.mark.gui @@ -62,8 +62,6 @@ def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI): # qtbot.stop() -# END Test testDlgOther_QuoteSelect - @pytest.mark.gui def testDlgOther_EditLabel(qtbot, monkeypatch): @@ -81,5 +79,3 @@ def testDlgOther_EditLabel(qtbot, monkeypatch): newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World") # type: ignore assert dlgOk is False assert newLabel == "Hello World" - -# END Test testDlgOther_EditLabel diff --git a/tests/test_dialogs/test_dlg_docmerge.py b/tests/test_dialogs/test_dlg_docmerge.py index 2653f256..3f85a13e 100644 --- a/tests/test_dialogs/test_dlg_docmerge.py +++ b/tests/test_dialogs/test_dlg_docmerge.py @@ -22,13 +22,13 @@ from __future__ import annotations import pytest -from tools import buildTestProject, C - from PyQt5.QtCore import Qt from novelwriter.dialogs.docmerge import GuiDocMerge from novelwriter.types import QtUserRole +from tests.tools import C, buildTestProject + @pytest.mark.gui def testDlgMerge_Main(qtbot, nwGUI, projPath, mockRnd): @@ -86,5 +86,3 @@ def testDlgMerge_Main(qtbot, nwGUI, projPath, mockRnd): assert data["finalItems"] == [C.hChapterDoc, C.hSceneDoc] # qtbot.stop() - -# END Test testDlgMerge_Main diff --git a/tests/test_dialogs/test_dlg_docsplit.py b/tests/test_dialogs/test_dlg_docsplit.py index 8f1815fb..f24bf326 100644 --- a/tests/test_dialogs/test_dlg_docsplit.py +++ b/tests/test_dialogs/test_dlg_docsplit.py @@ -22,12 +22,12 @@ from __future__ import annotations import pytest -from tools import C, buildTestProject - from novelwriter import SHARED from novelwriter.dialogs.docsplit import GuiDocSplit from novelwriter.dialogs.editlabel import GuiEditLabel +from tests.tools import C, buildTestProject + @pytest.mark.gui def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -98,5 +98,3 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd): nwSplit.reject() # qtbot.stop() - -# END Test testDlgSplit_Main diff --git a/tests/test_dialogs/test_dlg_preferences.py b/tests/test_dialogs/test_dlg_preferences.py index d193240f..59e705ff 100644 --- a/tests/test_dialogs/test_dlg_preferences.py +++ b/tests/test_dialogs/test_dlg_preferences.py @@ -22,8 +22,8 @@ from __future__ import annotations import pytest -from PyQt5.QtGui import QFontDatabase, QKeyEvent from PyQt5.QtCore import QEvent, Qt +from PyQt5.QtGui import QFontDatabase, QKeyEvent from PyQt5.QtWidgets import QAction, QFileDialog, QFontDialog from novelwriter import CONFIG, SHARED @@ -86,8 +86,6 @@ def testDlgPreferences_Main(qtbot, monkeypatch, nwGUI, tstPaths): # qtbot.stop() -# END Test testDlgPreferences_Main - @pytest.mark.gui def testDlgPreferences_Actions(qtbot, monkeypatch, nwGUI): @@ -148,8 +146,6 @@ def testDlgPreferences_Actions(qtbot, monkeypatch, nwGUI): # qtbot.stop() -# END Test testDlgPreferences_Actions - @pytest.mark.gui def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths): @@ -411,5 +407,3 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths): assert CONFIG.fmtDQuoteClose == nwUnicode.U_RAQUO # qtbot.stop() - -# END Test testDlgPreferences_Settings diff --git a/tests/test_dialogs/test_dlg_projectsettings.py b/tests/test_dialogs/test_dlg_projectsettings.py index 498dfda5..48be942b 100644 --- a/tests/test_dialogs/test_dlg_projectsettings.py +++ b/tests/test_dialogs/test_dlg_projectsettings.py @@ -22,10 +22,8 @@ from __future__ import annotations import pytest -from tools import C, buildTestProject - from PyQt5.QtGui import QColor -from PyQt5.QtWidgets import QDialog, QAction, QColorDialog +from PyQt5.QtWidgets import QAction, QColorDialog, QDialog from novelwriter import CONFIG, SHARED from novelwriter.dialogs.editlabel import GuiEditLabel @@ -33,6 +31,8 @@ from novelwriter.dialogs.projectsettings import GuiProjectSettings from novelwriter.enum import nwItemType, nwStatusShape from novelwriter.types import QtMouseLeft +from tests.tools import C, buildTestProject + KEY_DELAY = 1 @@ -81,8 +81,6 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI): projSettings.close() # qtbot.stop() -# END Test testDlgProjSettings_Dialog - @pytest.mark.gui def testDlgProjSettings_SettingsPage(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd): @@ -135,8 +133,6 @@ def testDlgProjSettings_SettingsPage(qtbot, monkeypatch, nwGUI, fncPath, projPat # qtbot.stop() -# END Test testDlgProjSettings_SettingsPage - @pytest.mark.gui def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -324,8 +320,6 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, projPath, mockRn # qtbot.stop() -# END Test testDlgProjSettings_StatusImport - @pytest.mark.gui def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -404,5 +398,3 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, projPath, mockRnd): } # qtbot.stop() - -# END Test testDlgProjSettings_Replace diff --git a/tests/test_dialogs/test_dlg_wordlist.py b/tests/test_dialogs/test_dlg_wordlist.py index 4972481d..085de7b2 100644 --- a/tests/test_dialogs/test_dlg_wordlist.py +++ b/tests/test_dialogs/test_dlg_wordlist.py @@ -23,15 +23,15 @@ from __future__ import annotations import pytest from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QDialog, QAction, QFileDialog - -from tools import buildTestProject -from mocked import causeOSError +from PyQt5.QtWidgets import QAction, QDialog, QFileDialog from novelwriter import SHARED from novelwriter.core.spellcheck import UserDictionary from novelwriter.dialogs.wordlist import GuiWordList +from tests.mocked import causeOSError +from tests.tools import buildTestProject + @pytest.mark.gui def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, fncPath, projPath): @@ -161,5 +161,3 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, fncPath, projPath): assert "word_i" in userDict # qtbot.stop() - -# END Test testDlgWordList_Dialog diff --git a/tests/test_ext/test_ext_eventfilters.py b/tests/test_ext/test_ext_eventfilters.py index a68a2eb9..142536fb 100644 --- a/tests/test_ext/test_ext_eventfilters.py +++ b/tests/test_ext/test_ext_eventfilters.py @@ -22,8 +22,8 @@ from __future__ import annotations import pytest -from PyQt5.QtGui import QKeyEvent, QWheelEvent from PyQt5.QtCore import QEvent, QObject, QPoint, Qt +from PyQt5.QtGui import QKeyEvent, QWheelEvent from PyQt5.QtWidgets import QWidget from novelwriter.extensions.eventfilters import WheelEventFilter @@ -65,5 +65,3 @@ def testExtEventFilters_WheelEventFilter(): eFilter._locked = True eFilter.eventFilter(obj, event) assert widget.count == 1 - -# END Test testExtEventFilters_WheelEventFilter diff --git a/tests/test_ext/test_ext_modified.py b/tests/test_ext/test_ext_modified.py index 151e3be9..2158bf60 100644 --- a/tests/test_ext/test_ext_modified.py +++ b/tests/test_ext/test_ext_modified.py @@ -24,10 +24,11 @@ import pytest from PyQt5.QtCore import QPoint, QPointF, Qt from PyQt5.QtGui import QWheelEvent -from tools import SimpleDialog from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NSpinBox +from tests.tools import SimpleDialog + class MockWheelEvent(QWheelEvent): @@ -70,8 +71,6 @@ def testExtModified_NComboBox(qtbot, monkeypatch): # qtbot.stop() -# END Test testExtModified_NComboBox - @pytest.mark.gui def testExtModified_NSpinBox(qtbot, monkeypatch): @@ -98,8 +97,6 @@ def testExtModified_NSpinBox(qtbot, monkeypatch): # qtbot.stop() -# END Test testExtModified_NSpinBox - @pytest.mark.gui def testExtModified_NDoubleSpinBox(qtbot, monkeypatch): @@ -125,5 +122,3 @@ def testExtModified_NDoubleSpinBox(qtbot, monkeypatch): assert event.ignored is True # qtbot.stop() - -# END Test testExtModified_NDoubleSpinBox diff --git a/tests/test_ext/test_ext_versioninfo.py b/tests/test_ext/test_ext_versioninfo.py index b30fb19c..14237fba 100644 --- a/tests/test_ext/test_ext_versioninfo.py +++ b/tests/test_ext/test_ext_versioninfo.py @@ -20,11 +20,9 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - from urllib.error import HTTPError -from tools import SimpleDialog +import pytest from PyQt5.QtCore import QUrl @@ -32,6 +30,8 @@ from novelwriter import SHARED from novelwriter.constants import nwConst from novelwriter.extensions.versioninfo import VersionInfoWidget, _Retriever, _RetrieverSignal +from tests.tools import SimpleDialog + class MockRetriever: signals = _RetrieverSignal() @@ -120,8 +120,6 @@ def testExtVersionInfo_Main(qtbot, monkeypatch): dialog.close() # qtbot.stop() -# END Test testExtVersionInfo_Main - @pytest.mark.gui def testExtVersionInfo_Retriever(qtbot, monkeypatch): @@ -151,5 +149,3 @@ def testExtVersionInfo_Retriever(qtbot, monkeypatch): with qtbot.waitSignal(task.signals.dataReady) as signal: task.run() assert signal.args == ["", "Oh noes!"] - -# END Test testExtVersionInfo_Retriever diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index 24ad4f10..30e199d0 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -134,8 +134,6 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd): # qtbot.stop() -# END Test testGuiEditor_Init - @pytest.mark.gui def testGuiEditor_LoadText(qtbot, nwGUI, projPath, ipsumText, mockRnd): @@ -168,8 +166,6 @@ def testGuiEditor_LoadText(qtbot, nwGUI, projPath, ipsumText, mockRnd): # qtbot.stop() -# END Test testGuiEditor_LoadText - @pytest.mark.gui def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumText, mockRnd): @@ -209,8 +205,6 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex # qtbot.stop() -# END Test testGuiEditor_SaveText - @pytest.mark.gui def testGuiEditor_MetaData(qtbot, nwGUI, projPath, mockRnd): @@ -261,8 +255,6 @@ def testGuiEditor_MetaData(qtbot, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testGuiEditor_MetaData - @pytest.mark.gui def testGuiEditor_ContextMenu(monkeypatch, qtbot, nwGUI, projPath, mockRnd): @@ -390,8 +382,6 @@ def testGuiEditor_ContextMenu(monkeypatch, qtbot, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testGuiEditor_ContextMenu - @pytest.mark.gui def testGuiEditor_SpellChecking(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd): @@ -474,8 +464,6 @@ def testGuiEditor_SpellChecking(qtbot, monkeypatch, nwGUI, projPath, ipsumText, # qtbot.stop() -# END Test testGuiEditor_SpellChecking - @pytest.mark.gui def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd): @@ -767,8 +755,6 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd): # qtbot.stop() -# END Test testGuiEditor_Actions - @pytest.mark.gui def testGuiEditor_ToolBar(qtbot, nwGUI, projPath, mockRnd): @@ -871,8 +857,6 @@ def testGuiEditor_ToolBar(qtbot, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testGuiEditor_ToolBar - @pytest.mark.gui def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd): @@ -974,8 +958,6 @@ def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd # qtbot.stop() -# END Test testGuiEditor_Insert - @pytest.mark.gui def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd): @@ -1187,8 +1169,6 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd): # qtbot.stop() -# END Test testGuiEditor_TextManipulation - @pytest.mark.gui def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd): @@ -1525,8 +1505,6 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText # qtbot.stop() -# END Test testGuiEditor_BlockFormatting - @pytest.mark.gui def testGuiEditor_MultiBlockFormatting(qtbot, nwGUI, projPath, ipsumText, mockRnd): @@ -1600,8 +1578,6 @@ def testGuiEditor_MultiBlockFormatting(qtbot, nwGUI, projPath, ipsumText, mockRn # qtbot.stop() -# END Test testGuiEditor_MultiBlockFormatting - @pytest.mark.gui def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd): @@ -1678,8 +1654,6 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd): # qtbot.stop() -# END Test testGuiEditor_Tags - @pytest.mark.gui def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd): @@ -1779,8 +1753,6 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testGuiEditor_Completer - @pytest.mark.gui def testGuiEditor_CursorVisibility(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -1817,8 +1789,6 @@ def testGuiEditor_CursorVisibility(qtbot, monkeypatch, nwGUI, projPath, mockRnd) # qtbot.stop() -# END Test testGuiEditor_CursorVisibility - @pytest.mark.gui def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd): @@ -1895,8 +1865,6 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, m # qtbot.stop() -# END Test testGuiEditor_WordCounters - @pytest.mark.gui def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum): @@ -2175,8 +2143,6 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum): # qtbot.stop() -# END Test testGuiEditor_Search - @pytest.mark.gui def testGuiEditor_StaticMethods(): @@ -2200,5 +2166,3 @@ def testGuiEditor_StaticMethods(): assert GuiDocEditor._allowSpaceBeforeColon("% Synopsis:", ":") is False assert GuiDocEditor._allowSpaceBeforeColon("%synopsis :", ":") is True assert GuiDocEditor._allowSpaceBeforeColon("%Synopsis :", ":") is True - -# END Test testGuiEditor_StaticMethods diff --git a/tests/test_gui/test_gui_docviewer.py b/tests/test_gui/test_gui_docviewer.py index dcea6af8..b8d0bb4c 100644 --- a/tests/test_gui/test_gui_docviewer.py +++ b/tests/test_gui/test_gui_docviewer.py @@ -22,17 +22,17 @@ from __future__ import annotations import pytest -from mocked import causeException - from PyQt5.QtCore import QEvent, QPoint, Qt, QUrl from PyQt5.QtGui import QMouseEvent, QTextCursor from PyQt5.QtWidgets import QAction, QApplication, QMenu from novelwriter import CONFIG, SHARED -from novelwriter.enum import nwDocAction from novelwriter.core.tohtml import ToHtml +from novelwriter.enum import nwDocAction from novelwriter.gui.docviewer import GuiDocViewer -from novelwriter.types import QtMouseLeft, QtModeNone +from novelwriter.types import QtModeNone, QtMouseLeft + +from tests.mocked import causeException @pytest.mark.gui @@ -217,5 +217,3 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum): docViewer.updateTheme() # qtbot.stop() - -# END Test testGuiViewer_Main diff --git a/tests/test_gui/test_gui_docviewerpanel.py b/tests/test_gui/test_gui_docviewerpanel.py index 9b35bfe4..b53cb626 100644 --- a/tests/test_gui/test_gui_docviewerpanel.py +++ b/tests/test_gui/test_gui_docviewerpanel.py @@ -22,8 +22,6 @@ from __future__ import annotations import pytest -from tools import C, buildTestProject - from PyQt5.QtGui import QIcon from novelwriter import SHARED @@ -31,6 +29,8 @@ from novelwriter.constants import nwLists from novelwriter.core.item import NWItem from novelwriter.dialogs.editlabel import GuiEditLabel +from tests.tools import C, buildTestProject + @pytest.mark.gui def testGuiViewerPanel_BackRefs(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -120,8 +120,6 @@ def testGuiViewerPanel_BackRefs(qtbot, monkeypatch, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testGuiViewerPanel_BackRefs - @pytest.mark.gui def testGuiViewerPanel_Tags(qtbot, monkeypatch, caplog, nwGUI, projPath, mockRnd): @@ -228,5 +226,3 @@ def testGuiViewerPanel_Tags(qtbot, monkeypatch, caplog, nwGUI, projPath, mockRnd assert charTab.topLevelItemCount() == 1 # qtbot.stop() - -# END Test testGuiViewerPanel_Tags diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py index 2a2205e8..4027a953 100644 --- a/tests/test_gui/test_gui_guimain.py +++ b/tests/test_gui/test_gui_guimain.py @@ -54,8 +54,6 @@ def testGuiMain_ProjectBlocker(nwGUI): assert nwGUI.viewDocument(None) is False assert nwGUI.importDocument() is False -# END Test testGuiMain_ProjectBlocker - @pytest.mark.gui def testGuiMain_Launch(qtbot, monkeypatch, nwGUI, projPath): @@ -95,8 +93,6 @@ def testGuiMain_Launch(qtbot, monkeypatch, nwGUI, projPath): # qtbot.stop() -# END Test testGuiMain_Launch - @pytest.mark.gui def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -145,8 +141,6 @@ def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testGuiMain_ProjectTreeItems - @pytest.mark.gui def testGuiMain_UpdateTheme(qtbot, nwGUI): @@ -167,8 +161,6 @@ def testGuiMain_UpdateTheme(qtbot, nwGUI): # qtbot.stop() -# END Test testGuiMain_UpdateTheme - @pytest.mark.gui def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd): @@ -566,8 +558,6 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd): # qtbot.stop() -# END Test testGuiMain_Editing - @pytest.mark.gui def testGuiMain_Features(qtbot, nwGUI, projPath, mockRnd): @@ -622,5 +612,3 @@ def testGuiMain_Features(qtbot, nwGUI, projPath, mockRnd): nwGUI.sideBar.mSettings.hide() # qtbot.stop() - -# END Test testGuiMain_Features diff --git a/tests/test_gui/test_gui_i18n.py b/tests/test_gui/test_gui_i18n.py index 941c140d..93f333a7 100644 --- a/tests/test_gui/test_gui_i18n.py +++ b/tests/test_gui/test_gui_i18n.py @@ -21,23 +21,24 @@ along with this program. If not, see . from __future__ import annotations import sys -import pytest -from tools import buildTestProject +import pytest from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox from novelwriter import CONFIG, SHARED from novelwriter.dialogs.about import GuiAbout -from novelwriter.dialogs.wordlist import GuiWordList from novelwriter.dialogs.preferences import GuiPreferences from novelwriter.dialogs.projectsettings import GuiProjectSettings -from novelwriter.tools.welcome import GuiWelcome -from novelwriter.tools.manuscript import GuiManuscript +from novelwriter.dialogs.wordlist import GuiWordList from novelwriter.tools.dictionaries import GuiDictionaries +from novelwriter.tools.manuscript import GuiManuscript from novelwriter.tools.noveldetails import GuiNovelDetails +from novelwriter.tools.welcome import GuiWelcome from novelwriter.tools.writingstats import GuiWritingStats +from tests.tools import buildTestProject + LANG_DATA = CONFIG.listLanguages(CONFIG.LANG_NW) @@ -79,5 +80,3 @@ def testGuiI18n_Localisation(qtbot, monkeypatch, language, nwGUI, projPath): qtbot.wait(20) nwGUI.closeMain() - -# END Test testGuiI18n_Localisation diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index ce2a981a..5b0ef538 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -24,7 +24,6 @@ import pytest from PyQt5.QtGui import QTextBlock, QTextCursor from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox -from tools import C, buildTestProject, writeFile from novelwriter import CONFIG, SHARED from novelwriter.constants import nwKeyWords, nwUnicode @@ -32,6 +31,8 @@ from novelwriter.enum import nwDocAction, nwDocInsert from novelwriter.gui.doceditor import GuiDocEditor from novelwriter.types import QtMouseLeft +from tests.tools import C, buildTestProject, writeFile + @pytest.mark.gui def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum): @@ -342,8 +343,6 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum): # qtbot.stop() -# END Test testGuiMenu_EditFormat - @pytest.mark.gui def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum): @@ -421,8 +420,6 @@ def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum): # qtbot.stop() -# END Test testGuiMenu_ContextMenus - @pytest.mark.gui def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd): @@ -664,5 +661,3 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd): assert SHARED.lastAlert.endswith(f"File Location: {path}") # qtbot.stop() - -# END Test testGuiMenu_Insert diff --git a/tests/test_gui/test_gui_noveltree.py b/tests/test_gui/test_gui_noveltree.py index 12cab27a..8878c540 100644 --- a/tests/test_gui/test_gui_noveltree.py +++ b/tests/test_gui/test_gui_noveltree.py @@ -20,22 +20,22 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - from pathlib import Path -from tools import C, buildTestProject +import pytest -from PyQt5.QtCore import QPoint, Qt, QEvent +from PyQt5.QtCore import QEvent, QPoint, Qt from PyQt5.QtGui import QFocusEvent from PyQt5.QtWidgets import QInputDialog, QToolTip from novelwriter import CONFIG, SHARED from novelwriter.dialogs.editlabel import GuiEditLabel -from novelwriter.enum import nwWidget, nwItemType +from novelwriter.enum import nwItemType, nwWidget from novelwriter.gui.noveltree import GuiNovelTree, NovelTreeColumn from novelwriter.types import QtMouseLeft +from tests.tools import C, buildTestProject + @pytest.mark.gui def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -233,5 +233,3 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd): # qtbot.stop() nwGUI.closeProject() - -# END Test testGuiNovelTree_TreeItems diff --git a/tests/test_gui/test_gui_outline.py b/tests/test_gui/test_gui_outline.py index 1aa0565f..7f059ff5 100644 --- a/tests/test_gui/test_gui_outline.py +++ b/tests/test_gui/test_gui_outline.py @@ -21,18 +21,19 @@ along with this program. If not, see . from __future__ import annotations import time -import pytest from shutil import copyfile -from tools import buildTestProject, cmpFiles, writeFile +import pytest from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QFileDialog, QWidget, QAction +from PyQt5.QtWidgets import QAction, QFileDialog, QWidget from novelwriter import CONFIG, SHARED from novelwriter.enum import nwItemClass, nwOutline, nwView +from tests.tools import buildTestProject, cmpFiles, writeFile + @pytest.mark.gui def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, projPath): @@ -173,8 +174,6 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, projPath): # qtbot.stop() -# END Test testGuiOutline_Main - @pytest.mark.gui def testGuiOutline_Content(qtbot, monkeypatch, nwGUI, prjLipsum, fncPath, tstPaths): @@ -296,5 +295,3 @@ def testGuiOutline_Content(qtbot, monkeypatch, nwGUI, prjLipsum, fncPath, tstPat assert cmpFiles(testFile, compFile) # qtbot.stop() - -# END Test testGuiOutline_Content diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py index 49ce464e..7a1ca6fa 100644 --- a/tests/test_gui/test_gui_projtree.py +++ b/tests/test_gui/test_gui_projtree.py @@ -20,16 +20,13 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - from pathlib import Path -from mocked import causeOSError -from tools import C, buildTestProject +import pytest -from PyQt5.QtCore import QEvent, QMimeData, QPoint, QTimer, Qt +from PyQt5.QtCore import QEvent, QMimeData, QPoint, Qt, QTimer from PyQt5.QtGui import QDragEnterEvent, QDragMoveEvent, QDropEvent, QMouseEvent -from PyQt5.QtWidgets import QMessageBox, QMenu, QTreeWidget, QTreeWidgetItem, QDialog +from PyQt5.QtWidgets import QDialog, QMenu, QMessageBox, QTreeWidget, QTreeWidgetItem from novelwriter import CONFIG, SHARED from novelwriter.core.item import NWItem @@ -37,10 +34,13 @@ from novelwriter.core.project import NWProject from novelwriter.dialogs.docmerge import GuiDocMerge from novelwriter.dialogs.docsplit import GuiDocSplit from novelwriter.dialogs.editlabel import GuiEditLabel -from novelwriter.enum import nwItemLayout, nwItemType, nwItemClass, nwWidget +from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType, nwWidget from novelwriter.gui.projtree import GuiProjectTree, GuiProjectView, _TreeContextMenu from novelwriter.guimain import GuiMain -from novelwriter.types import QtMouseLeft, QtMouseMiddle, QtModeNone +from novelwriter.types import QtModeNone, QtMouseLeft, QtMouseMiddle + +from tests.mocked import causeOSError +from tests.tools import C, buildTestProject @pytest.mark.gui @@ -190,8 +190,6 @@ def testGuiProjTree_NewItems(qtbot, caplog, monkeypatch, nwGUI, projPath, mockRn # qtbot.stop() nwGUI.closeProject() -# END Test testGuiProjTree_NewItems - @pytest.mark.gui def testGuiProjTree_MoveItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -294,8 +292,6 @@ def testGuiProjTree_MoveItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd): # qtbot.stop() nwGUI.closeProject() -# END Test testGuiProjTree_MoveItems - @pytest.mark.gui def testGuiProjTree_RequestDeleteItem(qtbot, caplog, monkeypatch, nwGUI, projPath, mockRnd): @@ -376,8 +372,6 @@ def testGuiProjTree_RequestDeleteItem(qtbot, caplog, monkeypatch, nwGUI, projPat nwGUI.closeProject() -# END Test testGuiProjTree_RequestDeleteItem - @pytest.mark.gui def testGuiProjTree_MoveItemToTrash(qtbot, caplog, monkeypatch, nwGUI, projPath, mockRnd): @@ -428,8 +422,6 @@ def testGuiProjTree_MoveItemToTrash(qtbot, caplog, monkeypatch, nwGUI, projPath, nwGUI.closeProject() -# END Test testGuiProjTree_MoveItemToTrash - @pytest.mark.gui def testGuiProjTree_PermanentlyDeleteItem(qtbot, caplog, monkeypatch, nwGUI, projPath, mockRnd): @@ -479,8 +471,6 @@ def testGuiProjTree_PermanentlyDeleteItem(qtbot, caplog, monkeypatch, nwGUI, pro nwGUI.closeProject() -# END Test testGuiProjTree_PermanentlyDeleteItem - @pytest.mark.gui def testGuiProjTree_EmptyTrash(qtbot, caplog, monkeypatch, nwGUI, projPath, mockRnd): @@ -531,8 +521,6 @@ def testGuiProjTree_EmptyTrash(qtbot, caplog, monkeypatch, nwGUI, projPath, mock nwGUI.closeProject() -# END Test testGuiProjTree_EmptyTrash - @pytest.mark.gui def testGuiProjTree_MergeDocuments(qtbot, monkeypatch, nwGUI, projPath, mockRnd, ipsumText): @@ -631,8 +619,6 @@ def testGuiProjTree_MergeDocuments(qtbot, monkeypatch, nwGUI, projPath, mockRnd, # qtbot.stop() -# END Test testGuiProjTree_MergeDocuments - @pytest.mark.gui def testGuiProjTree_SplitDocument(qtbot, monkeypatch, nwGUI, projPath, mockRnd, ipsumText): @@ -741,8 +727,6 @@ def testGuiProjTree_SplitDocument(qtbot, monkeypatch, nwGUI, projPath, mockRnd, # qtbot.stop() -# END Test testGuiProjTree_SplitDocument - @pytest.mark.gui def testGuiProjTree_Duplicate(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mockRnd): @@ -798,8 +782,6 @@ def testGuiProjTree_Duplicate(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mock # qtbot.stop() -# END Test testGuiProjTree_Duplicate - @pytest.mark.gui def testGuiProjTree_AutoScroll(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mockRnd): @@ -864,8 +846,6 @@ def testGuiProjTree_AutoScroll(qtbot, monkeypatch, nwGUI: GuiMain, projPath, moc # qtbot.stop() -# END Test testGuiProjTree_AutoScroll - @pytest.mark.gui def testGuiProjTree_DragAndDrop(qtbot, monkeypatch, caplog, nwGUI: GuiMain, projPath, mockRnd): @@ -954,8 +934,6 @@ def testGuiProjTree_DragAndDrop(qtbot, monkeypatch, caplog, nwGUI: GuiMain, proj # qtbot.stop() -# END Test testGuiProjTree_DragAndDrop - @pytest.mark.gui def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mockRnd): @@ -1120,8 +1098,6 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mockRnd) # qtbot.stop() -# END Test testGuiProjTree_Other - @pytest.mark.gui def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -1421,8 +1397,6 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testGuiProjTree_ContextMenu - @pytest.mark.gui def testGuiProjTree_Templates(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -1515,5 +1489,3 @@ def testGuiProjTree_Templates(qtbot, monkeypatch, nwGUI, projPath, mockRnd): assert projBar.mTemplates.menuAction().isVisible() is False # qtbot.stop() - -# END Test testGuiProjTree_Templates diff --git a/tests/test_gui/test_gui_search.py b/tests/test_gui/test_gui_search.py index 2b96514d..d46f6871 100644 --- a/tests/test_gui/test_gui_search.py +++ b/tests/test_gui/test_gui_search.py @@ -129,5 +129,3 @@ def testGuiDocSearch_Main(qtbot, monkeypatch, nwGUI, prjLipsum): # qtbot.stop() nwGUI.closeProject() - -# END Test testGuiDocSearch_Main diff --git a/tests/test_gui/test_gui_statusbar.py b/tests/test_gui/test_gui_statusbar.py index 89dd50c6..228f6896 100644 --- a/tests/test_gui/test_gui_statusbar.py +++ b/tests/test_gui/test_gui_statusbar.py @@ -21,13 +21,14 @@ along with this program. If not, see . from __future__ import annotations import time -import pytest -from tools import C, buildTestProject +import pytest from novelwriter import CONFIG, SHARED from novelwriter.extensions.statusled import StatusLED +from tests.tools import C, buildTestProject + @pytest.mark.gui def testGuiStatusBar_Main(qtbot, nwGUI, projPath, mockRnd): @@ -93,5 +94,3 @@ def testGuiStatusBar_Main(qtbot, nwGUI, projPath, mockRnd): assert nwGUI.mainStatus.statsText.text() == "Words: 11 (+11)" # qtbot.stop() - -# END Test testGuiStatusBar_Init diff --git a/tests/test_gui/test_gui_theme.py b/tests/test_gui/test_gui_theme.py index 5c4cf341..e5431b65 100644 --- a/tests/test_gui/test_gui_theme.py +++ b/tests/test_gui/test_gui_theme.py @@ -125,8 +125,6 @@ def testGuiTheme_Main(qtbot, nwGUI, tstPaths): # qtbot.stop() -# END Test testGuiTheme_Main - @pytest.mark.gui def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI): @@ -212,8 +210,6 @@ def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI): # qtbot.stop() -# END Test testGuiTheme_Theme - @pytest.mark.gui def testGuiTheme_Syntax(qtbot, monkeypatch, nwGUI): @@ -277,8 +273,6 @@ def testGuiTheme_Syntax(qtbot, monkeypatch, nwGUI): # qtbot.stop() -# END Test testGuiTheme_Syntax - @pytest.mark.gui def testGuiTheme_IconThemes(qtbot, caplog, monkeypatch, tstPaths): @@ -325,8 +319,6 @@ def testGuiTheme_IconThemes(qtbot, caplog, monkeypatch, tstPaths): # qtbot.stop() -# END Test testGuiTheme_IconThemes - @pytest.mark.gui def testGuiTheme_LoadIcons(qtbot): @@ -432,8 +424,6 @@ def testGuiTheme_LoadIcons(qtbot): # qtbot.stop() -# END Test testGuiTheme_LoadIcons - @pytest.mark.gui def testGuiTheme_LoadDecorations(qtbot, monkeypatch): @@ -498,5 +488,3 @@ def testGuiTheme_LoadDecorations(qtbot, monkeypatch): assert iconCache.getHeaderDecorationNarrow(6) == iconCache._headerDecNarrow[5] # qtbot.stop() - -# END Test testGuiTheme_LoadDecorations diff --git a/tests/test_text/test_core_counting.py b/tests/test_text/test_core_counting.py index 05780c49..3606e802 100644 --- a/tests/test_text/test_core_counting.py +++ b/tests/test_text/test_core_counting.py @@ -71,8 +71,6 @@ def testTextCounting_preProcessText(): "Dashes and even longer dashes.", "" ] -# END Test testTextCounting_preProcessText - @pytest.mark.core def testTextCounting_standardCounter(): @@ -180,8 +178,6 @@ def testTextCounting_standardCounter(): assert wC == 14 assert pC == 2 -# END Test testTextCounting_standardCounter - @pytest.mark.core def testTextCounting_bodyTextCounter(): @@ -207,5 +203,3 @@ def testTextCounting_bodyTextCounter(): assert wC == 14 assert cC == 91 assert sC == 81 - -# END Test testTextCounting_bodyTextCounter diff --git a/tests/test_tools/test_tools_dictionaries.py b/tests/test_tools/test_tools_dictionaries.py index 9f11d51c..1b3bd4f8 100644 --- a/tests/test_tools/test_tools_dictionaries.py +++ b/tests/test_tools/test_tools_dictionaries.py @@ -20,12 +20,10 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest -import enchant - from zipfile import ZipFile -from mocked import causeException +import enchant +import pytest from PyQt5.QtGui import QDesktopServices from PyQt5.QtWidgets import QFileDialog @@ -33,6 +31,8 @@ from PyQt5.QtWidgets import QFileDialog from novelwriter import SHARED from novelwriter.tools.dictionaries import GuiDictionaries +from tests.mocked import causeException + @pytest.mark.gui def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath): @@ -153,5 +153,3 @@ def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath): # Close nwDicts._doClose() # qtbot.stop() - -# END Test testToolDictionaries_Main diff --git a/tests/test_tools/test_tools_lipsum.py b/tests/test_tools/test_tools_lipsum.py index b2ecc445..8720a376 100644 --- a/tests/test_tools/test_tools_lipsum.py +++ b/tests/test_tools/test_tools_lipsum.py @@ -22,13 +22,13 @@ from __future__ import annotations import pytest -from tools import C, buildTestProject - from PyQt5.QtWidgets import QAction from novelwriter import SHARED from novelwriter.tools.lipsum import GuiLipsum +from tests.tools import C, buildTestProject + @pytest.mark.gui def testToolLipsum_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd): @@ -66,5 +66,3 @@ def testToolLipsum_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd): assert nwGUI.docEditor.getText() == "### New Scene\n\nFooBar" # qtbot.stop() - -# END Test testToolLipsum_Main diff --git a/tests/test_tools/test_tools_manusbuild.py b/tests/test_tools/test_tools_manusbuild.py index 6497cb3c..a1ca1175 100644 --- a/tests/test_tools/test_tools_manusbuild.py +++ b/tests/test_tools/test_tools_manusbuild.py @@ -20,16 +20,14 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - from pathlib import Path -from pytestqt.qtbot import QtBot -from tools import buildTestProject +import pytest from PyQt5.QtCore import QUrl from PyQt5.QtGui import QDesktopServices from PyQt5.QtWidgets import QFileDialog, QListWidgetItem, QMessageBox +from pytestqt.qtbot import QtBot from novelwriter.constants import nwLabels from novelwriter.core.buildsettings import BuildSettings @@ -38,6 +36,8 @@ from novelwriter.guimain import GuiMain from novelwriter.tools.manusbuild import GuiManuscriptBuild from novelwriter.types import QtDialogClose +from tests.tools import buildTestProject + @pytest.mark.gui def testManuscriptBuild_Main( @@ -152,5 +152,3 @@ def testManuscriptBuild_Main( # Finish manus._dialogButtonClicked(manus.dlgButtons.button(QtDialogClose)) # qtbot.stop() - -# END Test testManuscriptBuild_Main diff --git a/tests/test_tools/test_tools_manuscript.py b/tests/test_tools/test_tools_manuscript.py index accfa950..5d0c928c 100644 --- a/tests/test_tools/test_tools_manuscript.py +++ b/tests/test_tools/test_tools_manuscript.py @@ -84,8 +84,6 @@ def testManuscript_Init(monkeypatch, qtbot, nwGUI, projPath, mockRnd): # qtbot.stop() -# END Test testManuscript_Init - @pytest.mark.gui def testManuscript_Builds(qtbot, nwGUI, projPath): @@ -157,8 +155,6 @@ def testManuscript_Builds(qtbot, nwGUI, projPath): # qtbot.stop() -# END Test testManuscript_Builds - @pytest.mark.gui def testManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd): @@ -300,8 +296,6 @@ def testManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd): manus.close() # qtbot.stop() -# END Test testManuscript_Features - @pytest.mark.gui @pytest.mark.skipif(sys.platform.startswith("darwin"), reason="Not running on Darwin") @@ -333,5 +327,3 @@ def testManuscript_Print(monkeypatch, qtbot, nwGUI, projPath): # Finish manus.close() # qtbot.stop() - -# END Test testManuscript_Print diff --git a/tests/test_tools/test_tools_manussettings.py b/tests/test_tools/test_tools_manussettings.py index 9cb34a46..a2d0bc7d 100644 --- a/tests/test_tools/test_tools_manussettings.py +++ b/tests/test_tools/test_tools_manussettings.py @@ -107,8 +107,6 @@ def testBuildSettings_Init(qtbot, nwGUI, projPath, mockRnd): bSettings._dialogButtonClicked(bSettings.buttonBox.button(QtDialogClose)) # qtbot.stop() -# END Test testBuildSettings_Init - @pytest.mark.gui def testBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd): @@ -313,8 +311,6 @@ def testBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd): bSettings._dialogButtonClicked(bSettings.buttonBox.button(QtDialogClose)) # qtbot.stop() -# END Test testBuildSettings_Filter - @pytest.mark.gui def testBuildSettings_Headings(qtbot, nwGUI): @@ -485,8 +481,6 @@ def testBuildSettings_Headings(qtbot, nwGUI): bSettings._dialogButtonClicked(bSettings.buttonBox.button(QtDialogClose)) # qtbot.stop() -# END Test testBuildSettings_Headings - @pytest.mark.gui def testBuildSettings_Content(qtbot, nwGUI): @@ -547,8 +541,6 @@ def testBuildSettings_Content(qtbot, nwGUI): bSettings._dialogButtonClicked(bSettings.buttonBox.button(QtDialogClose)) # qtbot.stop() -# END Test testBuildSettings_Content - @pytest.mark.gui def testBuildSettings_Format(monkeypatch, qtbot, nwGUI): @@ -661,8 +653,6 @@ def testBuildSettings_Format(monkeypatch, qtbot, nwGUI): bSettings._dialogButtonClicked(bSettings.buttonBox.button(QtDialogClose)) # qtbot.stop() -# END Test testBuildSettings_Format - @pytest.mark.gui def testBuildSettings_Output(qtbot, nwGUI): @@ -716,5 +706,3 @@ def testBuildSettings_Output(qtbot, nwGUI): # Finish bSettings._dialogButtonClicked(bSettings.buttonBox.button(QtDialogClose)) # qtbot.stop() - -# END Test testBuildSettings_Output diff --git a/tests/test_tools/test_tools_noveldetails.py b/tests/test_tools/test_tools_noveldetails.py index b8b49a2c..ca9fe604 100644 --- a/tests/test_tools/test_tools_noveldetails.py +++ b/tests/test_tools/test_tools_noveldetails.py @@ -130,5 +130,3 @@ def testToolNovelDetails_Main(qtbot, nwGUI, prjLipsum, ipsumText): # qtbot.stop() details.close() - -# END Test testToolNovelDetails_Main diff --git a/tests/test_tools/test_tools_welcome.py b/tests/test_tools/test_tools_welcome.py index 71bf14de..fd23ea95 100644 --- a/tests/test_tools/test_tools_welcome.py +++ b/tests/test_tools/test_tools_welcome.py @@ -20,18 +20,18 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - -from pathlib import Path from datetime import datetime -from pytestqt.qtbot import QtBot +from pathlib import Path + +import pytest from PyQt5.QtCore import QPoint from PyQt5.QtWidgets import QAction, QFileDialog, QMenu +from pytestqt.qtbot import QtBot from novelwriter import CONFIG, SHARED -from novelwriter.enum import nwItemClass from novelwriter.constants import nwFiles +from novelwriter.enum import nwItemClass from novelwriter.tools.welcome import GuiWelcome from novelwriter.types import QtMouseLeft @@ -65,8 +65,6 @@ def testToolWelcome_Main(qtbot: QtBot, monkeypatch, nwGUI, fncPath): # qtbot.stop() welcome.close() -# END Test testToolWelcome_Main - @pytest.mark.gui def testToolWelcome_Open(qtbot: QtBot, monkeypatch, nwGUI, fncPath): @@ -164,8 +162,6 @@ def testToolWelcome_Open(qtbot: QtBot, monkeypatch, nwGUI, fncPath): # qtbot.stop() welcome.close() -# END Test testToolWelcome_Open - @pytest.mark.gui def testToolWelcome_New(qtbot: QtBot, caplog, monkeypatch, nwGUI, fncPath): @@ -252,5 +248,3 @@ def testToolWelcome_New(qtbot: QtBot, caplog, monkeypatch, nwGUI, fncPath): # qtbot.stop() welcome.close() - -# END Test testToolWelcome_New diff --git a/tests/test_tools/test_tools_writingstats.py b/tests/test_tools/test_tools_writingstats.py index ef76dbaf..47e67a2c 100644 --- a/tests/test_tools/test_tools_writingstats.py +++ b/tests/test_tools/test_tools_writingstats.py @@ -21,12 +21,10 @@ along with this program. If not, see . from __future__ import annotations import json -import pytest from pathlib import Path -from mocked import causeOSError -from tools import buildTestProject +import pytest from PyQt5.QtWidgets import QAction, QFileDialog @@ -35,6 +33,9 @@ from novelwriter.constants import nwFiles from novelwriter.tools.writingstats import GuiWritingStats from novelwriter.types import QtMouseLeft +from tests.mocked import causeOSError +from tests.tools import buildTestProject + @pytest.mark.gui def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths): @@ -388,5 +389,3 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths): sessLog._doClose() assert nwGUI.closeProject() is True - -# END Test testToolWritingStats_Main