Clean up code style (#1859)
This commit is contained in:
@@ -36,7 +36,7 @@ jobs:
|
||||
- name: Run Tests
|
||||
run: |
|
||||
export QT_QPA_PLATFORM=offscreen
|
||||
pytest -v --cov=novelwriter --timeout=60
|
||||
python -m pytest -v --cov=novelwriter --timeout=60
|
||||
- name: Upload to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
env:
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
- name: Run Tests
|
||||
run: |
|
||||
export QT_QPA_PLATFORM=offscreen
|
||||
pytest -v --cov=novelwriter --timeout=60
|
||||
python -m pytest -v --cov=novelwriter --timeout=60
|
||||
- name: Upload to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
env:
|
||||
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
pip install -U -r requirements.txt -r tests/requirements.txt
|
||||
- name: Run Tests
|
||||
run: |
|
||||
pytest -v --cov=novelwriter --timeout=60
|
||||
python -m pytest -v --cov=novelwriter --timeout=60
|
||||
- name: Upload to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
env:
|
||||
|
||||
@@ -242,5 +242,3 @@ def main(sysArgs: list | None = None) -> GuiMain | None:
|
||||
sys.exit(nwApp.exec())
|
||||
|
||||
return None
|
||||
|
||||
# END Function main
|
||||
|
||||
@@ -603,5 +603,3 @@ class NWConfigParser(ConfigParser):
|
||||
for i in range(min(len(data), len(result))):
|
||||
result[i] = checkInt(data[i].strip(), result[i])
|
||||
return result
|
||||
|
||||
# END Class NWConfigParser
|
||||
|
||||
@@ -24,24 +24,24 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from time import time
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
|
||||
from PyQt5.QtGui import QFontDatabase
|
||||
from PyQt5.QtCore import (
|
||||
PYQT_VERSION, PYQT_VERSION_STR, QT_VERSION, QT_VERSION_STR, QLibraryInfo,
|
||||
QLocale, QStandardPaths, QSysInfo, QTranslator
|
||||
)
|
||||
from PyQt5.QtGui import QFontDatabase
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from novelwriter.error import formatException, logException
|
||||
from novelwriter.common import NWConfigParser, checkInt, checkPath, formatTimeStamp
|
||||
from novelwriter.constants import nwFiles, nwUnicode
|
||||
from novelwriter.error import formatException, logException
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -787,8 +787,6 @@ class Config:
|
||||
logger.debug("Checking package 'pyenchant': OK")
|
||||
return
|
||||
|
||||
# END Class Config
|
||||
|
||||
|
||||
class RecentProjects:
|
||||
|
||||
@@ -857,5 +855,3 @@ class RecentProjects:
|
||||
logger.debug("Removed recent: %s", path)
|
||||
self.saveCache()
|
||||
return
|
||||
|
||||
# END Class RecentProjects
|
||||
|
||||
@@ -60,8 +60,6 @@ class nwConst:
|
||||
# Dialogs
|
||||
DLG_FINISHED = 2
|
||||
|
||||
# END Class nwConst
|
||||
|
||||
|
||||
class nwRegEx:
|
||||
|
||||
@@ -71,8 +69,6 @@ class nwRegEx:
|
||||
FMT_SC = r"(?i)(?<!\\)(\[[\/\!]?(?:i|b|s|u|m|sup|sub)\])"
|
||||
FMT_SV = r"(?<!\\)(\[(?i)(?:footnote):)(.+?)(?<!\\)(\])"
|
||||
|
||||
# END Class nwRegEx
|
||||
|
||||
|
||||
class nwShortcode:
|
||||
|
||||
@@ -98,16 +94,12 @@ class nwShortcode:
|
||||
nwComment.COMMENT: "[comment:{0}]",
|
||||
}
|
||||
|
||||
# END Class nwShortcode
|
||||
|
||||
|
||||
class nwHeaders:
|
||||
|
||||
H_VALID = ("H0", "H1", "H2", "H3", "H4")
|
||||
H_LEVEL = {"H0": 0, "H1": 1, "H2": 2, "H3": 3, "H4": 4}
|
||||
|
||||
# END Class nwHeaders
|
||||
|
||||
|
||||
class nwFiles:
|
||||
|
||||
@@ -127,8 +119,6 @@ class nwFiles:
|
||||
DICT_FILE = "userdict.json"
|
||||
SESS_FILE = "sessions.jsonl"
|
||||
|
||||
# END Class nwFiles
|
||||
|
||||
|
||||
class nwKeyWords:
|
||||
|
||||
@@ -162,8 +152,6 @@ class nwKeyWords:
|
||||
CUSTOM_KEY: nwItemClass.CUSTOM,
|
||||
}
|
||||
|
||||
# END Class nwKeyWords
|
||||
|
||||
|
||||
class nwLists:
|
||||
|
||||
@@ -177,8 +165,6 @@ class nwLists:
|
||||
nwItemClass.CUSTOM,
|
||||
]
|
||||
|
||||
# END Class nwLists
|
||||
|
||||
|
||||
class nwLabels:
|
||||
|
||||
@@ -339,8 +325,6 @@ class nwLabels:
|
||||
"Custom": (-1.0, -1.0),
|
||||
}
|
||||
|
||||
# END Class nwLabels
|
||||
|
||||
|
||||
class nwHeadFmt:
|
||||
|
||||
@@ -366,8 +350,6 @@ class nwHeadFmt:
|
||||
ODT_PAGE = "{Page}"
|
||||
ODT_AUTO = "{Project} / {Author} / {Page}"
|
||||
|
||||
# END Class nwHeadFmt
|
||||
|
||||
|
||||
class nwQuotes:
|
||||
"""Allowed quotation marks.
|
||||
@@ -398,8 +380,6 @@ class nwQuotes:
|
||||
"\u300f": QT_TRANSLATE_NOOP("Constant", "Right white corner bracket"),
|
||||
}
|
||||
|
||||
# END Class nwQuotes
|
||||
|
||||
|
||||
class nwUnicode:
|
||||
"""Supported unicode character constants and their HTML equivalents."""
|
||||
@@ -534,8 +514,6 @@ class nwUnicode:
|
||||
H_LTRI = "◀"
|
||||
H_LTRIS = "◂"
|
||||
|
||||
# END Class nwUnicode
|
||||
|
||||
|
||||
class nwHtmlUnicode():
|
||||
|
||||
@@ -591,5 +569,3 @@ class nwHtmlUnicode():
|
||||
nwUnicode.U_TIMES: nwUnicode.H_TIMES,
|
||||
nwUnicode.U_DIVIDE: nwUnicode.H_DIVIDE,
|
||||
}
|
||||
|
||||
# END Class nwHtmlUnicode
|
||||
|
||||
@@ -172,8 +172,6 @@ class FilterMode(Enum):
|
||||
SKIPPED = 4
|
||||
ROOT = 5
|
||||
|
||||
# END Enum FilterMode
|
||||
|
||||
|
||||
class BuildSettings:
|
||||
"""Core: Build Settings Class
|
||||
@@ -488,8 +486,6 @@ class BuildSettings:
|
||||
|
||||
return
|
||||
|
||||
# END Class BuildSettings
|
||||
|
||||
|
||||
class BuildCollection:
|
||||
"""Core: Build Collection Class
|
||||
@@ -637,5 +633,3 @@ class BuildCollection:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# END Class BuildCollection
|
||||
|
||||
@@ -129,8 +129,6 @@ class DocMerger:
|
||||
|
||||
return status
|
||||
|
||||
# END Class DocMerger
|
||||
|
||||
|
||||
class DocSplitter:
|
||||
"""Document tool for splitting a document into a set of new
|
||||
@@ -257,8 +255,6 @@ class DocSplitter:
|
||||
|
||||
return
|
||||
|
||||
# END Class DocSplitter
|
||||
|
||||
|
||||
class DocDuplicator:
|
||||
"""A class that will duplicate all documents and folders starting
|
||||
@@ -297,8 +293,6 @@ class DocDuplicator:
|
||||
nHandle = None
|
||||
return
|
||||
|
||||
# END Class DocDuplicator
|
||||
|
||||
|
||||
class DocSearch:
|
||||
|
||||
@@ -375,8 +369,6 @@ class DocSearch:
|
||||
search = f"(?:^|\\b){search}(?:$|\\b)"
|
||||
return search
|
||||
|
||||
# END Class DocSearch
|
||||
|
||||
|
||||
class ProjectBuilder:
|
||||
"""A class to build a new project from a set of user-defined
|
||||
@@ -609,5 +601,3 @@ class ProjectBuilder:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# END Class ProjectBuilder
|
||||
|
||||
@@ -405,5 +405,3 @@ class NWBuildDocument:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# END Class NWBuildDocument
|
||||
|
||||
@@ -26,14 +26,14 @@ from __future__ import annotations
|
||||
import hashlib
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
from typing import TYPE_CHECKING
|
||||
from pathlib import Path
|
||||
|
||||
from novelwriter.enum import nwItemLayout, nwItemClass
|
||||
from novelwriter.error import formatException, logException
|
||||
from novelwriter.common import formatTimeStamp, isHandle
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.enum import nwItemClass, nwItemLayout
|
||||
from novelwriter.error import formatException, logException
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -359,5 +359,3 @@ class NWDocument:
|
||||
logger.debug("Unknown meta data: '%s'", metaLine.strip())
|
||||
|
||||
return
|
||||
|
||||
# END Class NWDocument
|
||||
|
||||
@@ -707,12 +707,9 @@ class NWIndex:
|
||||
return tName, tClass, iItem, None if iItem is None else iItem[tHeading]
|
||||
return "", "", None, None
|
||||
|
||||
# END Class NWIndex
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Tags Index Object
|
||||
# =============================================================================================== #
|
||||
# The Tags Index Object
|
||||
# =====================
|
||||
|
||||
class TagsIndex:
|
||||
"""Core: Tags Index Wrapper Class
|
||||
@@ -832,12 +829,9 @@ class TagsIndex:
|
||||
|
||||
return
|
||||
|
||||
# END Class TagsIndex
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Item Index Objects
|
||||
# =============================================================================================== #
|
||||
# The Item Index Objects
|
||||
# ======================
|
||||
|
||||
class ItemIndex:
|
||||
"""Core: Item Index Wrapper Class
|
||||
@@ -1014,8 +1008,6 @@ class ItemIndex:
|
||||
|
||||
return
|
||||
|
||||
# END Class ItemIndex
|
||||
|
||||
|
||||
class IndexItem:
|
||||
"""Core: Single Index Item Class
|
||||
@@ -1176,8 +1168,6 @@ class IndexItem:
|
||||
|
||||
return
|
||||
|
||||
# END Class IndexItem
|
||||
|
||||
|
||||
class IndexHeading:
|
||||
"""Core: Single Index Heading Class
|
||||
@@ -1353,12 +1343,9 @@ class IndexHeading:
|
||||
raise ValueError("The itemIndex contains an invalid reference type")
|
||||
return
|
||||
|
||||
# END Class IndexHeading
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Text Processing Functions
|
||||
# =============================================================================================== #
|
||||
# Text Processing Functions
|
||||
# =========================
|
||||
|
||||
MODIFIERS = {
|
||||
"synopsis": nwComment.SYNOPSIS,
|
||||
|
||||
@@ -29,11 +29,12 @@ from typing import TYPE_CHECKING, Any
|
||||
|
||||
from PyQt5.QtGui import QIcon
|
||||
|
||||
from novelwriter.enum import nwItemType, nwItemClass, nwItemLayout
|
||||
from novelwriter.common import (
|
||||
checkInt, isHandle, isItemClass, isItemLayout, isItemType, simplified, yesNo
|
||||
checkInt, isHandle, isItemClass, isItemLayout, isItemType, simplified,
|
||||
yesNo
|
||||
)
|
||||
from novelwriter.constants import nwHeaders, nwLabels, trConst
|
||||
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -557,5 +558,3 @@ class NWItem:
|
||||
"""Save the initial word count."""
|
||||
self._initCount = self._wordCount
|
||||
return
|
||||
|
||||
# END Class NWItem
|
||||
|
||||
@@ -28,12 +28,12 @@ import json
|
||||
import logging
|
||||
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.common import checkBool, checkFloat, checkInt, checkString, jsonEncode
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.error import logException
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -218,5 +218,3 @@ class OptionState:
|
||||
if value in lookup.__members__:
|
||||
return lookup[value]
|
||||
return default
|
||||
|
||||
# END Class OptionState
|
||||
|
||||
@@ -35,11 +35,12 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
from novelwriter import CONFIG, SHARED, __version__, __hexversion__
|
||||
from novelwriter import CONFIG, SHARED, __hexversion__, __version__
|
||||
from novelwriter.common import (
|
||||
checkStringNone, formatInt, formatTimeStamp, getFileSize, hexToInt, makeFileNameSafe, minmax
|
||||
checkStringNone, formatInt, formatTimeStamp, getFileSize, hexToInt,
|
||||
makeFileNameSafe, minmax
|
||||
)
|
||||
from novelwriter.constants import trConst, nwLabels
|
||||
from novelwriter.constants import nwLabels, trConst
|
||||
from novelwriter.core.index import NWIndex
|
||||
from novelwriter.core.options import OptionState
|
||||
from novelwriter.core.projectdata import NWProjectData
|
||||
@@ -47,7 +48,7 @@ from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLR
|
||||
from novelwriter.core.sessions import NWSessionLog
|
||||
from novelwriter.core.storage import NWStorage, NWStorageOpen
|
||||
from novelwriter.core.tree import NWTree
|
||||
from novelwriter.enum import nwItemType, nwItemClass, nwItemLayout
|
||||
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
|
||||
from novelwriter.error import logException
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
@@ -63,8 +64,6 @@ class NWProjectState(Enum):
|
||||
RECOVERY = 2
|
||||
READY = 3
|
||||
|
||||
# END Enum NWProjectState
|
||||
|
||||
|
||||
class NWProject:
|
||||
|
||||
@@ -595,5 +594,3 @@ class NWProject:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# END Class NWProject
|
||||
|
||||
@@ -23,8 +23,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
import logging
|
||||
import uuid
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
@@ -322,5 +322,3 @@ class NWProjectData:
|
||||
self._autoReplace[key] = simplified(entry)
|
||||
self._project.setProjectChanged(True)
|
||||
return
|
||||
|
||||
# END Class NWProjectData
|
||||
|
||||
@@ -29,19 +29,19 @@ import logging
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
from typing import TYPE_CHECKING
|
||||
from pathlib import Path
|
||||
|
||||
from novelwriter import __version__, __hexversion__
|
||||
from novelwriter import __hexversion__, __version__
|
||||
from novelwriter.common import (
|
||||
checkBool, checkInt, checkString, checkStringNone, formatTimeStamp,
|
||||
hexToInt, simplified, xmlIndent, yesNo
|
||||
)
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.core.status import NWStatus
|
||||
from novelwriter.core.projectdata import NWProjectData
|
||||
from novelwriter.core.status import NWStatus
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -70,8 +70,6 @@ class XMLReadState(Enum):
|
||||
PARSED_OK = 5
|
||||
WAS_LEGACY = 6
|
||||
|
||||
# END Class XMLReadState
|
||||
|
||||
|
||||
class ProjectXMLReader:
|
||||
"""Core: Project XML Reader
|
||||
@@ -458,8 +456,6 @@ class ProjectXMLReader:
|
||||
"""
|
||||
return {xNode.tag: checkString(xNode.text, "") for xNode in xItem}
|
||||
|
||||
# END Class ProjectXMLReader
|
||||
|
||||
|
||||
class ProjectXMLWriter:
|
||||
"""Core: Project XML Writer
|
||||
@@ -579,5 +575,3 @@ class ProjectXMLWriter:
|
||||
xEntry = ET.SubElement(xItem, "entry", attrib={"key": key})
|
||||
xEntry.text = str(value) or ""
|
||||
return
|
||||
|
||||
# END Class ProjectXMLWriter
|
||||
|
||||
@@ -26,14 +26,14 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
from typing import TYPE_CHECKING
|
||||
from pathlib import Path
|
||||
from collections.abc import Iterable
|
||||
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.common import formatTimeStamp
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.error import logException
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -135,5 +135,3 @@ class NWSessionLog:
|
||||
"novel": novel, "notes": notes, "idle": idle,
|
||||
})
|
||||
return f"{data}\n"
|
||||
|
||||
# END Class NWSessionLog
|
||||
|
||||
@@ -27,14 +27,14 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from pathlib import Path
|
||||
from collections.abc import Iterator
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import QLocale
|
||||
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.error import logException
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -164,11 +164,10 @@ class NWSpellEnchant:
|
||||
name = ""
|
||||
return tag, name
|
||||
|
||||
# END Class NWSpellEnchant
|
||||
|
||||
|
||||
class FakeEnchant:
|
||||
"""Fallback for when Enchant is selected, but not installed."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
||||
class FakeProvider:
|
||||
@@ -188,8 +187,6 @@ class FakeEnchant:
|
||||
def add_to_session(self, word: str) -> None:
|
||||
return
|
||||
|
||||
# END Class FakeEnchant
|
||||
|
||||
|
||||
class UserDictionary:
|
||||
|
||||
@@ -240,5 +237,3 @@ class UserDictionary:
|
||||
logger.error("Failed to save user dictionary")
|
||||
logException()
|
||||
return
|
||||
|
||||
# END Class UserDictionary
|
||||
|
||||
@@ -32,7 +32,7 @@ from collections.abc import Iterable
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from PyQt5.QtCore import QPointF, Qt
|
||||
from PyQt5.QtGui import QIcon, QPainter, QPainterPath, QPixmap, QColor, QPolygonF
|
||||
from PyQt5.QtGui import QColor, QIcon, QPainter, QPainterPath, QPixmap, QPolygonF
|
||||
|
||||
from novelwriter import SHARED
|
||||
from novelwriter.common import simplified
|
||||
@@ -62,8 +62,6 @@ class StatusEntry:
|
||||
cls.icon = QIcon(source.icon)
|
||||
return cls
|
||||
|
||||
# END Class StatusEntry
|
||||
|
||||
|
||||
NO_ENTRY = StatusEntry("", QColor(0, 0, 0), nwStatusShape.SQUARE, QIcon(), 0)
|
||||
|
||||
@@ -221,8 +219,6 @@ class NWStatus:
|
||||
"""Check key is valid, and if not, generate one."""
|
||||
return key if self._isKey(key) else self._newKey()
|
||||
|
||||
# END Class NWStatus
|
||||
|
||||
|
||||
class _ShapeCache:
|
||||
|
||||
@@ -329,8 +325,6 @@ class _ShapeCache:
|
||||
|
||||
return path
|
||||
|
||||
# END Class _ShapeCache
|
||||
|
||||
|
||||
# Create Singleton
|
||||
_SHAPES = _ShapeCache()
|
||||
|
||||
@@ -54,8 +54,6 @@ class NWStorageOpen(Enum):
|
||||
FAILED = 3
|
||||
READY = 4
|
||||
|
||||
# END Enum NWStorageOpen
|
||||
|
||||
|
||||
class NWStorageCreate(Enum):
|
||||
|
||||
@@ -63,8 +61,6 @@ class NWStorageCreate(Enum):
|
||||
OS_ERROR = 1
|
||||
READY = 2
|
||||
|
||||
# END Enum NWStorageCreate
|
||||
|
||||
|
||||
class NWStorage:
|
||||
"""Core: Project Storage Class
|
||||
@@ -391,8 +387,6 @@ class NWStorage:
|
||||
self._lockedBy = None
|
||||
return True
|
||||
|
||||
# END Class NWStorage
|
||||
|
||||
|
||||
class _LegacyStorage:
|
||||
"""Core: Legacy Storage Converter Utils
|
||||
@@ -590,5 +584,3 @@ class _LegacyStorage:
|
||||
logException()
|
||||
|
||||
return
|
||||
|
||||
# END Class _LegacyStorage
|
||||
|
||||
@@ -536,5 +536,3 @@ class ToHtml(Tokenizer):
|
||||
)
|
||||
|
||||
return bits[0][1:], result
|
||||
|
||||
# END Class ToHtml
|
||||
|
||||
@@ -1045,8 +1045,6 @@ class Tokenizer(ABC):
|
||||
|
||||
return result, formats
|
||||
|
||||
# END Class Tokenizer
|
||||
|
||||
|
||||
class HeadingFormatter:
|
||||
|
||||
@@ -1116,5 +1114,3 @@ class HeadingFormatter:
|
||||
hFormat = hFormat.replace(nwHeadFmt.CHAR_FOCUS, fText)
|
||||
|
||||
return hFormat
|
||||
|
||||
# END Class HeadingFormatter
|
||||
|
||||
@@ -272,5 +272,3 @@ class ToMarkdown(Tokenizer):
|
||||
result += " \n" if style & self.A_Z_BTMMRG else "\n\n"
|
||||
|
||||
return result
|
||||
|
||||
# END Class ToMarkdown
|
||||
|
||||
@@ -1079,12 +1079,9 @@ class ToOdt(Tokenizer):
|
||||
|
||||
return
|
||||
|
||||
# END Class ToOdt
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Auto-Style Classes
|
||||
# =============================================================================================== #
|
||||
# Auto-Style Classes
|
||||
# ==================
|
||||
|
||||
class ODTParagraphStyle:
|
||||
"""Wrapper class for the paragraph style setting used by the
|
||||
@@ -1332,8 +1329,6 @@ class ODTParagraphStyle:
|
||||
|
||||
return
|
||||
|
||||
# END Class ODTParagraphStyle
|
||||
|
||||
|
||||
class ODTTextStyle:
|
||||
"""Wrapper class for the text style setting used by the exporter.
|
||||
@@ -1457,12 +1452,9 @@ class ODTTextStyle:
|
||||
ET.SubElement(xEntry, _mkTag("style", "text-properties"), attrib=attr)
|
||||
return
|
||||
|
||||
# END Class ODTTextStyle
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# XML Complex Element Helper Class
|
||||
# =============================================================================================== #
|
||||
# XML Complex Element Helper Class
|
||||
# ================================
|
||||
|
||||
X_ROOT_TEXT = 0
|
||||
X_ROOT_TAIL = 1
|
||||
@@ -1661,5 +1653,3 @@ class XMLParagraph:
|
||||
self._chrPos += nSpaces - 1
|
||||
|
||||
return
|
||||
|
||||
# END Class XMLParagraph
|
||||
|
||||
@@ -23,18 +23,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
import logging
|
||||
import random
|
||||
|
||||
from typing import TYPE_CHECKING, Literal, overload
|
||||
from pathlib import Path
|
||||
from collections.abc import Iterable, Iterator
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Literal, overload
|
||||
|
||||
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.common import isHandle
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
|
||||
from novelwriter.error import logException
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -520,5 +520,3 @@ class NWTree:
|
||||
handle = self._makeHandle()
|
||||
|
||||
return handle
|
||||
|
||||
# END Class NWTree
|
||||
|
||||
@@ -152,5 +152,3 @@ class GuiAbout(NNonBlockingDialog):
|
||||
f"QTextBrowser {{border: none; background: {baseCol};}} "
|
||||
)
|
||||
return
|
||||
|
||||
# END Class GuiAbout
|
||||
|
||||
@@ -34,8 +34,8 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.extensions.configlayout import NColourLabel
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.types import QtDialogCancel, QtDialogOk, QtDialogReset, QtUserRole
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -182,5 +182,3 @@ class GuiDocMerge(QDialog):
|
||||
self.listBox.addItem(newItem)
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiDocMerge
|
||||
|
||||
@@ -34,8 +34,8 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.extensions.configlayout import NColourLabel
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.types import QtDialogCancel, QtDialogOk, QtUserRole
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -257,5 +257,3 @@ class GuiDocSplit(QDialog):
|
||||
self.listBox.addItem(newItem)
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiDocSplit
|
||||
|
||||
@@ -94,5 +94,3 @@ class GuiEditLabel(QDialog):
|
||||
accepted = cls.result() == QDialog.DialogCode.Accepted
|
||||
cls.deleteLater()
|
||||
return label, accepted
|
||||
|
||||
# END Class GuiEditLabel
|
||||
|
||||
@@ -962,5 +962,3 @@ class GuiPreferences(QDialog):
|
||||
self.newPreferencesReady.emit(needsRestart, refreshTree, updateTheme, updateSyntax)
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiPreferences
|
||||
|
||||
@@ -29,8 +29,8 @@ import logging
|
||||
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtGui import QCloseEvent, QColor
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QApplication, QColorDialog, QDialog, QDialogButtonBox, QHBoxLayout,
|
||||
QLineEdit, QMenu, QStackedWidget, QToolButton, QTreeWidget,
|
||||
QAbstractItemView, QApplication, QColorDialog, QDialog, QDialogButtonBox,
|
||||
QHBoxLayout, QLineEdit, QMenu, QStackedWidget, QToolButton, QTreeWidget,
|
||||
QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
@@ -227,8 +227,6 @@ class GuiProjectSettings(QDialog):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiProjectSettings
|
||||
|
||||
|
||||
class _SettingsPage(NScrollableForm):
|
||||
|
||||
@@ -302,8 +300,6 @@ class _SettingsPage(NScrollableForm):
|
||||
|
||||
return
|
||||
|
||||
# END Class _SettingsPage
|
||||
|
||||
|
||||
class _StatusPage(NFixedPage):
|
||||
|
||||
@@ -622,8 +618,6 @@ class _StatusPage(NFixedPage):
|
||||
self.shapeButton.setIcon(self._icons[self._shape])
|
||||
return
|
||||
|
||||
# END Class _StatusPage
|
||||
|
||||
|
||||
class _ReplacePage(NFixedPage):
|
||||
|
||||
@@ -797,5 +791,3 @@ class _ReplacePage(NFixedPage):
|
||||
def _stripNotAllowed(self, key: str) -> str:
|
||||
"""Clean up the replace key string."""
|
||||
return "".join(c for c in key if c.isalnum())
|
||||
|
||||
# END Class _ReplacePage
|
||||
|
||||
@@ -25,15 +25,15 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtGui import QFontMetrics
|
||||
from PyQt5.QtCore import QSize, pyqtSlot
|
||||
from PyQt5.QtGui import QFontMetrics
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QDialogButtonBox, QFrame, QHBoxLayout, QLabel, QListWidget,
|
||||
QListWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.constants import trConst, nwQuotes
|
||||
from novelwriter.constants import nwQuotes, trConst
|
||||
from novelwriter.types import QtAlignCenter, QtAlignTop, QtDialogCancel, QtDialogOk, QtUserRole
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -141,5 +141,3 @@ class GuiQuoteSelect(QDialog):
|
||||
self.previewLabel.setText(quote)
|
||||
self._selected = quote
|
||||
return
|
||||
|
||||
# END Class GuiQuoteSelect
|
||||
|
||||
@@ -253,5 +253,3 @@ class GuiWordList(QDialog):
|
||||
if (item := self.listBox.item(i)) and (word := item.text().strip()):
|
||||
result.append(word)
|
||||
return result
|
||||
|
||||
# END Class GuiWordList
|
||||
|
||||
@@ -32,8 +32,6 @@ class nwItemType(Enum):
|
||||
FOLDER = 2
|
||||
FILE = 3
|
||||
|
||||
# END Enum nwItemType
|
||||
|
||||
|
||||
class nwItemClass(Enum):
|
||||
|
||||
@@ -50,8 +48,6 @@ class nwItemClass(Enum):
|
||||
TEMPLATE = 10
|
||||
TRASH = 11
|
||||
|
||||
# END Enum nwItemClass
|
||||
|
||||
|
||||
class nwItemLayout(Enum):
|
||||
|
||||
@@ -59,8 +55,6 @@ class nwItemLayout(Enum):
|
||||
DOCUMENT = 1
|
||||
NOTE = 2
|
||||
|
||||
# END Enum nwItemLayout
|
||||
|
||||
|
||||
class nwComment(Enum):
|
||||
|
||||
@@ -73,8 +67,6 @@ class nwComment(Enum):
|
||||
COMMENT = 6
|
||||
STORY = 7
|
||||
|
||||
# END Enum nwComment
|
||||
|
||||
|
||||
class nwTrinary(Enum):
|
||||
|
||||
@@ -82,16 +74,12 @@ class nwTrinary(Enum):
|
||||
NEUTRAL = 0
|
||||
POSITIVE = 1
|
||||
|
||||
# END Enum nwTrinary
|
||||
|
||||
|
||||
class nwDocMode(Enum):
|
||||
|
||||
VIEW = 0
|
||||
EDIT = 1
|
||||
|
||||
# END Enum nwDocMode
|
||||
|
||||
|
||||
class nwDocAction(Enum):
|
||||
|
||||
@@ -134,8 +122,6 @@ class nwDocAction(Enum):
|
||||
SC_SUP = 36
|
||||
SC_SUB = 37
|
||||
|
||||
# END Enum nwDocAction
|
||||
|
||||
|
||||
class nwDocInsert(Enum):
|
||||
|
||||
@@ -152,8 +138,6 @@ class nwDocInsert(Enum):
|
||||
LIPSUM = 10
|
||||
FOOTNOTE = 11
|
||||
|
||||
# END Enum nwDocInsert
|
||||
|
||||
|
||||
class nwView(Enum):
|
||||
|
||||
@@ -163,8 +147,6 @@ class nwView(Enum):
|
||||
OUTLINE = 3
|
||||
SEARCH = 4
|
||||
|
||||
# END Enum nwView
|
||||
|
||||
|
||||
class nwWidget(Enum):
|
||||
|
||||
@@ -173,8 +155,6 @@ class nwWidget(Enum):
|
||||
VIEWER = 3
|
||||
OUTLINE = 4
|
||||
|
||||
# END Enum nwWidget
|
||||
|
||||
|
||||
class nwOutline(Enum):
|
||||
|
||||
@@ -196,8 +176,6 @@ class nwOutline(Enum):
|
||||
CUSTOM = 15
|
||||
SYNOP = 16
|
||||
|
||||
# END Enum nwOutline
|
||||
|
||||
|
||||
class nwBuildFmt(Enum):
|
||||
|
||||
@@ -210,8 +188,6 @@ class nwBuildFmt(Enum):
|
||||
J_HTML = 6
|
||||
J_NWD = 7
|
||||
|
||||
# END Enum nwBuildFormat
|
||||
|
||||
|
||||
class nwStatusShape(Enum):
|
||||
|
||||
@@ -235,5 +211,3 @@ class nwStatusShape(Enum):
|
||||
BLOCK_2 = 17
|
||||
BLOCK_3 = 18
|
||||
BLOCK_4 = 19
|
||||
|
||||
# END Enum nwStatusShape
|
||||
|
||||
+8
-15
@@ -23,17 +23,17 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import random
|
||||
import logging
|
||||
import random
|
||||
import sys
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtGui import QFont, QFontDatabase
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QWidget, QDialog, QGridLayout, QStyle, QPlainTextEdit,
|
||||
QLabel, QDialogButtonBox
|
||||
QApplication, QDialog, QDialogButtonBox, QGridLayout, QLabel,
|
||||
QPlainTextEdit, QStyle, QWidget
|
||||
)
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
@@ -42,10 +42,6 @@ if TYPE_CHECKING: # pragma: no cover
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Utility Functions
|
||||
# =============================================================================================== #
|
||||
|
||||
def logException() -> None:
|
||||
"""Log the content of an exception message."""
|
||||
exType, exValue, _ = sys.exc_info()
|
||||
@@ -61,10 +57,6 @@ def formatException(exc: BaseException) -> str:
|
||||
return f"{type(exc).__name__}: {str(exc)}"
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Error Handler
|
||||
# =============================================================================================== #
|
||||
|
||||
class NWErrorMessage(QDialog):
|
||||
|
||||
def __init__(self, parent: QWidget) -> None:
|
||||
@@ -125,9 +117,11 @@ class NWErrorMessage(QDialog):
|
||||
error traceback.
|
||||
"""
|
||||
from traceback import format_tb
|
||||
|
||||
from PyQt5.QtCore import PYQT_VERSION_STR, QT_VERSION_STR, QSysInfo
|
||||
|
||||
from novelwriter import __version__
|
||||
from novelwriter.constants import nwConst
|
||||
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, QSysInfo
|
||||
|
||||
self.msgHead.setText(
|
||||
"<p>An unhandled error has been encountered.</p>"
|
||||
@@ -175,12 +169,11 @@ class NWErrorMessage(QDialog):
|
||||
self.close()
|
||||
return
|
||||
|
||||
# END Class NWErrorMessage
|
||||
|
||||
|
||||
def exceptionHandler(exType: type, exValue: BaseException, exTrace: TracebackType) -> None:
|
||||
"""Function to catch unhandled global exceptions."""
|
||||
from traceback import print_tb
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
logger.critical("%s: %s", exType.__name__, str(exValue))
|
||||
|
||||
@@ -26,11 +26,11 @@ from __future__ import annotations
|
||||
from math import ceil
|
||||
|
||||
from PyQt5.QtCore import QRect
|
||||
from PyQt5.QtGui import QBrush, QColor, QPaintEvent, QPainter, QPen
|
||||
from PyQt5.QtGui import QBrush, QColor, QPainter, QPaintEvent, QPen
|
||||
from PyQt5.QtWidgets import QProgressBar, QWidget
|
||||
|
||||
from novelwriter.types import (
|
||||
QtPaintAnitAlias, QtAlignCenter, QtRoundCap, QtSizeFixed, QtSolidLine,
|
||||
QtAlignCenter, QtPaintAnitAlias, QtRoundCap, QtSizeFixed, QtSolidLine,
|
||||
QtTransparent
|
||||
)
|
||||
|
||||
@@ -101,5 +101,3 @@ class NProgressCircle(QProgressBar):
|
||||
painter.setPen(self._tColor)
|
||||
painter.drawText(self._cRect, QtAlignCenter, self._text or f"{progress:.1f} %")
|
||||
return
|
||||
|
||||
# END Class NProgressCircle
|
||||
|
||||
@@ -27,8 +27,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from PyQt5.QtGui import QColor, QFont, QPalette
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QColor, QFont, QPalette
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractButton, QFrame, QHBoxLayout, QLabel, QLayout, QScrollArea,
|
||||
QVBoxLayout, QWidget
|
||||
@@ -64,8 +64,6 @@ class NFixedPage(QFrame):
|
||||
self.setLayout(layout)
|
||||
return
|
||||
|
||||
# END Class NFixedPage
|
||||
|
||||
|
||||
class NScrollablePage(QScrollArea):
|
||||
"""Extension: Scrollable Page Widget
|
||||
@@ -89,8 +87,6 @@ class NScrollablePage(QScrollArea):
|
||||
self._widget.setLayout(layout)
|
||||
return
|
||||
|
||||
# END Class NScrollablePage
|
||||
|
||||
|
||||
class NScrollableForm(QScrollArea):
|
||||
"""Extension: Scrollable Form Widget
|
||||
@@ -235,8 +231,6 @@ class NScrollableForm(QScrollArea):
|
||||
self._layout.addStretch(1)
|
||||
return
|
||||
|
||||
# END Class NScrollableForm
|
||||
|
||||
|
||||
class NColourLabel(QLabel):
|
||||
"""Extension: A Coloured Label
|
||||
@@ -267,8 +261,6 @@ class NColourLabel(QLabel):
|
||||
|
||||
return
|
||||
|
||||
# END Class NColourLabel
|
||||
|
||||
|
||||
class NWrappedWidgetBox(QHBoxLayout):
|
||||
"""Extension: A Text-Wrapped Widget Box
|
||||
@@ -287,5 +279,3 @@ class NWrappedWidgetBox(QHBoxLayout):
|
||||
if after:
|
||||
self.addWidget(QLabel(after.lstrip()))
|
||||
return
|
||||
|
||||
# END Class NWrappedWidgetBox
|
||||
|
||||
@@ -24,8 +24,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from PyQt5.QtGui import QStatusTipEvent, QWheelEvent
|
||||
from PyQt5.QtCore import QEvent, QObject
|
||||
from PyQt5.QtGui import QStatusTipEvent, QWheelEvent
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
|
||||
|
||||
@@ -63,13 +63,9 @@ class WheelEventFilter(QObject):
|
||||
self._locked = False
|
||||
return False
|
||||
|
||||
# END Class WheelEventFilter
|
||||
|
||||
|
||||
class StatusTipFilter(QObject):
|
||||
|
||||
def eventFilter(self, obj: QObject, event: QEvent) -> bool:
|
||||
"""Filter out status tip events on menus."""
|
||||
return True if isinstance(event, QStatusTipEvent) else super().eventFilter(obj, event)
|
||||
|
||||
# END Class StatusTipFilter
|
||||
|
||||
@@ -61,8 +61,6 @@ class NToolDialog(QDialog):
|
||||
QApplication.processEvents()
|
||||
return
|
||||
|
||||
# END Class NToolDialog
|
||||
|
||||
|
||||
class NNonBlockingDialog(QDialog):
|
||||
|
||||
@@ -80,8 +78,6 @@ class NNonBlockingDialog(QDialog):
|
||||
QApplication.processEvents()
|
||||
return
|
||||
|
||||
# END Class NNonBlockingDialog
|
||||
|
||||
|
||||
class NComboBox(QComboBox):
|
||||
|
||||
@@ -103,8 +99,6 @@ class NComboBox(QComboBox):
|
||||
self.setCurrentIndex(self.findData(default) if idx < 0 else idx)
|
||||
return
|
||||
|
||||
# END Class NComboBox
|
||||
|
||||
|
||||
class NSpinBox(QSpinBox):
|
||||
|
||||
@@ -120,8 +114,6 @@ class NSpinBox(QSpinBox):
|
||||
event.ignore()
|
||||
return
|
||||
|
||||
# END Class NSpinBox
|
||||
|
||||
|
||||
class NDoubleSpinBox(QDoubleSpinBox):
|
||||
|
||||
@@ -137,8 +129,6 @@ class NDoubleSpinBox(QDoubleSpinBox):
|
||||
event.ignore()
|
||||
return
|
||||
|
||||
# END Class NDoubleSpinBox
|
||||
|
||||
|
||||
class NIconToolButton(QToolButton):
|
||||
|
||||
@@ -156,8 +146,6 @@ class NIconToolButton(QToolButton):
|
||||
self.setIcon(SHARED.theme.getIcon(iconKey))
|
||||
return
|
||||
|
||||
# END Class NIconToolButton
|
||||
|
||||
|
||||
class NIconToggleButton(QToolButton):
|
||||
|
||||
@@ -177,5 +165,3 @@ class NIconToggleButton(QToolButton):
|
||||
iconSize = self.iconSize()
|
||||
self.setIcon(SHARED.theme.getToggleIcon(iconKey, (iconSize.width(), iconSize.height())))
|
||||
return
|
||||
|
||||
# END Class NUnfoldButton
|
||||
|
||||
@@ -29,8 +29,8 @@ from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtWidgets import QComboBox, QWidget
|
||||
|
||||
from novelwriter import SHARED
|
||||
from novelwriter.enum import nwItemClass
|
||||
from novelwriter.constants import nwLabels
|
||||
from novelwriter.enum import nwItemClass
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -126,5 +126,3 @@ class NovelSelector(QComboBox):
|
||||
if not self._blockSignal:
|
||||
self.novelSelectionChanged.emit(self.currentData())
|
||||
return
|
||||
|
||||
# END Class NovelSelector
|
||||
|
||||
@@ -25,15 +25,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from PyQt5.QtGui import QColor, QPaintEvent, QPainter, QPolygon
|
||||
from PyQt5.QtCore import QPoint, QRectF, QSize, Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtGui import QColor, QPainter, QPaintEvent, QPolygon
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractButton, QAction, QButtonGroup, QLabel, QStyle,
|
||||
QStyleOptionToolButton, QToolBar, QToolButton, QWidget
|
||||
)
|
||||
|
||||
from novelwriter.types import (
|
||||
QtPaintAnitAlias, QtAlignLeft, QtMouseOver, QtNoBrush, QtNoPen,
|
||||
QtAlignLeft, QtMouseOver, QtNoBrush, QtNoPen, QtPaintAnitAlias,
|
||||
QtSizeExpanding, QtSizeFixed
|
||||
)
|
||||
|
||||
@@ -112,8 +112,6 @@ class NPagedSideBar(QToolBar):
|
||||
self.buttonClicked.emit(buttonId)
|
||||
return
|
||||
|
||||
# END Class NPagedSideBar
|
||||
|
||||
|
||||
class _NPagedToolButton(QToolButton):
|
||||
|
||||
@@ -190,8 +188,6 @@ class _NPagedToolButton(QToolButton):
|
||||
|
||||
return
|
||||
|
||||
# END Class _NPagedToolButton
|
||||
|
||||
|
||||
class _NPagedToolLabel(QLabel):
|
||||
|
||||
@@ -231,5 +227,3 @@ class _NPagedToolLabel(QLabel):
|
||||
paint.drawText(QRectF(self._lM, self._tM, tW, tH), QtAlignLeft, self.text())
|
||||
|
||||
return
|
||||
|
||||
# END Class _NPagedToolLabel
|
||||
|
||||
@@ -25,7 +25,7 @@ from __future__ import annotations
|
||||
|
||||
from math import ceil
|
||||
|
||||
from PyQt5.QtGui import QPaintEvent, QPainter
|
||||
from PyQt5.QtGui import QPainter, QPaintEvent
|
||||
from PyQt5.QtWidgets import QProgressBar, QWidget
|
||||
|
||||
from novelwriter.types import QtPaintAnitAlias
|
||||
@@ -51,5 +51,3 @@ class NProgressSimple(QProgressBar):
|
||||
painter.setBrush(self.palette().highlight())
|
||||
painter.drawRect(0, 0, progress, self.height())
|
||||
return
|
||||
|
||||
# END Class NProgressSimple
|
||||
|
||||
@@ -27,7 +27,7 @@ import logging
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from PyQt5.QtGui import QColor, QPaintEvent, QPainter
|
||||
from PyQt5.QtGui import QColor, QPainter, QPaintEvent
|
||||
from PyQt5.QtWidgets import QAbstractButton, QWidget
|
||||
|
||||
from novelwriter.types import QtPaintAnitAlias
|
||||
@@ -75,5 +75,3 @@ class StatusLED(QAbstractButton):
|
||||
painter.setOpacity(1.0)
|
||||
painter.drawEllipse(1, 1, self.width() - 2, self.height() - 2)
|
||||
return
|
||||
|
||||
# END Class StatusLED
|
||||
|
||||
@@ -23,12 +23,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from PyQt5.QtGui import QMouseEvent, QPainter, QPaintEvent, QResizeEvent
|
||||
from PyQt5.QtCore import QEvent, QPropertyAnimation, Qt, pyqtProperty
|
||||
from PyQt5.QtGui import QMouseEvent, QPainter, QPaintEvent, QResizeEvent
|
||||
from PyQt5.QtWidgets import QAbstractButton, QWidget
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.types import QtPaintAnitAlias, QtMouseLeft, QtNoPen, QtSizeFixed
|
||||
from novelwriter.types import QtMouseLeft, QtNoPen, QtPaintAnitAlias, QtSizeFixed
|
||||
|
||||
|
||||
class NSwitch(QAbstractButton):
|
||||
@@ -133,5 +133,3 @@ class NSwitch(QAbstractButton):
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
super().enterEvent(event)
|
||||
return
|
||||
|
||||
# END Class NSwitch
|
||||
|
||||
@@ -23,8 +23,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QGridLayout, QLabel, QScrollArea, QWidget
|
||||
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
@@ -127,5 +127,3 @@ class NSwitchBox(QScrollArea):
|
||||
self._content.setRowStretch(self._index + 1, 1)
|
||||
self._index += 1
|
||||
return
|
||||
|
||||
# END Class NSwitchBox
|
||||
|
||||
@@ -26,16 +26,16 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
|
||||
from time import sleep
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtCore import QObject, QRunnable, QUrl, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget
|
||||
|
||||
from novelwriter import CONFIG, SHARED, __version__, __date__, __domain__
|
||||
from novelwriter import CONFIG, SHARED, __date__, __domain__, __version__
|
||||
from novelwriter.common import formatVersion
|
||||
from novelwriter.constants import nwConst
|
||||
|
||||
@@ -111,8 +111,6 @@ class VersionInfoWidget(QWidget):
|
||||
self._lblRelease.setText(self._trLatest.format(reason or self.tr("Failed")))
|
||||
return
|
||||
|
||||
# END Class VersionInfoWidget
|
||||
|
||||
|
||||
class _Retriever(QRunnable):
|
||||
|
||||
@@ -144,10 +142,6 @@ class _Retriever(QRunnable):
|
||||
self.signals.dataReady.emit("", str(e))
|
||||
return
|
||||
|
||||
# END Class _Retriever
|
||||
|
||||
|
||||
class _RetrieverSignal(QObject):
|
||||
dataReady = pyqtSignal(str, str)
|
||||
|
||||
# END Class _RetrieverSignal
|
||||
|
||||
@@ -78,8 +78,6 @@ class _SelectAction(Enum):
|
||||
KEEP_POSITION = 2
|
||||
MOVE_AFTER = 3
|
||||
|
||||
# END Class _SelectAction
|
||||
|
||||
|
||||
class GuiDocEditor(QPlainTextEdit):
|
||||
"""Gui Widget: Main Document Editor"""
|
||||
@@ -2131,8 +2129,6 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
self._doReplace = False
|
||||
return
|
||||
|
||||
# END Class GuiDocEditor
|
||||
|
||||
|
||||
class MetaCompleter(QMenu):
|
||||
"""GuiWidget: Meta Completer Menu
|
||||
@@ -2210,15 +2206,13 @@ class MetaCompleter(QMenu):
|
||||
self.complete.emit(pos, length, value)
|
||||
return
|
||||
|
||||
# END Class MetaCompleter
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Off-GUI Thread Word Counter
|
||||
# A runnable for the word counter to be run in the thread pool off the main GUI thread.
|
||||
# =============================================================================================== #
|
||||
|
||||
class BackgroundWordCounter(QRunnable):
|
||||
"""The Off-GUI Thread Word Counter
|
||||
|
||||
A runnable for the word counter to be run in the thread pool off the
|
||||
main GUI thread.
|
||||
"""
|
||||
|
||||
def __init__(self, docEditor: GuiDocEditor, forSelection: bool = False) -> None:
|
||||
super().__init__()
|
||||
@@ -2251,8 +2245,6 @@ class BackgroundWordCounter(QRunnable):
|
||||
|
||||
return
|
||||
|
||||
# END Class BackgroundWordCounter
|
||||
|
||||
|
||||
class BackgroundWordCounterSignals(QObject):
|
||||
"""The QRunnable cannot emit a signal, so we need a simple QObject
|
||||
@@ -2260,15 +2252,13 @@ class BackgroundWordCounterSignals(QObject):
|
||||
"""
|
||||
countsReady = pyqtSignal(int, int, int)
|
||||
|
||||
# END Class BackgroundWordCounterSignals
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Formatting and Options Fold Out Menu
|
||||
# Only used by DocEditor, and is opened by the first button in the header
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiDocToolBar(QWidget):
|
||||
"""The Formatting and Options Fold Out Menu
|
||||
|
||||
Only used by DocEditor, and is opened by the first button in the
|
||||
header.
|
||||
"""
|
||||
|
||||
requestDocAction = pyqtSignal(nwDocAction)
|
||||
|
||||
@@ -2393,15 +2383,13 @@ class GuiDocToolBar(QWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiDocToolBar
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Embedded Document Search/Replace Feature
|
||||
# Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiDocEditSearch(QFrame):
|
||||
"""The Embedded Document Search/Replace Feature
|
||||
|
||||
Only used by DocEditor, and is at a fixed position in the
|
||||
QTextEdit's viewport.
|
||||
"""
|
||||
|
||||
def __init__(self, docEditor: GuiDocEditor) -> None:
|
||||
super().__init__(parent=docEditor)
|
||||
@@ -2757,15 +2745,13 @@ class GuiDocEditSearch(QFrame):
|
||||
self.searchBox.setPalette(qPalette)
|
||||
return
|
||||
|
||||
# END Class GuiDocEditSearch
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Embedded Document Header
|
||||
# Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiDocEditHeader(QWidget):
|
||||
"""The Embedded Document Header
|
||||
|
||||
Only used by DocEditor, and is at a fixed position in the
|
||||
QTextEdit's viewport.
|
||||
"""
|
||||
|
||||
closeDocumentRequest = pyqtSignal()
|
||||
toggleToolBarRequest = pyqtSignal()
|
||||
@@ -2980,15 +2966,13 @@ class GuiDocEditHeader(QWidget):
|
||||
self.docEditor.requestProjectItemSelected.emit(self._docHandle or "", True)
|
||||
return
|
||||
|
||||
# END Class GuiDocEditHeader
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Embedded Document Footer
|
||||
# Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiDocEditFooter(QWidget):
|
||||
"""The Embedded Document Footer
|
||||
|
||||
Only used by DocEditor, and is at a fixed position in the
|
||||
QTextEdit's viewport.
|
||||
"""
|
||||
|
||||
def __init__(self, parent: QWidget) -> None:
|
||||
super().__init__(parent=parent)
|
||||
@@ -3171,5 +3155,3 @@ class GuiDocEditFooter(QWidget):
|
||||
wText = self._trWordCount.format("0", "+0")
|
||||
self.wordsText.setText(wText)
|
||||
return
|
||||
|
||||
# END Class GuiDocEditFooter
|
||||
|
||||
@@ -463,8 +463,6 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiDocHighlighter
|
||||
|
||||
|
||||
class TextBlockData(QTextBlockUserData):
|
||||
|
||||
@@ -505,5 +503,3 @@ class TextBlockData(QTextBlockUserData):
|
||||
(rxMatch.capturedStart(0), rxMatch.capturedLength(0))
|
||||
)
|
||||
return self._spellErrors
|
||||
|
||||
# END Class TextBlockData
|
||||
|
||||
@@ -496,8 +496,6 @@ class GuiDocViewer(QTextBrowser):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiDocViewer
|
||||
|
||||
|
||||
class GuiDocViewHistory:
|
||||
|
||||
@@ -611,15 +609,13 @@ class GuiDocViewHistory:
|
||||
)
|
||||
return
|
||||
|
||||
# END Class GuiDocViewHistory
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Embedded Document Header
|
||||
# Only used by DocViewer, and is at a fixed position in the QTextBrowser's viewport
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiDocViewHeader(QWidget):
|
||||
"""The Embedded Document Header
|
||||
|
||||
Only used by DocViewer, and is at a fixed position in the
|
||||
QTextBrowser's viewport.
|
||||
"""
|
||||
|
||||
def __init__(self, docViewer: GuiDocViewer) -> None:
|
||||
super().__init__(parent=docViewer)
|
||||
@@ -835,15 +831,13 @@ class GuiDocViewHeader(QWidget):
|
||||
self.docViewer.requestProjectItemSelected.emit(self._docHandle, True)
|
||||
return
|
||||
|
||||
# END Class GuiDocViewHeader
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Embedded Document Footer
|
||||
# Only used by DocViewer, and is at a fixed position in the QTextBrowser's viewport
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiDocViewFooter(QWidget):
|
||||
"""The Embedded Document Footer
|
||||
|
||||
Only used by DocViewer, and is at a fixed position in the
|
||||
QTextBrowser's viewport.
|
||||
"""
|
||||
|
||||
def __init__(self, docViewer: GuiDocViewer) -> None:
|
||||
super().__init__(parent=docViewer)
|
||||
@@ -967,5 +961,3 @@ class GuiDocViewFooter(QWidget):
|
||||
CONFIG.viewSynopsis = state
|
||||
self.docViewer.reloadText()
|
||||
return
|
||||
|
||||
# END Class GuiDocViewFooter
|
||||
|
||||
@@ -221,8 +221,6 @@ class GuiDocViewerPanel(QWidget):
|
||||
self.kwTabs[tClass].addUpdateEntry(key, name, iItem, hItem)
|
||||
return
|
||||
|
||||
# END Class GuiDocViewerPanel
|
||||
|
||||
|
||||
class _ViewPanelBackRefs(QTreeWidget):
|
||||
|
||||
@@ -360,8 +358,6 @@ class _ViewPanelBackRefs(QTreeWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class _ViewPanelBackRefs
|
||||
|
||||
|
||||
class _ViewPanelKeyWords(QTreeWidget):
|
||||
|
||||
@@ -528,5 +524,3 @@ class _ViewPanelKeyWords(QTreeWidget):
|
||||
if index.column() not in (self.C_EDIT, self.C_VIEW):
|
||||
self._parent.loadDocumentTagRequest.emit(tag, nwDocMode.VIEW)
|
||||
return
|
||||
|
||||
# END Class _ViewPanelKeyWords
|
||||
|
||||
@@ -28,8 +28,8 @@ import logging
|
||||
from collections.abc import Iterable
|
||||
from time import time
|
||||
|
||||
from PyQt5.QtGui import QTextBlock, QTextCursor, QTextDocument
|
||||
from PyQt5.QtCore import QObject, pyqtSlot
|
||||
from PyQt5.QtGui import QTextBlock, QTextCursor, QTextDocument
|
||||
from PyQt5.QtWidgets import QApplication, QPlainTextDocumentLayout
|
||||
|
||||
from novelwriter import SHARED
|
||||
@@ -133,5 +133,3 @@ class GuiTextDocument(QTextDocument):
|
||||
"""Set the spell check state of the syntax highlighter."""
|
||||
self._syntax.setSpellCheck(state)
|
||||
return
|
||||
|
||||
# END Class GuiTextDocument
|
||||
|
||||
@@ -295,5 +295,3 @@ class GuiItemDetails(QWidget):
|
||||
self.wCountData.setText(f"{wC:n}")
|
||||
self.pCountData.setText(f"{pC:n}")
|
||||
return
|
||||
|
||||
# END Class GuiItemDetails
|
||||
|
||||
@@ -991,5 +991,3 @@ class GuiMainMenu(QMenuBar):
|
||||
self.aWebsite.triggered.connect(lambda: self._openWebsite(nwConst.URL_WEB))
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiMainMenu
|
||||
|
||||
@@ -61,8 +61,6 @@ class NovelTreeColumn(Enum):
|
||||
FOCUS = 2
|
||||
PLOT = 3
|
||||
|
||||
# END Enum NovelTreeColumn
|
||||
|
||||
|
||||
class GuiNovelView(QWidget):
|
||||
|
||||
@@ -185,8 +183,6 @@ class GuiNovelView(QWidget):
|
||||
self.novelTree.refreshHandle(tHandle)
|
||||
return
|
||||
|
||||
# END Class GuiNovelView
|
||||
|
||||
|
||||
class GuiNovelToolBar(QWidget):
|
||||
|
||||
@@ -349,8 +345,6 @@ class GuiNovelToolBar(QWidget):
|
||||
self.aLastCol[colType] = aLast
|
||||
return
|
||||
|
||||
# END Class GuiNovelToolBar
|
||||
|
||||
|
||||
class GuiNovelTree(QTreeWidget):
|
||||
|
||||
@@ -778,5 +772,3 @@ class GuiNovelTree(QTreeWidget):
|
||||
if tags:
|
||||
lines.append(f"<b>{trConst(nwLabels.KEY_NAME[key])}</b>: {tags}")
|
||||
return lines
|
||||
|
||||
# END Class GuiNovelTree
|
||||
|
||||
@@ -30,10 +30,10 @@ from __future__ import annotations
|
||||
import csv
|
||||
import logging
|
||||
|
||||
from time import time
|
||||
from enum import Enum
|
||||
from time import time
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot, QT_TRANSLATE_NOOP
|
||||
from PyQt5.QtCore import QT_TRANSLATE_NOOP, Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QAction, QFileDialog, QFrame, QGridLayout, QGroupBox,
|
||||
QHBoxLayout, QLabel, QMenu, QScrollArea, QSplitter, QToolBar, QToolButton,
|
||||
@@ -41,10 +41,10 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import checkInt, formatFileFilter, makeFileNameSafe
|
||||
from novelwriter.constants import nwHeaders, nwKeyWords, nwLabels, trConst
|
||||
from novelwriter.enum import nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.common import checkInt, formatFileFilter, makeFileNameSafe
|
||||
from novelwriter.constants import nwHeaders, trConst, nwKeyWords, nwLabels
|
||||
from novelwriter.extensions.configlayout import NColourLabel
|
||||
from novelwriter.extensions.novelselector import NovelSelector
|
||||
from novelwriter.types import (
|
||||
@@ -52,7 +52,6 @@ from novelwriter.types import (
|
||||
QtSizeExpanding, QtUserRole
|
||||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -195,8 +194,6 @@ class GuiOutlineView(QWidget):
|
||||
self.outlineTree.refreshTree(rootHandle=(tHandle or None), overRide=True)
|
||||
return
|
||||
|
||||
# END Class GuiOutlineView
|
||||
|
||||
|
||||
class GuiOutlineToolBar(QToolBar):
|
||||
|
||||
@@ -310,8 +307,6 @@ class GuiOutlineToolBar(QToolBar):
|
||||
self.outlineExportRequest.emit()
|
||||
return
|
||||
|
||||
# END Class GuiOutlineToolBar
|
||||
|
||||
|
||||
class GuiOutlineTree(QTreeWidget):
|
||||
|
||||
@@ -727,8 +722,6 @@ class GuiOutlineTree(QTreeWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiOutlineTree
|
||||
|
||||
|
||||
class GuiOutlineHeaderMenu(QMenu):
|
||||
|
||||
@@ -771,8 +764,6 @@ class GuiOutlineHeaderMenu(QMenu):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiOutlineHeaderMenu
|
||||
|
||||
|
||||
class GuiOutlineDetails(QScrollArea):
|
||||
|
||||
@@ -1103,5 +1094,3 @@ class GuiOutlineDetails(QScrollArea):
|
||||
return ", ".join(
|
||||
[f"<a href='{tag}'>{tag}</a>" for tag in refs.get(key, [])]
|
||||
)
|
||||
|
||||
# END Class GuiOutlineDetails
|
||||
|
||||
@@ -243,8 +243,6 @@ class GuiProjectView(QWidget):
|
||||
self.projTree.createNewNote(tag, itemClass)
|
||||
return
|
||||
|
||||
# END Class GuiProjectView
|
||||
|
||||
|
||||
class GuiProjectToolBar(QWidget):
|
||||
|
||||
@@ -470,8 +468,6 @@ class GuiProjectToolBar(QWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiProjectToolBar
|
||||
|
||||
|
||||
class GuiProjectTree(QTreeWidget):
|
||||
|
||||
@@ -1651,8 +1647,6 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiProjectTree
|
||||
|
||||
|
||||
class _UpdatableMenu(QMenu):
|
||||
|
||||
@@ -1716,8 +1710,6 @@ class _UpdatableMenu(QMenu):
|
||||
self.menuItemTriggered.emit(str(action.data()))
|
||||
return
|
||||
|
||||
# END Class _UpdatableMenu
|
||||
|
||||
|
||||
class _TreeContextMenu(QMenu):
|
||||
|
||||
@@ -2069,5 +2061,3 @@ class _TreeContextMenu(QMenu):
|
||||
else:
|
||||
logger.info("Folder conversion cancelled")
|
||||
return
|
||||
|
||||
# END Class _TreeContextMenu
|
||||
|
||||
@@ -358,5 +358,3 @@ class GuiProjectSearch(QWidget):
|
||||
QApplication.processEvents()
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiProjectSearch
|
||||
|
||||
@@ -150,8 +150,6 @@ class GuiSideBar(QWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiSideBar
|
||||
|
||||
|
||||
class _PopRightMenu(QMenu):
|
||||
|
||||
@@ -162,5 +160,3 @@ class _PopRightMenu(QMenu):
|
||||
offset = QPoint(parent.width(), parent.height() - self.height())
|
||||
self.move(parent.mapToGlobal(offset))
|
||||
return super(_PopRightMenu, self).event(event)
|
||||
|
||||
# END Class _PopRightMenu
|
||||
|
||||
@@ -262,5 +262,3 @@ class GuiMainStatus(QStatusBar):
|
||||
f" \u2013 Peak: {mem[1]:n}"
|
||||
), 6000)
|
||||
return
|
||||
|
||||
# END Class GuiMainStatus
|
||||
|
||||
@@ -46,12 +46,11 @@ STYLES_MIN_TOOLBUTTON = "minimalToolButton"
|
||||
STYLES_BIG_TOOLBUTTON = "bigToolButton"
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Gui Theme Class
|
||||
# Handles the look and feel of novelWriter
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiTheme:
|
||||
"""Gui Theme Class
|
||||
|
||||
Handles the look and feel of novelWriter.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
||||
@@ -482,12 +481,6 @@ class GuiTheme:
|
||||
|
||||
return
|
||||
|
||||
# End Class GuiTheme
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Icons Class
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiIcons:
|
||||
"""The icon class manages the content of the assets/icons folder,
|
||||
@@ -795,12 +788,9 @@ class GuiIcons:
|
||||
|
||||
return self._noIcon
|
||||
|
||||
# END Class GuiIcons
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Module Functions
|
||||
# =============================================================================================== #
|
||||
# Module Functions
|
||||
# ================
|
||||
|
||||
|
||||
def _sortTheme(data: tuple[str, str]) -> str:
|
||||
|
||||
@@ -1399,5 +1399,3 @@ class GuiMain(QMainWindow):
|
||||
))
|
||||
return None, None
|
||||
return tHandle, sTitle
|
||||
|
||||
# END Class GuiMain
|
||||
|
||||
@@ -376,8 +376,6 @@ class SharedData(QObject):
|
||||
widget.close()
|
||||
return
|
||||
|
||||
# END Class SharedData
|
||||
|
||||
|
||||
class _GuiAlert(QMessageBox):
|
||||
|
||||
@@ -438,5 +436,3 @@ class _GuiAlert(QMessageBox):
|
||||
self.setIconPixmap(self._theme.getPixmap("alert_question", (pSz, pSz)))
|
||||
self.setWindowTitle(self.tr("Question"))
|
||||
return
|
||||
|
||||
# END Class _GuiAlert
|
||||
|
||||
@@ -264,5 +264,3 @@ class GuiDictionaries(NNonBlockingDialog):
|
||||
cursor.deleteChar()
|
||||
self.infoBox.setTextCursor(cursor)
|
||||
return
|
||||
|
||||
# END Class GuiDictionaries
|
||||
|
||||
@@ -23,8 +23,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
import logging
|
||||
import random
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtWidgets import (
|
||||
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import readTextFile
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.types import QtAlignLeft, QtAlignRight, QtRoleAction, QtDialogClose
|
||||
from novelwriter.types import QtAlignLeft, QtAlignRight, QtDialogClose, QtRoleAction
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -150,5 +150,3 @@ class GuiLipsum(QDialog):
|
||||
self._lipsumText = "\n\n".join(lipsumText[0:pCount]) + "\n\n"
|
||||
self.close()
|
||||
return
|
||||
|
||||
# END Class GuiLipsum
|
||||
|
||||
@@ -403,5 +403,3 @@ class GuiManuscriptBuild(QDialog):
|
||||
"""Open the build folder in the system's file explorer."""
|
||||
openExternalPath(Path(self.buildPath.text()))
|
||||
return
|
||||
|
||||
# END Class GuiManuscriptBuild
|
||||
|
||||
@@ -510,8 +510,6 @@ class GuiManuscript(NToolDialog):
|
||||
return obj
|
||||
return None
|
||||
|
||||
# END Class GuiManuscript
|
||||
|
||||
|
||||
class _DetailsWidget(QWidget):
|
||||
|
||||
@@ -653,8 +651,6 @@ class _DetailsWidget(QWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class _DetailsWidget
|
||||
|
||||
|
||||
class _OutlineWidget(QWidget):
|
||||
|
||||
@@ -734,8 +730,6 @@ class _OutlineWidget(QWidget):
|
||||
self.outlineEntryClicked.emit(str(item.data(0, self.D_LINE)))
|
||||
return
|
||||
|
||||
# END Class _OutlineWidget
|
||||
|
||||
|
||||
class _PreviewWidget(QTextBrowser):
|
||||
|
||||
@@ -961,8 +955,6 @@ class _PreviewWidget(QTextBrowser):
|
||||
self.buildProgress.move((vW-pS)//2, (vH-pS)//2)
|
||||
return
|
||||
|
||||
# END Class _PreviewWidget
|
||||
|
||||
|
||||
class _StatsWidget(QWidget):
|
||||
|
||||
@@ -1136,5 +1128,3 @@ class _StatsWidget(QWidget):
|
||||
self.maxWidget.setLayout(self.maxLayout)
|
||||
|
||||
return
|
||||
|
||||
# END Class _StatsWidget
|
||||
|
||||
@@ -278,8 +278,6 @@ class GuiBuildSettings(NToolDialog):
|
||||
self._build.resetChangedState()
|
||||
return
|
||||
|
||||
# END Class GuiBuildSettings
|
||||
|
||||
|
||||
class _FilterTab(NFixedPage):
|
||||
|
||||
@@ -574,8 +572,6 @@ class _FilterTab(NFixedPage):
|
||||
self._scanChildren(item.child(i), items)
|
||||
return items
|
||||
|
||||
# END Class _FilterTab
|
||||
|
||||
|
||||
class _HeadingsTab(NScrollablePage):
|
||||
|
||||
@@ -941,8 +937,6 @@ class _HeadingsTab(NScrollablePage):
|
||||
|
||||
return
|
||||
|
||||
# END Class _HeadingsTab
|
||||
|
||||
|
||||
class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
|
||||
|
||||
@@ -967,8 +961,6 @@ class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
|
||||
self.setFormat(pos + ddots, 1, self._fmtSymbol)
|
||||
return
|
||||
|
||||
# END Class _HeadingSyntaxHighlighter
|
||||
|
||||
|
||||
class _ContentTab(NScrollableForm):
|
||||
|
||||
@@ -1052,8 +1044,6 @@ class _ContentTab(NScrollableForm):
|
||||
self.ignoredKeywords.setText(", ".join(verified))
|
||||
return
|
||||
|
||||
# END Class _ContentTab
|
||||
|
||||
|
||||
class _FormatTab(NScrollableForm):
|
||||
|
||||
@@ -1346,8 +1336,6 @@ class _FormatTab(NScrollableForm):
|
||||
self.pageSize.setCurrentIndex(index)
|
||||
return
|
||||
|
||||
# END Class _FormatTab
|
||||
|
||||
|
||||
class _OutputTab(NScrollableForm):
|
||||
|
||||
@@ -1432,5 +1420,3 @@ class _OutputTab(NScrollableForm):
|
||||
self.odtPageHeader.setText(nwHeadFmt.ODT_AUTO)
|
||||
self.odtPageHeader.setCursorPosition(0)
|
||||
return
|
||||
|
||||
# END Class _OutputTab
|
||||
|
||||
@@ -186,8 +186,6 @@ class GuiNovelDetails(NNonBlockingDialog):
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiNovelDetails
|
||||
|
||||
|
||||
class _OverviewPage(NScrollablePage):
|
||||
|
||||
@@ -294,8 +292,6 @@ class _OverviewPage(NScrollablePage):
|
||||
|
||||
return
|
||||
|
||||
# END Class _OverviewPage
|
||||
|
||||
|
||||
class _ContentsPage(NFixedPage):
|
||||
|
||||
@@ -524,5 +520,3 @@ class _ContentsPage(NFixedPage):
|
||||
self._data = SHARED.project.index.getTableOfContents(rootHandle, 2)
|
||||
self._data.append(("", 0, self.tr("END"), 0))
|
||||
return
|
||||
|
||||
# END Class _ContentsPage
|
||||
|
||||
@@ -32,11 +32,11 @@ from PyQt5.QtCore import (
|
||||
QAbstractListModel, QEvent, QModelIndex, QObject, QPoint, QSize, Qt,
|
||||
pyqtSignal, pyqtSlot
|
||||
)
|
||||
from PyQt5.QtGui import QCloseEvent, QColor, QFont, QPaintEvent, QPainter, QPen
|
||||
from PyQt5.QtGui import QCloseEvent, QColor, QFont, QPainter, QPaintEvent, QPen
|
||||
from PyQt5.QtWidgets import (
|
||||
QAction, QApplication, QDialog, QFileDialog, QFormLayout, QHBoxLayout,
|
||||
QLabel, QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut,
|
||||
QStackedWidget, QStyleOptionViewItem, QStyledItemDelegate, QVBoxLayout,
|
||||
QStackedWidget, QStyledItemDelegate, QStyleOptionViewItem, QVBoxLayout,
|
||||
QWidget
|
||||
)
|
||||
|
||||
@@ -267,8 +267,6 @@ class GuiWelcome(QDialog):
|
||||
self.btnCreate.setFocus()
|
||||
return
|
||||
|
||||
# END Class GuiWelcome
|
||||
|
||||
|
||||
class _OpenProjectPage(QWidget):
|
||||
|
||||
@@ -392,8 +390,6 @@ class _OpenProjectPage(QWidget):
|
||||
self._projectClicked(index)
|
||||
return
|
||||
|
||||
# END Class _OpenProjectPage
|
||||
|
||||
|
||||
class _ProjectListItem(QStyledItemDelegate):
|
||||
|
||||
@@ -450,8 +446,6 @@ class _ProjectListItem(QStyledItemDelegate):
|
||||
"""Set the size hint to fixed height."""
|
||||
return QSize(opt.rect.width(), self._hPx)
|
||||
|
||||
# END Class _ProjectListItem
|
||||
|
||||
|
||||
class _ProjectListModel(QAbstractListModel):
|
||||
|
||||
@@ -491,8 +485,6 @@ class _ProjectListModel(QAbstractListModel):
|
||||
return True
|
||||
return False
|
||||
|
||||
# END Class _ProjectListModel
|
||||
|
||||
|
||||
class _NewProjectPage(QWidget):
|
||||
|
||||
@@ -548,8 +540,6 @@ class _NewProjectPage(QWidget):
|
||||
self.openProjectRequest.emit(path)
|
||||
return
|
||||
|
||||
# END Class _NewProjectPage
|
||||
|
||||
|
||||
class _NewProjectForm(QWidget):
|
||||
|
||||
@@ -805,8 +795,6 @@ class _NewProjectForm(QWidget):
|
||||
|
||||
return
|
||||
|
||||
# END Class _NewProjectForm
|
||||
|
||||
|
||||
class _PopLeftDirectionMenu(QMenu):
|
||||
|
||||
@@ -817,5 +805,3 @@ class _PopLeftDirectionMenu(QMenu):
|
||||
offset = QPoint(parent.width() - self.width(), parent.height())
|
||||
self.move(parent.mapToGlobal(offset))
|
||||
return super(_PopLeftDirectionMenu, self).event(event)
|
||||
|
||||
# END Class _PopLeftDirectionMenu
|
||||
|
||||
@@ -614,5 +614,3 @@ class GuiWritingStats(NToolDialog):
|
||||
self.labelFilter.setText(formatTime(round(self.timeFilter)))
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiWritingStats
|
||||
|
||||
@@ -1718,5 +1718,3 @@ if __name__ == "__main__":
|
||||
sys.exit(1)
|
||||
else:
|
||||
xdgUninstall()
|
||||
|
||||
# END Main
|
||||
|
||||
+6
-5
@@ -20,15 +20,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -36,6 +34,9 @@ sys.path.insert(1, str(Path(__file__).parent.parent.absolute()))
|
||||
|
||||
from novelwriter import CONFIG, SHARED, main # noqa: E402
|
||||
|
||||
from tests.mocked import MockGuiMain, MockTheme # noqa: E402
|
||||
from tests.tools import cleanProject # noqa: E402
|
||||
|
||||
_TST_ROOT = Path(__file__).parent
|
||||
_TMP_ROOT = _TST_ROOT / "temp"
|
||||
_TMP_CONF = _TMP_ROOT / "conf"
|
||||
|
||||
+3
-16
@@ -24,10 +24,6 @@ from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
|
||||
|
||||
# =========================================================================== #
|
||||
# Mock GUI
|
||||
# =========================================================================== #
|
||||
|
||||
class MockGuiMain(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
@@ -55,8 +51,6 @@ class MockGuiMain(QWidget):
|
||||
def close(self):
|
||||
return "close"
|
||||
|
||||
# END Class MockGuiMain
|
||||
|
||||
|
||||
class MockStatusBar:
|
||||
|
||||
@@ -69,8 +63,6 @@ class MockStatusBar:
|
||||
def updateProjectStatus(self, status):
|
||||
return
|
||||
|
||||
# END Class MockStatusBar
|
||||
|
||||
|
||||
class MockTheme:
|
||||
|
||||
@@ -81,8 +73,6 @@ class MockTheme:
|
||||
def getPixmap(self, *a):
|
||||
return QPixmap()
|
||||
|
||||
# END Class MockTheme
|
||||
|
||||
|
||||
class MockApp:
|
||||
|
||||
@@ -92,13 +82,10 @@ class MockApp:
|
||||
def installTranslator(self, language):
|
||||
return
|
||||
|
||||
# END Class MockApp
|
||||
|
||||
|
||||
# =========================================================================== #
|
||||
# Error Functions
|
||||
# Mock functions that will raise errors instead.
|
||||
# =========================================================================== #
|
||||
# Error Functions
|
||||
# ===============
|
||||
# Mock functions that will raise errors instead.
|
||||
|
||||
def causeOSError(*args, **kwargs):
|
||||
raise OSError("Mock OSError")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,18 +21,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,13 +20,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,20 +21,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,15 +21,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
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
|
||||
|
||||
@@ -21,15 +21,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
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
|
||||
|
||||
@@ -20,25 +20,25 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,18 +20,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -21,18 +21,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,20 +21,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
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
|
||||
|
||||
@@ -129,8 +129,6 @@ def testCoreToHtml_ConvertHeaders(mockGUI):
|
||||
html.doConvert()
|
||||
assert html.result == "<h2><a name='0000000000000:T0001'></a>Heading Two</h2>\n"
|
||||
|
||||
# END Test testCoreToHtml_ConvertHeaders
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreToHtml_ConvertParagraphs(mockGUI):
|
||||
@@ -301,8 +299,6 @@ def testCoreToHtml_ConvertParagraphs(mockGUI):
|
||||
"text</b> here</p>\n"
|
||||
)
|
||||
|
||||
# END Test testCoreToHtml_ConvertParagraphs
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
@@ -447,8 +443,6 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
"<p style='margin-right: 40px;'>Some text ...</p>\n"
|
||||
)
|
||||
|
||||
# END Test testCoreToHtml_ConvertDirect
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreToHtml_SpecialCases(mockGUI):
|
||||
@@ -521,8 +515,6 @@ def testCoreToHtml_SpecialCases(mockGUI):
|
||||
"<p>Test text **<em>bold</em>** and more.</p>\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):
|
||||
"<a class='tag' href='#char=Bod'>Bod</a>, "
|
||||
"<a class='tag' href='#char=Jane'>Jane</a>"
|
||||
)
|
||||
|
||||
# END Test testCoreToHtml_Format
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
'</office:text>'
|
||||
)
|
||||
|
||||
# END Test testCoreToOdt_TextFormatting
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreToOdt_ConvertHeaders(mockGUI):
|
||||
@@ -325,8 +320,6 @@ def testCoreToOdt_ConvertHeaders(mockGUI):
|
||||
'</office:text>'
|
||||
)
|
||||
|
||||
# END Test testCoreToOdt_ConvertHeaders
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreToOdt_ConvertParagraphs(mockGUI):
|
||||
@@ -675,8 +668,6 @@ def testCoreToOdt_ConvertParagraphs(mockGUI):
|
||||
'</office:text>'
|
||||
)
|
||||
|
||||
# END Test testCoreToOdt_ConvertParagraphs
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreToOdt_ConvertDirect(mockGUI):
|
||||
@@ -730,8 +721,6 @@ def testCoreToOdt_ConvertDirect(mockGUI):
|
||||
'</office:text>'
|
||||
)
|
||||
|
||||
# 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():
|
||||
'</style:style></test>'
|
||||
)
|
||||
|
||||
# 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
|
||||
|
||||
@@ -20,20 +20,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -20,10 +20,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user