Fix uninitialised shared class in tests
This commit is contained in:
@@ -20,16 +20,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
import pytest
|
||||
import shutil
|
||||
import uuid
|
||||
|
||||
from shutil import copyfile
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
from zipfile import ZipFile
|
||||
|
||||
from tools import C, NWD_IGNORE, buildTestProject, cmpFiles, XML_IGNORE
|
||||
from mocked import causeOSError
|
||||
import pytest
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.constants import nwConst, nwFiles, nwItemClass
|
||||
@@ -38,6 +36,9 @@ from novelwriter.core.coretools import (
|
||||
)
|
||||
from novelwriter.core.project import NWProject
|
||||
|
||||
from tests.mocked import causeOSError
|
||||
from tests.tools import NWD_IGNORE, XML_IGNORE, C, buildTestProject, cmpFiles
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreTools_DocMerger(monkeypatch, mockGUI, fncPath, tstPaths, mockRnd, ipsumText):
|
||||
@@ -512,7 +513,7 @@ def testCoreTools_ProjectBuilderWrapper(monkeypatch, caplog, fncPath, mockGUI):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreTools_ProjectBuilderA(monkeypatch, fncPath, tstPaths, mockRnd):
|
||||
def testCoreTools_ProjectBuilderA(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd):
|
||||
"""Create a new project from a project dictionary, with chapters."""
|
||||
monkeypatch.setattr("uuid.uuid4", lambda *a: uuid.UUID("d0f3fe10-c6e6-4310-8bfd-181eb4224eed"))
|
||||
|
||||
@@ -547,7 +548,7 @@ def testCoreTools_ProjectBuilderA(monkeypatch, fncPath, tstPaths, mockRnd):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreTools_ProjectBuilderB(monkeypatch, fncPath, tstPaths, mockRnd):
|
||||
def testCoreTools_ProjectBuilderB(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd):
|
||||
"""Create a new project from a project dictionary, without chapters."""
|
||||
monkeypatch.setattr("uuid.uuid4", lambda *a: uuid.UUID("d0f3fe10-c6e6-4310-8bfd-181eb4224eed"))
|
||||
|
||||
|
||||
@@ -21,21 +21,22 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pytest
|
||||
|
||||
from shutil import copyfile
|
||||
from datetime import datetime
|
||||
from novelwriter.constants import nwFiles
|
||||
from shutil import copyfile
|
||||
|
||||
from novelwriter.enum import nwStatusShape
|
||||
from tools import cmpFiles, writeFile
|
||||
from mocked import causeOSError
|
||||
import pytest
|
||||
|
||||
from PyQt5.QtGui import QColor
|
||||
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
|
||||
from novelwriter.core.projectdata import NWProjectData
|
||||
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
|
||||
from novelwriter.enum import nwStatusShape
|
||||
|
||||
from tests.mocked import causeOSError
|
||||
from tests.tools import cmpFiles, writeFile
|
||||
|
||||
|
||||
class MockProject:
|
||||
@@ -55,7 +56,7 @@ def mockVersion(monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
|
||||
def testCoreProjectXML_ReadCurrent(monkeypatch, mockGUI, tstPaths, fncPath):
|
||||
"""Test reading the current XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.5.nwx"
|
||||
tstFile = tstPaths.outDir / "ProjectXML_ReadCurrent.nwx"
|
||||
@@ -249,7 +250,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
|
||||
def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockGUI, mockRnd):
|
||||
"""Test reading the version 1.0 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.0.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.0.nwx"
|
||||
@@ -396,7 +397,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):
|
||||
def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockGUI, mockRnd):
|
||||
"""Test reading the version 1.1 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.1.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.1.nwx"
|
||||
@@ -543,7 +544,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):
|
||||
def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockGUI, mockRnd):
|
||||
"""Test reading the version 1.2 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.2.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.2.nwx"
|
||||
@@ -693,7 +694,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):
|
||||
def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockGUI, mockRnd):
|
||||
"""Test reading the version 1.3 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.3.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.3.nwx"
|
||||
@@ -843,7 +844,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd):
|
||||
def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockGUI, mockRnd):
|
||||
"""Test reading the version 1.4 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.4.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.4.nwx"
|
||||
|
||||
@@ -21,14 +21,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from tools import C, buildTestProject, readFile
|
||||
|
||||
from novelwriter.constants import nwHeadFmt
|
||||
from novelwriter.core.tomd import ToMarkdown
|
||||
from novelwriter.core.project import NWProject
|
||||
from novelwriter.core.tokenizer import HeadingFormatter, Tokenizer, stripEscape
|
||||
from novelwriter.core.tomd import ToMarkdown
|
||||
|
||||
from tests.tools import C, buildTestProject, readFile
|
||||
|
||||
|
||||
class BareTokenizer(Tokenizer):
|
||||
@@ -2137,7 +2138,7 @@ def testCoreToken_CounterHandling(mockGUI):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreToken_HeadingFormatter(fncPath, mockRnd):
|
||||
def testCoreToken_HeadingFormatter(fncPath, mockGUI, mockRnd):
|
||||
"""Check the HeadingFormatter class."""
|
||||
project = NWProject()
|
||||
project.setProjectLang("en_GB")
|
||||
|
||||
Reference in New Issue
Block a user