diff --git a/novelwriter/core/projectdata.py b/novelwriter/core/projectdata.py index 50c48086..ea7415b6 100644 --- a/novelwriter/core/projectdata.py +++ b/novelwriter/core/projectdata.py @@ -170,11 +170,6 @@ class NWProjectData: """Return the autoreplace dictionary.""" return self._autoReplace - @property - def titleFormat(self): - """Delete""" - return self._titleFormat - @property def itemStatus(self) -> NWStatus: """Return the status settings object.""" @@ -209,10 +204,6 @@ class NWProjectData: """Retrieve the last used handle for a given component.""" return self._lastHandle.get(component, None) - def getTitleFormat(self, kind): - """Retrieve the title format string for a given kind of header.""" - return self._titleFormat.get(kind, "%title%") - ## # Setters ## @@ -337,13 +328,4 @@ class NWProjectData: self.theProject.setProjectChanged(True) return - def setTitleFormat(self, value): - """Set the title formats.""" - if isinstance(value, dict): - for key, entry in value.items(): - if key in self._titleFormat and isinstance(entry, str): - self._titleFormat[key] = simplified(entry) - self.theProject.setProjectChanged(True) - return - # END Class NWProjectData diff --git a/novelwriter/core/projectxml.py b/novelwriter/core/projectxml.py index 0726d7da..42f4e582 100644 --- a/novelwriter/core/projectxml.py +++ b/novelwriter/core/projectxml.py @@ -280,11 +280,6 @@ class ProjectXMLReader: data.setAutoReplace(self._parseDictKeyText(xItem)) else: # Pre 1.2 format data.setAutoReplace(self._parseDictTagText(xItem)) - elif xItem.tag == "titleFormat": - if self._version >= 0x0105: - data.setTitleFormat(self._parseDictKeyText(xItem)) - else: # Pre 1.4 format - data.setTitleFormat(self._parseDictTagText(xItem)) else: logger.warning("Ignored in XML", xItem.tag) @@ -523,7 +518,6 @@ class ProjectXMLWriter: }) self._packDictKeyValue(xSettings, "lastHandle", data.lastHandle) self._packDictKeyValue(xSettings, "autoReplace", data.autoReplace) - self._packDictKeyValue(xSettings, "titleFormat", data.titleFormat) # Save Status/Importance xStatus = ET.SubElement(xSettings, "status") diff --git a/tests/conftest.py b/tests/conftest.py index d333a1b9..c8c84095 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,7 +25,7 @@ import shutil from pathlib import Path -from mock import MockGuiMain +from mocked import MockGuiMain from tools import cleanProject from PyQt5.QtWidgets import QMessageBox diff --git a/tests/mock.py b/tests/mocked.py similarity index 100% rename from tests/mock.py rename to tests/mocked.py diff --git a/tests/test_base/test_base_common.py b/tests/test_base/test_base_common.py index 5559439e..c244cd05 100644 --- a/tests/test_base/test_base_common.py +++ b/tests/test_base/test_base_common.py @@ -25,7 +25,7 @@ import hashlib from pathlib import Path -from mock import causeOSError +from mocked import causeOSError from tools import writeFile from novelwriter.guimain import GuiMain diff --git a/tests/test_base/test_base_config.py b/tests/test_base/test_base_config.py index 0d986906..2a7e6130 100644 --- a/tests/test_base/test_base_config.py +++ b/tests/test_base/test_base_config.py @@ -25,7 +25,7 @@ import pytest from shutil import copyfile from pathlib import Path -from mock import causeOSError, MockApp +from mocked import causeOSError, MockApp from tools import cmpFiles, writeFile from novelwriter import CONFIG diff --git a/tests/test_base/test_base_error.py b/tests/test_base/test_base_error.py index d90e6eb1..d6a743c0 100644 --- a/tests/test_base/test_base_error.py +++ b/tests/test_base/test_base_error.py @@ -21,7 +21,7 @@ along with this program. If not, see . import pytest -from mock import causeException +from mocked import causeException from novelwriter.error import NWErrorMessage, exceptionHandler diff --git a/tests/test_base/test_base_init.py b/tests/test_base/test_base_init.py index a932dcfa..b6e09d15 100644 --- a/tests/test_base/test_base_init.py +++ b/tests/test_base/test_base_init.py @@ -23,7 +23,7 @@ import sys import pytest import logging -from mock import MockGuiMain +from mocked import MockGuiMain from novelwriter import CONFIG, main, logger diff --git a/tests/test_core/test_core_coretools.py b/tests/test_core/test_core_coretools.py index 585a9fae..c28354f8 100644 --- a/tests/test_core/test_core_coretools.py +++ b/tests/test_core/test_core_coretools.py @@ -25,7 +25,7 @@ import pytest from shutil import copyfile from zipfile import ZipFile -from mock import causeOSError +from mocked import causeOSError from tools import C, buildTestProject, cmpFiles, XML_IGNORE from novelwriter import CONFIG diff --git a/tests/test_core/test_core_docbuild.py b/tests/test_core/test_core_docbuild.py index 0dabad71..5953a10a 100644 --- a/tests/test_core/test_core_docbuild.py +++ b/tests/test_core/test_core_docbuild.py @@ -23,7 +23,7 @@ import pytest from shutil import copyfile -from mock import causeException, causeOSError +from mocked import causeException, causeOSError from novelwriter.core.buildsettings import BuildSettings from tools import ODT_IGNORE, cmpFiles diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index 58eb10fc..319e2ef8 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -21,7 +21,7 @@ along with this program. If not, see . import pytest -from mock import causeOSError +from mocked import causeOSError from tools import C, buildTestProject, readFile, writeFile from novelwriter.enum import nwItemClass, nwItemLayout diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index c3838772..5fada997 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -24,7 +24,7 @@ import pytest from shutil import copyfile -from mock import causeException +from mocked import causeException from tools import C, buildTestProject, cmpFiles, writeFile from novelwriter.enum import nwItemClass, nwItemLayout diff --git a/tests/test_core/test_core_options.py b/tests/test_core/test_core_options.py index ce26dbe1..c241504e 100644 --- a/tests/test_core/test_core_options.py +++ b/tests/test_core/test_core_options.py @@ -22,7 +22,7 @@ along with this program. If not, see . import json import pytest -from mock import causeOSError +from mocked import causeOSError from novelwriter.constants import nwFiles from novelwriter.core.options import OptionState diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index 6425e4d8..05e4e6cc 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -26,7 +26,7 @@ from shutil import copyfile from pathlib import Path from zipfile import ZipFile -from mock import causeOSError +from mocked import causeOSError from tools import C, cmpFiles, writeFile, buildTestProject, XML_IGNORE from novelwriter import CONFIG diff --git a/tests/test_core/test_core_projectxml.py b/tests/test_core/test_core_projectxml.py index 35132107..d3108b72 100644 --- a/tests/test_core/test_core_projectxml.py +++ b/tests/test_core/test_core_projectxml.py @@ -25,8 +25,8 @@ import pytest from shutil import copyfile from datetime import datetime -from mock import causeOSError from tools import cmpFiles, writeFile +from mocked import causeOSError from novelwriter.core.item import NWItem from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState @@ -34,12 +34,16 @@ from novelwriter.core.projectdata import NWProjectData class MockProject: + """Fake project object.""" + def setProjectChanged(self, *a): + """Fake project method.""" pass @pytest.fixture(scope="function", autouse=True) def mockVersion(monkeypatch): + """Mock the version info to prevent diff from failing.""" monkeypatch.setattr("novelwriter.core.projectxml.__version__", "2.0-rc1") monkeypatch.setattr("novelwriter.core.projectxml.__hexversion__", "0x020000c1") return @@ -47,8 +51,7 @@ def mockVersion(monkeypatch): @pytest.mark.core def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath): - """Test reading the current XML file format. - """ + """Test reading the current XML file format.""" refFile = tstPaths.filesDir / "nwProject-1.5.nwx" tstFile = tstPaths.outDir / "ProjectXML_ReadCurrent.nwx" xmlFile = fncPath / "nwProject-1.5.nwx" @@ -160,12 +163,6 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath): assert data.getLastHandle("novelTree") == "7031beac91f75" assert data.getLastHandle("outline") == "7031beac91f75" - assert data.getTitleFormat("title") == "%title%" - assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%" - assert data.getTitleFormat("unnumbered") == "%title%" - assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%" - assert data.getTitleFormat("section") == "" - assert data.itemStatus.name("sf12341") == "New" assert data.itemStatus.name("sf24ce6") == "Notes" assert data.itemStatus.name("sc24b8f") == "Started" @@ -286,12 +283,6 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd): assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.0 assert data.getLastHandle("outline") is None # Doesn't exist in 1.0 - assert data.getTitleFormat("title") == "%title%" - assert data.getTitleFormat("chapter") == "Chapter %ch%: %title%" - assert data.getTitleFormat("unnumbered") == "%title%" - assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%" - assert data.getTitleFormat("section") == "" - assert data.itemStatus.name("s000000") == "New" assert data.itemStatus.name("s000001") == "Notes" assert data.itemStatus.name("s000002") == "Started" @@ -388,8 +379,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd): @pytest.mark.core def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd): - """Test reading the version 1.1 XML file format. - """ + """Test reading the version 1.1 XML file format.""" refFile = tstPaths.filesDir / "nwProject-1.1.nwx" xmlFile = fncPath / "nwProject-1.1.nwx" outFile = fncPath / "nwProject.nwx" @@ -428,12 +418,6 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd): assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.1 assert data.getLastHandle("outline") is None # Doesn't exist in 1.1 - assert data.getTitleFormat("title") == "%title%" - assert data.getTitleFormat("chapter") == "Chapter %ch%: %title%" - assert data.getTitleFormat("unnumbered") == "%title%" - assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%" - assert data.getTitleFormat("section") == "" - assert data.itemStatus.name("s000000") == "New" assert data.itemStatus.name("s000001") == "Notes" assert data.itemStatus.name("s000002") == "Started" @@ -530,8 +514,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd): @pytest.mark.core def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd): - """Test reading the version 1.2 XML file format. - """ + """Test reading the version 1.2 XML file format.""" refFile = tstPaths.filesDir / "nwProject-1.2.nwx" xmlFile = fncPath / "nwProject-1.2.nwx" outFile = fncPath / "nwProject.nwx" @@ -570,12 +553,6 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd): assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.2 assert data.getLastHandle("outline") is None # Doesn't exist in 1.2 - assert data.getTitleFormat("title") == "%title%" - assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%" - assert data.getTitleFormat("unnumbered") == "%title%" - assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%" - assert data.getTitleFormat("section") == "" - assert data.itemStatus.name("s000000") == "New" assert data.itemStatus.name("s000001") == "Notes" assert data.itemStatus.name("s000002") == "Started" @@ -675,8 +652,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd): @pytest.mark.core def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd): - """Test reading the version 1.3 XML file format. - """ + """Test reading the version 1.3 XML file format.""" refFile = tstPaths.filesDir / "nwProject-1.3.nwx" xmlFile = fncPath / "nwProject-1.3.nwx" outFile = fncPath / "nwProject.nwx" @@ -715,12 +691,6 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd): assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.3 assert data.getLastHandle("outline") is None # Doesn't exist in 1.3 - assert data.getTitleFormat("title") == "%title%" - assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%" - assert data.getTitleFormat("unnumbered") == "%title%" - assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%" - assert data.getTitleFormat("section") == "" - assert data.itemStatus.name("s000000") == "New" assert data.itemStatus.name("s000001") == "Notes" assert data.itemStatus.name("s000002") == "Started" @@ -820,8 +790,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd): @pytest.mark.core def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd): - """Test reading the version 1.4 XML file format. - """ + """Test reading the version 1.4 XML file format.""" refFile = tstPaths.filesDir / "nwProject-1.4.nwx" xmlFile = fncPath / "nwProject-1.4.nwx" outFile = fncPath / "nwProject.nwx" @@ -860,12 +829,6 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd): assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.3 assert data.getLastHandle("outline") is None # Doesn't exist in 1.3 - assert data.getTitleFormat("title") == "%title%" - assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%" - assert data.getTitleFormat("unnumbered") == "%title%" - assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%" - assert data.getTitleFormat("section") == "" - assert data.itemStatus.name("sf12341") == "New" assert data.itemStatus.name("sf24ce6") == "Notes" assert data.itemStatus.name("sc24b8f") == "Started" diff --git a/tests/test_core/test_core_spellcheck.py b/tests/test_core/test_core_spellcheck.py index b13e7100..1782adb4 100644 --- a/tests/test_core/test_core_spellcheck.py +++ b/tests/test_core/test_core_spellcheck.py @@ -22,7 +22,7 @@ along with this program. If not, see . import sys import pytest -from mock import causeOSError +from mocked import causeOSError from tools import readFile, writeFile from novelwriter.core.spellcheck import FakeEnchant, NWSpellEnchant diff --git a/tests/test_core/test_core_storage.py b/tests/test_core/test_core_storage.py index fe1dedc4..5baa8cf0 100644 --- a/tests/test_core/test_core_storage.py +++ b/tests/test_core/test_core_storage.py @@ -22,7 +22,7 @@ along with this program. If not, see . from zipfile import ZipFile import pytest -from mock import causeOSError +from mocked import causeOSError from tools import C, buildTestProject, writeFile from novelwriter import CONFIG diff --git a/tests/test_core/test_core_tree.py b/tests/test_core/test_core_tree.py index 80a6e7cc..ee9ce687 100644 --- a/tests/test_core/test_core_tree.py +++ b/tests/test_core/test_core_tree.py @@ -24,7 +24,7 @@ import random from pathlib import Path -from mock import causeOSError +from mocked import causeOSError from tools import readFile from novelwriter.enum import nwItemClass, nwItemType, nwItemLayout diff --git a/tests/test_dialogs/test_dlg_wordlist.py b/tests/test_dialogs/test_dlg_wordlist.py index fef4b4a3..8781a82d 100644 --- a/tests/test_dialogs/test_dlg_wordlist.py +++ b/tests/test_dialogs/test_dlg_wordlist.py @@ -25,7 +25,7 @@ from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog, QAction from tools import buildTestProject, writeFile, readFile, getGuiItem -from mock import causeOSError +from mocked import causeOSError from novelwriter.constants import nwFiles from novelwriter.dialogs.wordlist import GuiWordList diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index 34f9dfd1..1dc3610b 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -21,7 +21,7 @@ along with this program. If not, see . import pytest -from mock import causeOSError +from mocked import causeOSError from tools import C, buildTestProject from PyQt5.QtCore import Qt diff --git a/tests/test_gui/test_gui_docviewer.py b/tests/test_gui/test_gui_docviewer.py index 2bd7ad7a..bb3437dd 100644 --- a/tests/test_gui/test_gui_docviewer.py +++ b/tests/test_gui/test_gui_docviewer.py @@ -21,7 +21,7 @@ along with this program. If not, see . import pytest -from mock import causeException +from mocked import causeException from PyQt5.QtCore import Qt, QUrl from PyQt5.QtGui import QTextCursor diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py index dbaeb09f..92b68e9a 100644 --- a/tests/test_gui/test_gui_projtree.py +++ b/tests/test_gui/test_gui_projtree.py @@ -21,7 +21,7 @@ along with this program. If not, see . import pytest -from mock import causeOSError +from mocked import causeOSError from tools import C, buildTestProject from PyQt5.QtCore import Qt diff --git a/tests/test_gui/test_gui_theme.py b/tests/test_gui/test_gui_theme.py index a4aa6b2a..3ba5f405 100644 --- a/tests/test_gui/test_gui_theme.py +++ b/tests/test_gui/test_gui_theme.py @@ -24,7 +24,7 @@ import pytest from pathlib import Path from configparser import ConfigParser -from mock import causeOSError +from mocked import causeOSError from tools import writeFile from PyQt5.QtGui import QIcon, QPalette, QPixmap diff --git a/tests/test_tools/test_tools_writingstats.py b/tests/test_tools/test_tools_writingstats.py index 7cf832f6..af2e4f0c 100644 --- a/tests/test_tools/test_tools_writingstats.py +++ b/tests/test_tools/test_tools_writingstats.py @@ -22,7 +22,7 @@ along with this program. If not, see . import json import pytest -from mock import causeOSError +from mocked import causeOSError from tools import getGuiItem, writeFile, buildTestProject from PyQt5.QtCore import Qt