From 2afe0ebbe9f0469533897bf9a03180677816464b Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 10 May 2024 16:00:56 +0200 Subject: [PATCH 1/6] Remove all END Class comments --- novelwriter/__init__.py | 2 -- novelwriter/common.py | 2 -- novelwriter/config.py | 14 +++++-------- novelwriter/constants.py | 24 ---------------------- novelwriter/core/buildsettings.py | 4 ---- novelwriter/core/coretools.py | 10 --------- novelwriter/core/docbuild.py | 2 -- novelwriter/core/document.py | 8 +++----- novelwriter/core/index.py | 11 ---------- novelwriter/core/item.py | 7 +++---- novelwriter/core/options.py | 6 ++---- novelwriter/core/project.py | 11 +++++----- novelwriter/core/projectdata.py | 4 +--- novelwriter/core/projectxml.py | 12 +++-------- novelwriter/core/sessions.py | 8 +++----- novelwriter/core/spellcheck.py | 13 ++++-------- novelwriter/core/status.py | 8 +------- novelwriter/core/storage.py | 4 ---- novelwriter/core/tohtml.py | 2 -- novelwriter/core/tokenizer.py | 4 ---- novelwriter/core/tomd.py | 2 -- novelwriter/core/toodt.py | 9 -------- novelwriter/core/tree.py | 12 +++++------ novelwriter/dialogs/about.py | 2 -- novelwriter/dialogs/docmerge.py | 4 +--- novelwriter/dialogs/docsplit.py | 4 +--- novelwriter/dialogs/editlabel.py | 2 -- novelwriter/dialogs/preferences.py | 2 -- novelwriter/dialogs/projectsettings.py | 12 ++--------- novelwriter/dialogs/quotes.py | 6 ++---- novelwriter/dialogs/wordlist.py | 2 -- novelwriter/error.py | 15 +++++++------- novelwriter/extensions/circularprogress.py | 6 ++---- novelwriter/extensions/configlayout.py | 12 +---------- novelwriter/extensions/eventfilters.py | 6 +----- novelwriter/extensions/modified.py | 14 ------------- novelwriter/extensions/novelselector.py | 4 +--- novelwriter/extensions/pagedsidebar.py | 10 ++------- novelwriter/extensions/simpleprogress.py | 4 +--- novelwriter/extensions/statusled.py | 4 +--- novelwriter/extensions/switch.py | 6 ++---- novelwriter/extensions/switchbox.py | 4 +--- novelwriter/extensions/versioninfo.py | 12 +++-------- novelwriter/gui/doceditor.py | 20 ++++++++---------- novelwriter/gui/dochighlight.py | 4 ---- novelwriter/gui/docviewer.py | 8 -------- novelwriter/gui/docviewerpanel.py | 6 ------ novelwriter/gui/editordocument.py | 4 +--- novelwriter/gui/itemdetails.py | 2 -- novelwriter/gui/mainmenu.py | 2 -- novelwriter/gui/noveltree.py | 6 ------ novelwriter/gui/outline.py | 19 ++++------------- novelwriter/gui/projtree.py | 10 --------- novelwriter/gui/search.py | 2 -- novelwriter/gui/sidebar.py | 4 ---- novelwriter/gui/statusbar.py | 2 -- novelwriter/gui/theme.py | 2 -- novelwriter/guimain.py | 2 -- novelwriter/shared.py | 4 ---- novelwriter/tools/dictionaries.py | 2 -- novelwriter/tools/lipsum.py | 6 ++---- novelwriter/tools/manusbuild.py | 2 -- novelwriter/tools/manuscript.py | 10 --------- novelwriter/tools/manussettings.py | 14 ------------- novelwriter/tools/noveldetails.py | 6 ------ novelwriter/tools/welcome.py | 18 ++-------------- novelwriter/tools/writingstats.py | 2 -- pkgutils.py | 2 -- tests/mocked.py | 10 +-------- tests/test_ext/test_ext_modified.py | 7 ++----- tests/tools.py | 8 ++------ 71 files changed, 87 insertions(+), 407 deletions(-) diff --git a/novelwriter/__init__.py b/novelwriter/__init__.py index d29e191f..348ce56f 100644 --- a/novelwriter/__init__.py +++ b/novelwriter/__init__.py @@ -242,5 +242,3 @@ def main(sysArgs: list | None = None) -> GuiMain | None: sys.exit(nwApp.exec()) return None - -# END Function main diff --git a/novelwriter/common.py b/novelwriter/common.py index 8573c1bd..b1282867 100644 --- a/novelwriter/common.py +++ b/novelwriter/common.py @@ -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 diff --git a/novelwriter/config.py b/novelwriter/config.py index e9fab918..1627cade 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -24,24 +24,24 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/constants.py b/novelwriter/constants.py index dac0604a..2f409d9a 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -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)(?. """ 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 diff --git a/novelwriter/core/projectxml.py b/novelwriter/core/projectxml.py index ac28ed4a..7f7551c2 100644 --- a/novelwriter/core/projectxml.py +++ b/novelwriter/core/projectxml.py @@ -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 diff --git a/novelwriter/core/sessions.py b/novelwriter/core/sessions.py index 2f79ad20..444b2d3c 100644 --- a/novelwriter/core/sessions.py +++ b/novelwriter/core/sessions.py @@ -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 diff --git a/novelwriter/core/spellcheck.py b/novelwriter/core/spellcheck.py index 6dc47785..587895c0 100644 --- a/novelwriter/core/spellcheck.py +++ b/novelwriter/core/spellcheck.py @@ -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 diff --git a/novelwriter/core/status.py b/novelwriter/core/status.py index 50f7e1d2..c29c34a2 100644 --- a/novelwriter/core/status.py +++ b/novelwriter/core/status.py @@ -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() diff --git a/novelwriter/core/storage.py b/novelwriter/core/storage.py index e8a2bb16..8daccd86 100644 --- a/novelwriter/core/storage.py +++ b/novelwriter/core/storage.py @@ -391,8 +391,6 @@ class NWStorage: self._lockedBy = None return True -# END Class NWStorage - class _LegacyStorage: """Core: Legacy Storage Converter Utils @@ -590,5 +588,3 @@ class _LegacyStorage: logException() return - -# END Class _LegacyStorage diff --git a/novelwriter/core/tohtml.py b/novelwriter/core/tohtml.py index 575fd410..2f64bb56 100644 --- a/novelwriter/core/tohtml.py +++ b/novelwriter/core/tohtml.py @@ -536,5 +536,3 @@ class ToHtml(Tokenizer): ) return bits[0][1:], result - -# END Class ToHtml diff --git a/novelwriter/core/tokenizer.py b/novelwriter/core/tokenizer.py index 148fe574..15cd8046 100644 --- a/novelwriter/core/tokenizer.py +++ b/novelwriter/core/tokenizer.py @@ -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 diff --git a/novelwriter/core/tomd.py b/novelwriter/core/tomd.py index e794083a..371b6f7c 100644 --- a/novelwriter/core/tomd.py +++ b/novelwriter/core/tomd.py @@ -272,5 +272,3 @@ class ToMarkdown(Tokenizer): result += " \n" if style & self.A_Z_BTMMRG else "\n\n" return result - -# END Class ToMarkdown diff --git a/novelwriter/core/toodt.py b/novelwriter/core/toodt.py index 92003f52..e06c8de6 100644 --- a/novelwriter/core/toodt.py +++ b/novelwriter/core/toodt.py @@ -1079,8 +1079,6 @@ class ToOdt(Tokenizer): return -# END Class ToOdt - # =============================================================================================== # # Auto-Style Classes @@ -1332,8 +1330,6 @@ class ODTParagraphStyle: return -# END Class ODTParagraphStyle - class ODTTextStyle: """Wrapper class for the text style setting used by the exporter. @@ -1457,13 +1453,10 @@ class ODTTextStyle: ET.SubElement(xEntry, _mkTag("style", "text-properties"), attrib=attr) return -# END Class ODTTextStyle - # =============================================================================================== # # XML Complex Element Helper Class # =============================================================================================== # - X_ROOT_TEXT = 0 X_ROOT_TAIL = 1 X_SPAN_TEXT = 2 @@ -1661,5 +1654,3 @@ class XMLParagraph: self._chrPos += nSpaces - 1 return - -# END Class XMLParagraph diff --git a/novelwriter/core/tree.py b/novelwriter/core/tree.py index f206fdb2..01131b93 100644 --- a/novelwriter/core/tree.py +++ b/novelwriter/core/tree.py @@ -23,18 +23,18 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/dialogs/about.py b/novelwriter/dialogs/about.py index da6ba884..ee138d37 100644 --- a/novelwriter/dialogs/about.py +++ b/novelwriter/dialogs/about.py @@ -152,5 +152,3 @@ class GuiAbout(NNonBlockingDialog): f"QTextBrowser {{border: none; background: {baseCol};}} " ) return - -# END Class GuiAbout diff --git a/novelwriter/dialogs/docmerge.py b/novelwriter/dialogs/docmerge.py index 9c94489e..d258c89a 100644 --- a/novelwriter/dialogs/docmerge.py +++ b/novelwriter/dialogs/docmerge.py @@ -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 diff --git a/novelwriter/dialogs/docsplit.py b/novelwriter/dialogs/docsplit.py index b9d1f048..49325a70 100644 --- a/novelwriter/dialogs/docsplit.py +++ b/novelwriter/dialogs/docsplit.py @@ -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 diff --git a/novelwriter/dialogs/editlabel.py b/novelwriter/dialogs/editlabel.py index a2d374fd..2afbd6fa 100644 --- a/novelwriter/dialogs/editlabel.py +++ b/novelwriter/dialogs/editlabel.py @@ -94,5 +94,3 @@ class GuiEditLabel(QDialog): accepted = cls.result() == QDialog.DialogCode.Accepted cls.deleteLater() return label, accepted - -# END Class GuiEditLabel diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index a8900786..671d4d4e 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -962,5 +962,3 @@ class GuiPreferences(QDialog): self.newPreferencesReady.emit(needsRestart, refreshTree, updateTheme, updateSyntax) return - -# END Class GuiPreferences diff --git a/novelwriter/dialogs/projectsettings.py b/novelwriter/dialogs/projectsettings.py index 23bb43da..74b44409 100644 --- a/novelwriter/dialogs/projectsettings.py +++ b/novelwriter/dialogs/projectsettings.py @@ -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 diff --git a/novelwriter/dialogs/quotes.py b/novelwriter/dialogs/quotes.py index d728994f..12bc0b0b 100644 --- a/novelwriter/dialogs/quotes.py +++ b/novelwriter/dialogs/quotes.py @@ -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 diff --git a/novelwriter/dialogs/wordlist.py b/novelwriter/dialogs/wordlist.py index 721ab91e..fa2b573c 100644 --- a/novelwriter/dialogs/wordlist.py +++ b/novelwriter/dialogs/wordlist.py @@ -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 diff --git a/novelwriter/error.py b/novelwriter/error.py index 86641011..9026803e 100644 --- a/novelwriter/error.py +++ b/novelwriter/error.py @@ -23,17 +23,17 @@ along with this program. If not, see . """ 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 @@ -125,9 +125,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( "

An unhandled error has been encountered.

" @@ -175,12 +177,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)) diff --git a/novelwriter/extensions/circularprogress.py b/novelwriter/extensions/circularprogress.py index 23ca7d3d..de360d82 100644 --- a/novelwriter/extensions/circularprogress.py +++ b/novelwriter/extensions/circularprogress.py @@ -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 diff --git a/novelwriter/extensions/configlayout.py b/novelwriter/extensions/configlayout.py index cdfcbffe..d73774eb 100644 --- a/novelwriter/extensions/configlayout.py +++ b/novelwriter/extensions/configlayout.py @@ -27,8 +27,8 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/extensions/eventfilters.py b/novelwriter/extensions/eventfilters.py index 922790c3..f2618d34 100644 --- a/novelwriter/extensions/eventfilters.py +++ b/novelwriter/extensions/eventfilters.py @@ -24,8 +24,8 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/extensions/modified.py b/novelwriter/extensions/modified.py index 450647ac..4eed6635 100644 --- a/novelwriter/extensions/modified.py +++ b/novelwriter/extensions/modified.py @@ -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 diff --git a/novelwriter/extensions/novelselector.py b/novelwriter/extensions/novelselector.py index 44e5bf23..340f083c 100644 --- a/novelwriter/extensions/novelselector.py +++ b/novelwriter/extensions/novelselector.py @@ -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 diff --git a/novelwriter/extensions/pagedsidebar.py b/novelwriter/extensions/pagedsidebar.py index 7709509f..da3fca21 100644 --- a/novelwriter/extensions/pagedsidebar.py +++ b/novelwriter/extensions/pagedsidebar.py @@ -25,15 +25,15 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/extensions/simpleprogress.py b/novelwriter/extensions/simpleprogress.py index f350d394..f940c73c 100644 --- a/novelwriter/extensions/simpleprogress.py +++ b/novelwriter/extensions/simpleprogress.py @@ -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 diff --git a/novelwriter/extensions/statusled.py b/novelwriter/extensions/statusled.py index afd641fb..ea34c759 100644 --- a/novelwriter/extensions/statusled.py +++ b/novelwriter/extensions/statusled.py @@ -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 diff --git a/novelwriter/extensions/switch.py b/novelwriter/extensions/switch.py index 1c04a158..302e6e80 100644 --- a/novelwriter/extensions/switch.py +++ b/novelwriter/extensions/switch.py @@ -23,12 +23,12 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/extensions/switchbox.py b/novelwriter/extensions/switchbox.py index 1cff6a9c..42f4ccb2 100644 --- a/novelwriter/extensions/switchbox.py +++ b/novelwriter/extensions/switchbox.py @@ -23,8 +23,8 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/extensions/versioninfo.py b/novelwriter/extensions/versioninfo.py index 6ac78794..9b1177a3 100644 --- a/novelwriter/extensions/versioninfo.py +++ b/novelwriter/extensions/versioninfo.py @@ -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 diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 662b1c35..36349e6b 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -78,9 +78,7 @@ class _SelectAction(Enum): KEEP_POSITION = 2 MOVE_AFTER = 3 -# END Class _SelectAction - - + class GuiDocEditor(QPlainTextEdit): """Gui Widget: Main Document Editor""" @@ -2131,7 +2129,7 @@ class GuiDocEditor(QPlainTextEdit): self._doReplace = False return -# END Class GuiDocEditor + class MetaCompleter(QMenu): @@ -2210,7 +2208,7 @@ class MetaCompleter(QMenu): self.complete.emit(pos, length, value) return -# END Class MetaCompleter + # =============================================================================================== # @@ -2251,7 +2249,7 @@ class BackgroundWordCounter(QRunnable): return -# END Class BackgroundWordCounter + class BackgroundWordCounterSignals(QObject): @@ -2260,7 +2258,7 @@ class BackgroundWordCounterSignals(QObject): """ countsReady = pyqtSignal(int, int, int) -# END Class BackgroundWordCounterSignals + # =============================================================================================== # @@ -2393,7 +2391,7 @@ class GuiDocToolBar(QWidget): return -# END Class GuiDocToolBar + # =============================================================================================== # @@ -2757,7 +2755,7 @@ class GuiDocEditSearch(QFrame): self.searchBox.setPalette(qPalette) return -# END Class GuiDocEditSearch + # =============================================================================================== # @@ -2980,7 +2978,7 @@ class GuiDocEditHeader(QWidget): self.docEditor.requestProjectItemSelected.emit(self._docHandle or "", True) return -# END Class GuiDocEditHeader + # =============================================================================================== # @@ -3172,4 +3170,4 @@ class GuiDocEditFooter(QWidget): self.wordsText.setText(wText) return -# END Class GuiDocEditFooter + diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index 4725b7f3..29fe9504 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -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 diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index 465f1241..89052faf 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -496,8 +496,6 @@ class GuiDocViewer(QTextBrowser): return -# END Class GuiDocViewer - class GuiDocViewHistory: @@ -611,8 +609,6 @@ class GuiDocViewHistory: ) return -# END Class GuiDocViewHistory - # =============================================================================================== # # The Embedded Document Header @@ -835,8 +831,6 @@ class GuiDocViewHeader(QWidget): self.docViewer.requestProjectItemSelected.emit(self._docHandle, True) return -# END Class GuiDocViewHeader - # =============================================================================================== # # The Embedded Document Footer @@ -967,5 +961,3 @@ class GuiDocViewFooter(QWidget): CONFIG.viewSynopsis = state self.docViewer.reloadText() return - -# END Class GuiDocViewFooter diff --git a/novelwriter/gui/docviewerpanel.py b/novelwriter/gui/docviewerpanel.py index b82c5d52..8944711a 100644 --- a/novelwriter/gui/docviewerpanel.py +++ b/novelwriter/gui/docviewerpanel.py @@ -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 diff --git a/novelwriter/gui/editordocument.py b/novelwriter/gui/editordocument.py index 0bbfd1b5..e071658c 100644 --- a/novelwriter/gui/editordocument.py +++ b/novelwriter/gui/editordocument.py @@ -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 diff --git a/novelwriter/gui/itemdetails.py b/novelwriter/gui/itemdetails.py index 486acf29..73542889 100644 --- a/novelwriter/gui/itemdetails.py +++ b/novelwriter/gui/itemdetails.py @@ -295,5 +295,3 @@ class GuiItemDetails(QWidget): self.wCountData.setText(f"{wC:n}") self.pCountData.setText(f"{pC:n}") return - -# END Class GuiItemDetails diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 6ac50c19..6a5b1c8a 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -991,5 +991,3 @@ class GuiMainMenu(QMenuBar): self.aWebsite.triggered.connect(lambda: self._openWebsite(nwConst.URL_WEB)) return - -# END Class GuiMainMenu diff --git a/novelwriter/gui/noveltree.py b/novelwriter/gui/noveltree.py index 68aa8c46..9c7a65c5 100644 --- a/novelwriter/gui/noveltree.py +++ b/novelwriter/gui/noveltree.py @@ -185,8 +185,6 @@ class GuiNovelView(QWidget): self.novelTree.refreshHandle(tHandle) return -# END Class GuiNovelView - class GuiNovelToolBar(QWidget): @@ -349,8 +347,6 @@ class GuiNovelToolBar(QWidget): self.aLastCol[colType] = aLast return -# END Class GuiNovelToolBar - class GuiNovelTree(QTreeWidget): @@ -778,5 +774,3 @@ class GuiNovelTree(QTreeWidget): if tags: lines.append(f"{trConst(nwLabels.KEY_NAME[key])}: {tags}") return lines - -# END Class GuiNovelTree diff --git a/novelwriter/gui/outline.py b/novelwriter/gui/outline.py index ec48267d..d404794a 100644 --- a/novelwriter/gui/outline.py +++ b/novelwriter/gui/outline.py @@ -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"{tag}" for tag in refs.get(key, [])] ) - -# END Class GuiOutlineDetails diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index 34a324da..23806eea 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -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 diff --git a/novelwriter/gui/search.py b/novelwriter/gui/search.py index 17d18f53..f19c419d 100644 --- a/novelwriter/gui/search.py +++ b/novelwriter/gui/search.py @@ -358,5 +358,3 @@ class GuiProjectSearch(QWidget): QApplication.processEvents() return - -# END Class GuiProjectSearch diff --git a/novelwriter/gui/sidebar.py b/novelwriter/gui/sidebar.py index 0620ad2d..6f4669c7 100644 --- a/novelwriter/gui/sidebar.py +++ b/novelwriter/gui/sidebar.py @@ -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 diff --git a/novelwriter/gui/statusbar.py b/novelwriter/gui/statusbar.py index 6b51731a..755ee230 100644 --- a/novelwriter/gui/statusbar.py +++ b/novelwriter/gui/statusbar.py @@ -262,5 +262,3 @@ class GuiMainStatus(QStatusBar): f" \u2013 Peak: {mem[1]:n}" ), 6000) return - -# END Class GuiMainStatus diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index 8256bf5f..170bb452 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -795,8 +795,6 @@ class GuiIcons: return self._noIcon -# END Class GuiIcons - # =============================================================================================== # # Module Functions diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index e35699e8..af9ad75f 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -1399,5 +1399,3 @@ class GuiMain(QMainWindow): )) return None, None return tHandle, sTitle - -# END Class GuiMain diff --git a/novelwriter/shared.py b/novelwriter/shared.py index 6586f676..e703eb2c 100644 --- a/novelwriter/shared.py +++ b/novelwriter/shared.py @@ -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 diff --git a/novelwriter/tools/dictionaries.py b/novelwriter/tools/dictionaries.py index 982ebcc9..9acc57f5 100644 --- a/novelwriter/tools/dictionaries.py +++ b/novelwriter/tools/dictionaries.py @@ -264,5 +264,3 @@ class GuiDictionaries(NNonBlockingDialog): cursor.deleteChar() self.infoBox.setTextCursor(cursor) return - -# END Class GuiDictionaries diff --git a/novelwriter/tools/lipsum.py b/novelwriter/tools/lipsum.py index bce851f5..19b4cac9 100644 --- a/novelwriter/tools/lipsum.py +++ b/novelwriter/tools/lipsum.py @@ -23,8 +23,8 @@ along with this program. If not, see . """ 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 diff --git a/novelwriter/tools/manusbuild.py b/novelwriter/tools/manusbuild.py index 8b6cdb0e..0af6ef52 100644 --- a/novelwriter/tools/manusbuild.py +++ b/novelwriter/tools/manusbuild.py @@ -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 diff --git a/novelwriter/tools/manuscript.py b/novelwriter/tools/manuscript.py index 47bbdc10..6e17bed8 100644 --- a/novelwriter/tools/manuscript.py +++ b/novelwriter/tools/manuscript.py @@ -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 diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py index b3f7d1d5..963da221 100644 --- a/novelwriter/tools/manussettings.py +++ b/novelwriter/tools/manussettings.py @@ -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 diff --git a/novelwriter/tools/noveldetails.py b/novelwriter/tools/noveldetails.py index 91d95651..dc2ac3c2 100644 --- a/novelwriter/tools/noveldetails.py +++ b/novelwriter/tools/noveldetails.py @@ -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 diff --git a/novelwriter/tools/welcome.py b/novelwriter/tools/welcome.py index ce37539b..bb291441 100644 --- a/novelwriter/tools/welcome.py +++ b/novelwriter/tools/welcome.py @@ -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 diff --git a/novelwriter/tools/writingstats.py b/novelwriter/tools/writingstats.py index cc59f9f0..c0b63085 100644 --- a/novelwriter/tools/writingstats.py +++ b/novelwriter/tools/writingstats.py @@ -614,5 +614,3 @@ class GuiWritingStats(NToolDialog): self.labelFilter.setText(formatTime(round(self.timeFilter))) return - -# END Class GuiWritingStats diff --git a/pkgutils.py b/pkgutils.py index 5409007a..8ebd9d4f 100755 --- a/pkgutils.py +++ b/pkgutils.py @@ -1718,5 +1718,3 @@ if __name__ == "__main__": sys.exit(1) else: xdgUninstall() - -# END Main diff --git a/tests/mocked.py b/tests/mocked.py index 5f9fc6a3..545a32ce 100644 --- a/tests/mocked.py +++ b/tests/mocked.py @@ -23,11 +23,11 @@ from __future__ import annotations from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import QWidget - # =========================================================================== # # Mock GUI # =========================================================================== # + class MockGuiMain(QWidget): def __init__(self): @@ -55,8 +55,6 @@ class MockGuiMain(QWidget): def close(self): return "close" -# END Class MockGuiMain - class MockStatusBar: @@ -69,8 +67,6 @@ class MockStatusBar: def updateProjectStatus(self, status): return -# END Class MockStatusBar - class MockTheme: @@ -81,8 +77,6 @@ class MockTheme: def getPixmap(self, *a): return QPixmap() -# END Class MockTheme - class MockApp: @@ -92,8 +86,6 @@ class MockApp: def installTranslator(self, language): return -# END Class MockApp - # =========================================================================== # # Error Functions diff --git a/tests/test_ext/test_ext_modified.py b/tests/test_ext/test_ext_modified.py index 7ea40755..151e3be9 100644 --- a/tests/test_ext/test_ext_modified.py +++ b/tests/test_ext/test_ext_modified.py @@ -22,10 +22,9 @@ from __future__ import annotations import pytest -from tools import SimpleDialog - -from PyQt5.QtGui import QWheelEvent from PyQt5.QtCore import QPoint, QPointF, Qt +from PyQt5.QtGui import QWheelEvent +from tools import SimpleDialog from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NSpinBox @@ -46,8 +45,6 @@ class MockWheelEvent(QWheelEvent): self.ignored = True return -# END Class MockWheelEvent - @pytest.mark.gui def testExtModified_NComboBox(qtbot, monkeypatch): diff --git a/tests/tools.py b/tests/tools.py index 835a61f5..1d62562d 100644 --- a/tests/tools.py +++ b/tests/tools.py @@ -22,8 +22,8 @@ from __future__ import annotations import shutil -from pathlib import Path from datetime import datetime +from pathlib import Path from PyQt5.QtWidgets import QDialog, QVBoxLayout, QWidget @@ -57,8 +57,6 @@ class C: hChapterDoc = "000000000000e" hSceneDoc = "000000000000f" -# END Class C - def cmpFiles( fileOne: str | Path, fileTwo: str | Path, @@ -148,9 +146,9 @@ def buildTestProject(obj: object, projPath: Path) -> None: """Build a standard test project in projPath using the project object as the parent. """ + from novelwriter.core.project import NWProject from novelwriter.enum import nwItemClass from novelwriter.guimain import GuiMain - from novelwriter.core.project import NWProject if isinstance(obj, NWProject): nwGUI = None @@ -220,5 +218,3 @@ class SimpleDialog(QDialog): @property def widget(self) -> QWidget: return self._widget - -# END Class TestDialog From 142d7c4f3a6c02ac300fb9d77b72dfa5e4de7e6c Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 10 May 2024 16:01:44 +0200 Subject: [PATCH 2/6] Remove all END Enum comments --- novelwriter/core/buildsettings.py | 2 -- novelwriter/core/project.py | 2 -- novelwriter/core/storage.py | 4 ---- novelwriter/enum.py | 26 -------------------------- novelwriter/gui/noveltree.py | 2 -- 5 files changed, 36 deletions(-) diff --git a/novelwriter/core/buildsettings.py b/novelwriter/core/buildsettings.py index e37f38c2..13f4cc07 100644 --- a/novelwriter/core/buildsettings.py +++ b/novelwriter/core/buildsettings.py @@ -172,8 +172,6 @@ class FilterMode(Enum): SKIPPED = 4 ROOT = 5 -# END Enum FilterMode - class BuildSettings: """Core: Build Settings Class diff --git a/novelwriter/core/project.py b/novelwriter/core/project.py index 5be1938d..bd269fa4 100644 --- a/novelwriter/core/project.py +++ b/novelwriter/core/project.py @@ -64,8 +64,6 @@ class NWProjectState(Enum): RECOVERY = 2 READY = 3 -# END Enum NWProjectState - class NWProject: diff --git a/novelwriter/core/storage.py b/novelwriter/core/storage.py index 8daccd86..258c379c 100644 --- a/novelwriter/core/storage.py +++ b/novelwriter/core/storage.py @@ -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 diff --git a/novelwriter/enum.py b/novelwriter/enum.py index eae462a0..53155d2a 100644 --- a/novelwriter/enum.py +++ b/novelwriter/enum.py @@ -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 diff --git a/novelwriter/gui/noveltree.py b/novelwriter/gui/noveltree.py index 9c7a65c5..e82f270c 100644 --- a/novelwriter/gui/noveltree.py +++ b/novelwriter/gui/noveltree.py @@ -61,8 +61,6 @@ class NovelTreeColumn(Enum): FOCUS = 2 PLOT = 3 -# END Enum NovelTreeColumn - class GuiNovelView(QWidget): From 3f4538a60e407e88c9632ca45954b20b31430dc4 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 10 May 2024 16:06:23 +0200 Subject: [PATCH 3/6] Remove all END Test comments --- tests/conftest.py | 11 +-- tests/test_base/test_base_common.py | 70 ------------------- tests/test_base/test_base_config.py | 23 ++---- tests/test_base/test_base_error.py | 8 +-- tests/test_base/test_base_init.py | 15 ++-- tests/test_base/test_base_shared.py | 14 ++-- tests/test_core/test_core_buildsettings.py | 23 +++--- tests/test_core/test_core_coretools.py | 20 ------ tests/test_core/test_core_docbuild.py | 12 ---- tests/test_core/test_core_document.py | 14 ++-- tests/test_core/test_core_index.py | 20 ------ tests/test_core/test_core_item.py | 21 ++---- tests/test_core/test_core_options.py | 9 +-- tests/test_core/test_core_project.py | 30 +++----- tests/test_core/test_core_projectxml.py | 12 ---- tests/test_core/test_core_sessions.py | 12 ++-- tests/test_core/test_core_spellcheck.py | 15 ++-- tests/test_core/test_core_status.py | 16 +---- tests/test_core/test_core_storage.py | 25 ++----- tests/test_core/test_core_tohtml.py | 14 ---- tests/test_core/test_core_tokenizer.py | 35 ---------- tests/test_core/test_core_tomd.py | 10 --- tests/test_core/test_core_toodt.py | 25 ------- tests/test_core/test_core_tree.py | 27 ++----- tests/test_dialogs/test_dlg_about.py | 8 +-- tests/test_dialogs/test_dlg_dialogs.py | 8 +-- tests/test_dialogs/test_dlg_docmerge.py | 6 +- tests/test_dialogs/test_dlg_docsplit.py | 6 +- tests/test_dialogs/test_dlg_preferences.py | 8 +-- .../test_dialogs/test_dlg_projectsettings.py | 14 +--- tests/test_dialogs/test_dlg_wordlist.py | 10 ++- tests/test_ext/test_ext_eventfilters.py | 4 +- tests/test_ext/test_ext_modified.py | 9 +-- tests/test_ext/test_ext_versioninfo.py | 10 +-- tests/test_gui/test_gui_doceditor.py | 36 ---------- tests/test_gui/test_gui_docviewer.py | 10 ++- tests/test_gui/test_gui_docviewerpanel.py | 8 +-- tests/test_gui/test_gui_guimain.py | 12 ---- tests/test_gui/test_gui_i18n.py | 13 ++-- tests/test_gui/test_gui_mainmenu.py | 9 +-- tests/test_gui/test_gui_noveltree.py | 12 ++-- tests/test_gui/test_gui_outline.py | 11 ++- tests/test_gui/test_gui_projtree.py | 44 +++--------- tests/test_gui/test_gui_search.py | 2 - tests/test_gui/test_gui_statusbar.py | 7 +- tests/test_gui/test_gui_theme.py | 12 ---- tests/test_text/test_core_counting.py | 6 -- tests/test_tools/test_tools_dictionaries.py | 10 ++- tests/test_tools/test_tools_lipsum.py | 6 +- tests/test_tools/test_tools_manusbuild.py | 10 ++- tests/test_tools/test_tools_manuscript.py | 8 --- tests/test_tools/test_tools_manussettings.py | 12 ---- tests/test_tools/test_tools_noveldetails.py | 2 - tests/test_tools/test_tools_welcome.py | 16 ++--- tests/test_tools/test_tools_writingstats.py | 9 ++- 55 files changed, 148 insertions(+), 671 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9ca87f06..6b95d569 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,18 +20,19 @@ along with this program. If not, see . """ from __future__ import annotations -import sys -import pytest -import shutil import logging +import shutil +import sys from pathlib import Path -from tools import cleanProject -from mocked import MockGuiMain, MockTheme +import pytest from PyQt5.QtWidgets import QMessageBox +from tests.mocked import MockGuiMain, MockTheme +from tests.tools import cleanProject + sys.path.insert(1, str(Path(__file__).parent.parent.absolute())) from novelwriter import CONFIG, SHARED, main # noqa: E402 diff --git a/tests/test_base/test_base_common.py b/tests/test_base/test_base_common.py index dfe5cdb0..0bfa6dad 100644 --- a/tests/test_base/test_base_common.py +++ b/tests/test_base/test_base_common.py @@ -54,8 +54,6 @@ def testBaseCommon_checkStringNone(): assert checkStringNone(1.0, "NotNone") == "NotNone" assert checkStringNone(True, "NotNone") == "NotNone" -# END Test testBaseCommon_checkStringNone - @pytest.mark.base def testBaseCommon_checkString(): @@ -69,8 +67,6 @@ def testBaseCommon_checkString(): assert checkString(1.0, "default") == "default" assert checkString(True, "default") == "default" -# END Test testBaseCommon_checkString - @pytest.mark.base def testBaseCommon_checkInt(): @@ -85,8 +81,6 @@ def testBaseCommon_checkInt(): assert checkInt("1", 3) == 1 assert checkInt("1.0", 3) == 3 -# END Test testBaseCommon_checkInt - @pytest.mark.base def testBaseCommon_checkFloat(): @@ -101,8 +95,6 @@ def testBaseCommon_checkFloat(): assert checkFloat("1", 3.0) == 1.0 assert checkFloat("1.0", 3.0) == 1.0 -# END Test testBaseCommon_checkFloat - @pytest.mark.base def testBaseCommon_checkBool(): @@ -150,8 +142,6 @@ def testBaseCommon_checkBool(): assert checkBool(2.0, True) is True assert checkBool(2.0, False) is False -# END Test testBaseCommon_checkBool - @pytest.mark.base def testBaseCommon_checkUuid(): @@ -163,8 +153,6 @@ def testBaseCommon_checkUuid(): assert checkUuid("e2be99af-f9bf-4403-857a-c3d1ac25abeaa", None) is None # type: ignore assert checkUuid(testUuid, None) == testUuid # type: ignore -# END Test testBaseCommon_checkUuid - @pytest.mark.base def testBaseCommon_checkPath(): @@ -175,8 +163,6 @@ def testBaseCommon_checkPath(): assert checkPath("", None) is None # type: ignore assert checkPath(" ", None) is None # type: ignore -# END Test testBaseCommon_checkPath - @pytest.mark.base def testBaseCommon_isHandle(): @@ -188,8 +174,6 @@ def testBaseCommon_isHandle(): assert isHandle(None) is False assert isHandle("STUFF") is False -# END Test testBaseCommon_isHandle - @pytest.mark.base def testBaseCommon_isTitleTag(): @@ -205,8 +189,6 @@ def testBaseCommon_isTitleTag(): assert isTitleTag(None) is False assert isTitleTag("STUFF") is False -# END Test testBaseCommon_isTitleTag - @pytest.mark.base def testBaseCommon_isItemClass(): @@ -228,8 +210,6 @@ def testBaseCommon_isItemClass(): assert isItemClass(None) is False assert isItemClass("STUFF") is False -# END Test testBaseCommon_isItemClass - @pytest.mark.base def testBaseCommon_isItemType(): @@ -247,8 +227,6 @@ def testBaseCommon_isItemType(): assert isItemType(None) is False # type: ignore assert isItemType("STUFF") is False -# END Test testBaseCommon_isItemType - @pytest.mark.base def testBaseCommon_isItemLayout(): @@ -271,8 +249,6 @@ def testBaseCommon_isItemLayout(): assert isItemLayout(None) is False # type: ignore assert isItemLayout("STUFF") is False -# END Test testBaseCommon_isItemLayout - @pytest.mark.base def testBaseCommon_isListInstance(): @@ -289,8 +265,6 @@ def testBaseCommon_isListInstance(): assert isListInstance([1], str) is False assert isListInstance(["stuff"], int) is False -# END Test testBaseCommon_isListInstance - @pytest.mark.base def testBaseCommon_hexToInt(): @@ -302,8 +276,6 @@ def testBaseCommon_hexToInt(): assert hexToInt("0xffffq") == 0 assert hexToInt("0xffffq", 12) == 12 -# END Test testBaseCommon_hexToInt - @pytest.mark.base def testBaseCommon_minmax(): @@ -311,8 +283,6 @@ def testBaseCommon_minmax(): for i in range(-5, 15): assert 0 <= minmax(i, 0, 10) <= 10 -# END Test testBaseCommon_minmax - @pytest.mark.base def testBaseCommon_checkIntTuple(): @@ -320,8 +290,6 @@ def testBaseCommon_checkIntTuple(): assert checkIntTuple(0, (0, 1, 2), 3) == 0 assert checkIntTuple(5, (0, 1, 2), 3) == 3 -# END Test testBaseCommon_checkIntTuple - @pytest.mark.base def testBaseCommon_formatTimeStamp(): @@ -330,8 +298,6 @@ def testBaseCommon_formatTimeStamp(): assert formatTimeStamp(tTime, False) == "1970-01-01 00:00:00" assert formatTimeStamp(tTime, True) == "1970-01-01 00.00.00" -# END Test testBaseCommon_formatTimeStamp - @pytest.mark.base def testBaseCommon_formatTime(): @@ -352,8 +318,6 @@ def testBaseCommon_formatTime(): assert formatTime(86400) == "1-00:00:00" assert formatTime(360000) == "4-04:00:00" -# END Test testBaseCommon_formatTime - @pytest.mark.base def testBaseCommon_formatVersion(): @@ -363,8 +327,6 @@ def testBaseCommon_formatVersion(): assert formatVersion("1.2b2") == "1.2 Beta 2" assert formatVersion("1.2rc3") == "1.2 RC 3" -# END Test testBaseCommon_formatVersion - @pytest.mark.base def testBaseCommon_formatFileFilter(): @@ -375,8 +337,6 @@ def testBaseCommon_formatFileFilter(): "Stuff (*.stuff);;Text files (*.txt);;All files (*)" ) -# END Test testBaseCommon_formatFileFilter - @pytest.mark.base def testBaseCommon_simplified(): @@ -385,8 +345,6 @@ def testBaseCommon_simplified(): assert simplified(" Hello World ") == "Hello World" assert simplified("\tHello\n\r\tWorld") == "Hello World" -# END Test testBaseCommon_simplified - @pytest.mark.base def testBaseCommon_elide(): @@ -405,8 +363,6 @@ def testBaseCommon_elide(): assert elide("Hello World!", 1) == " ..." assert elide("Hello World!", 0) == " ..." -# END Test testBaseCommon_elide - @pytest.mark.base def testBaseCommon_yesNo(): @@ -432,8 +388,6 @@ def testBaseCommon_yesNo(): assert yesNo(1.0) == "yes" # type: ignore assert yesNo(2.0) == "yes" # type: ignore -# END Test testBaseCommon_yesNo - @pytest.mark.base def testBaseCommon_formatInt(): @@ -455,8 +409,6 @@ def testBaseCommon_formatInt(): assert formatInt(None) == "ERR" # type: ignore assert formatInt("42") == "ERR" # type: ignore -# END Test testBaseCommon_formatInt - @pytest.mark.base def testBaseCommon_transferCase(): @@ -469,8 +421,6 @@ def testBaseCommon_transferCase(): assert transferCase("SOURCE", "target") == "TARGET" assert transferCase("source", "TARGET") == "target" -# END Test testBaseCommon_transferCase - @pytest.mark.base def testBaseCommon_fuzzyTime(): @@ -504,8 +454,6 @@ def testBaseCommon_fuzzyTime(): assert fuzzyTime(47336399) == "a year ago" assert fuzzyTime(47336400) == "2 years ago" -# END Test testBaseCommon_fuzzyTime - @pytest.mark.core def testBaseCommon_numberToRoman(): @@ -531,8 +479,6 @@ def testBaseCommon_numberToRoman(): assert numberToRoman(2010, False) == "MMX" assert numberToRoman(999, True) == "cmxcix" -# END Test testBaseCommon_numberToRoman - @pytest.mark.base def testBaseCommon_cssCol(): @@ -540,8 +486,6 @@ def testBaseCommon_cssCol(): assert cssCol(QColor(0, 0, 0, 0)) == "rgba(0, 0, 0, 0)" assert cssCol(QColor(10, 20, 30, 40)) == "rgba(10, 20, 30, 40)" -# END Test testBaseCommon_cssCol - @pytest.mark.base def testBaseCommon_jsonEncode(): @@ -623,8 +567,6 @@ def testBaseCommon_jsonEncode(): '}' ) -# END Test testBaseCommon_jsonEncode - @pytest.mark.base def testBaseCommon_xmlIndent(): @@ -650,8 +592,6 @@ def testBaseCommon_xmlIndent(): xmlIndent(data) # type: ignore assert data == "foobar" -# END Test testBaseCommon_xmlIndent - @pytest.mark.base def testBaseCommon_readTextFile(monkeypatch, fncPath, ipsumText): @@ -667,8 +607,6 @@ def testBaseCommon_readTextFile(monkeypatch, fncPath, ipsumText): mp.setattr("pathlib.Path.read_text", causeOSError) assert readTextFile(testFile) == "" -# END Test testBaseCommon_readTextFile - @pytest.mark.base def testBaseCommon_makeFileNameSafe(): @@ -680,8 +618,6 @@ def testBaseCommon_makeFileNameSafe(): assert makeFileNameSafe("æøå") == "æøå" assert makeFileNameSafe("Stuff œfi2⁵") == "Stuff œfi25" -# END Test testBaseCommon_makeFileNameSafe - @pytest.mark.base def testBaseCommon_getFileSize(fncPath): @@ -693,8 +629,6 @@ def testBaseCommon_getFileSize(fncPath): assert getFileSize(fncPath / "one.txt") == 6 assert getFileSize(fncPath / "two.txt") == 0 -# END Test testBaseCommon_getFileSize - @pytest.mark.base def testBaseCommon_openExternalPath(monkeypatch, tstPaths): @@ -711,8 +645,6 @@ def testBaseCommon_openExternalPath(monkeypatch, tstPaths): assert openExternalPath(tstPaths.tmpDir) is True assert lastUrl.startswith("file://") -# END Test testBaseCommon_openExternalPath - @pytest.mark.base def testBaseCommon_NWConfigParser(fncPath): @@ -801,5 +733,3 @@ def testBaseCommon_NWConfigParser(fncPath): assert cfgParser.rdIntList("nope", "list2", [1]) == [1] assert cfgParser.rdIntList("main", "blabla", [1]) == [1] - -# END Test testBaseCommon_NWConfigParser diff --git a/tests/test_base/test_base_config.py b/tests/test_base/test_base_config.py index 7c9cc88d..8af01057 100644 --- a/tests/test_base/test_base_config.py +++ b/tests/test_base/test_base_config.py @@ -21,18 +21,19 @@ along with this program. If not, see . from __future__ import annotations import sys -import pytest -from shutil import copyfile from pathlib import Path +from shutil import copyfile -from mocked import causeOSError, MockApp -from tools import cmpFiles, writeFile +import pytest from novelwriter import CONFIG from novelwriter.config import Config, RecentProjects from novelwriter.constants import nwFiles +from tests.mocked import MockApp, causeOSError +from tests.tools import cmpFiles, writeFile + @pytest.mark.base def testBaseConfig_Constructor(monkeypatch): @@ -88,8 +89,6 @@ def testBaseConfig_Constructor(monkeypatch): tstConf = Config() assert tstConf._appPath == tstConf._appRoot -# END Test testBaseConfig_Constructor - @pytest.mark.base def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths): @@ -153,8 +152,6 @@ def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths): assert newConf.doReplaceDQuote is False assert newConf.doReplaceSQuote is False -# END Test testBaseConfig_InitLoadSave - @pytest.mark.base def testBaseConfig_Localisation(fncPath, tstPaths): @@ -191,8 +188,6 @@ def testBaseConfig_Localisation(fncPath, tstPaths): languages = tstConf.listLanguages(tstConf.LANG_NW) assert languages == [("en_GB", "British English"), ("fr", "Français")] -# END Test testBaseConfig_Localisation - @pytest.mark.base def testBaseConfig_Methods(fncPath): @@ -237,8 +232,6 @@ def testBaseConfig_Methods(fncPath): # Recent Projects assert isinstance(tstConf.recentProjects, RecentProjects) -# END Test testBaseConfig_Methods - @pytest.mark.base def testBaseConfig_SettersGetters(fncPath): @@ -361,8 +354,6 @@ def testBaseConfig_SettersGetters(fncPath): assert tstConf.getTextMargin() == 80 assert tstConf.getTabWidth() == 80 -# END Test testBaseConfig_SettersGetters - @pytest.mark.base def testBaseConfig_Internal(monkeypatch, fncPath): @@ -383,8 +374,6 @@ def testBaseConfig_Internal(monkeypatch, fncPath): tstConf._checkOptionalPackages() assert tstConf.hasEnchant is False -# END Test testBaseConfig_Internal - @pytest.mark.base def testBaseConfig_RecentCache(monkeypatch, tstPaths): @@ -446,5 +435,3 @@ def testBaseConfig_RecentCache(monkeypatch, tstPaths): assert recent.listEntries() == [ (str(pathOne), "Proj One", 100, 1600002000), ] - -# END Test testBaseConfig_RecentCache diff --git a/tests/test_base/test_base_error.py b/tests/test_base/test_base_error.py index 1f8c2205..4d9990f2 100644 --- a/tests/test_base/test_base_error.py +++ b/tests/test_base/test_base_error.py @@ -22,10 +22,10 @@ from __future__ import annotations import pytest -from mocked import causeException - from novelwriter.error import NWErrorMessage, exceptionHandler +from tests.mocked import causeException + @pytest.mark.base def testBaseError_Dialog(qtbot, monkeypatch, nwGUI): @@ -61,8 +61,6 @@ def testBaseError_Dialog(qtbot, monkeypatch, nwGUI): nwErr.close() nwGUI.closeMain() -# END Test testBaseError_Dialog - @pytest.mark.base def testBaseError_Handler(qtbot, monkeypatch, nwGUI): @@ -98,5 +96,3 @@ def testBaseError_Handler(qtbot, monkeypatch, nwGUI): exceptionHandler(Exception, "Error Message", None) # type: ignore nwGUI.closeMain() - -# END Test testBaseError_Handler diff --git a/tests/test_base/test_base_init.py b/tests/test_base/test_base_init.py index e828ce76..2b7ebc47 100644 --- a/tests/test_base/test_base_init.py +++ b/tests/test_base/test_base_init.py @@ -20,13 +20,14 @@ along with this program. If not, see . """ from __future__ import annotations -import sys -import pytest import logging +import sys -from mocked import MockGuiMain +import pytest -from novelwriter import CONFIG, main, logger +from novelwriter import CONFIG, logger, main + +from tests.mocked import MockGuiMain @pytest.mark.base @@ -71,8 +72,6 @@ def testBaseInit_Launch(caplog, monkeypatch, fncPath): main([f"--config={fncPath}", f"--data={fncPath}"]) assert ex.value.code == 0 -# END Test testBaseInit_Launch - @pytest.mark.base def testBaseInit_Options(monkeypatch, fncPath): @@ -136,8 +135,6 @@ def testBaseInit_Options(monkeypatch, fncPath): ) assert nwGUI.closeMain() == "closeMain" -# END Test testBaseInit_Options - @pytest.mark.base def testBaseInit_Imports(caplog, monkeypatch, fncPath): @@ -164,5 +161,3 @@ def testBaseInit_Imports(caplog, monkeypatch, fncPath): assert "At least Python" in caplog.messages[0] assert "At least Qt5" in caplog.messages[1] assert "At least PyQt5" in caplog.messages[2] - -# END Test testBaseInit_Imports diff --git a/tests/test_base/test_base_shared.py b/tests/test_base/test_base_shared.py index 6cdb8dfe..6676a465 100644 --- a/tests/test_base/test_base_shared.py +++ b/tests/test_base/test_base_shared.py @@ -22,13 +22,13 @@ from __future__ import annotations import pytest -from tools import buildTestProject -from mocked import MockGuiMain, MockTheme - from PyQt5.QtWidgets import QFileDialog, QMessageBox, QWidget -from novelwriter.shared import SharedData from novelwriter.core.project import NWProject +from novelwriter.shared import SharedData + +from tests.mocked import MockGuiMain, MockTheme +from tests.tools import buildTestProject @pytest.mark.base @@ -62,8 +62,6 @@ def testBaseSharedData_Init(): assert shared.projectIdleTime == 0.0 assert shared.projectLock is None -# END Test testBaseSharedData_Init - @pytest.mark.base def testBaseSharedData_Projects(monkeypatch, caplog, fncPath): @@ -123,8 +121,6 @@ def testBaseSharedData_Projects(monkeypatch, caplog, fncPath): mp.setattr(QFileDialog, "getOpenFileName", lambda *a, **k: (a[2], "")) assert shared.getProjectPath(QWidget(), fncPath, allowZip=True) == fncPath -# END Test testBaseSharedData_Projects - @pytest.mark.base def testBaseSharedData_Alerts(qtbot, monkeypatch, caplog): @@ -171,5 +167,3 @@ def testBaseSharedData_Alerts(qtbot, monkeypatch, caplog): # Question box assert shared.question("Why?") is True assert shared.lastAlert == "Why?" - -# END Test testBaseSharedData_Alerts diff --git a/tests/test_core/test_core_buildsettings.py b/tests/test_core/test_core_buildsettings.py index 10c63253..df891745 100644 --- a/tests/test_core/test_core_buildsettings.py +++ b/tests/test_core/test_core_buildsettings.py @@ -21,20 +21,21 @@ along with this program. If not, see . from __future__ import annotations import json -import uuid -import pytest import shutil +import uuid from pathlib import Path -from novelwriter import CONFIG -from tools import C, buildTestProject -from mocked import causeOSError +import pytest -from novelwriter.enum import nwBuildFmt, nwItemClass +from novelwriter import CONFIG from novelwriter.constants import nwFiles -from novelwriter.core.project import NWProject from novelwriter.core.buildsettings import BuildCollection, BuildSettings, FilterMode +from novelwriter.core.project import NWProject +from novelwriter.enum import nwBuildFmt, nwItemClass + +from tests.mocked import causeOSError +from tests.tools import C, buildTestProject def isUUID(value): @@ -140,8 +141,6 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path): assert more["build"] == "Build Name" assert more["format"] == nwBuildFmt.HTML.name -# END Test testCoreBuildSettings_ClassAttributes - @pytest.mark.core def testCoreBuildSettings_BuildValues(): @@ -216,8 +215,6 @@ def testCoreBuildSettings_BuildValues(): assert more["settings"][boolSetting] is True assert more["settings"][floatSetting] == 2.5 -# END Test testCoreBuildSettings_BuildValues - @pytest.mark.core def testCoreBuildSettings_Filters(mockGUI, fncPath: Path, mockRnd): @@ -364,8 +361,6 @@ def testCoreBuildSettings_Filters(mockGUI, fncPath: Path, mockRnd): # No valid project provided assert build.buildItemFilter(None) == {} # type: ignore -# END Test testCoreBuildSettings_Filters - @pytest.mark.core def testCoreBuildSettings_Collection(monkeypatch, mockGUI, fncPath: Path, mockRnd): @@ -471,5 +466,3 @@ def testCoreBuildSettings_Collection(monkeypatch, mockGUI, fncPath: Path, mockRn ] assert another.lastBuild == buildIDOne assert another.defaultBuild == buildIDTwo - -# END Test testCoreBuildSettings_Collection diff --git a/tests/test_core/test_core_coretools.py b/tests/test_core/test_core_coretools.py index fbceb229..a0aa86e0 100644 --- a/tests/test_core/test_core_coretools.py +++ b/tests/test_core/test_core_coretools.py @@ -125,8 +125,6 @@ def testCoreTools_DocMerger(monkeypatch, mockGUI, fncPath, tstPaths, mockRnd, ip # Just for debugging docMerger.writeTargetDoc() -# END Test testCoreTools_DocMerger - @pytest.mark.core def testCoreTools_DocSplitter(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText): @@ -264,8 +262,6 @@ def testCoreTools_DocSplitter(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText) project.saveProject() -# END Test testCoreTools_DocSplitter - @pytest.mark.core def testCoreTools_DocDuplicator(mockGUI, fncPath, tstPaths, mockRnd): @@ -401,8 +397,6 @@ def testCoreTools_DocDuplicator(mockGUI, fncPath, tstPaths, mockRnd): copyfile(projFile, testFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) -# END Test testCoreTools_DocDuplicator - @pytest.mark.core def testCoreTools_DocSearch(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText): @@ -479,8 +473,6 @@ def testCoreTools_DocSearch(monkeypatch, mockGUI, fncPath, mockRnd, ipsumText): assert pruneResult(search.iterSearch(project, "Lorem"), 2) == [(15, 5, "Lorem")] search.setCaseSensitive(False) -# END Test testCoreTools_DocSearch - @pytest.mark.core def testCoreTools_ProjectBuilderWrapper(monkeypatch, caplog, fncPath, mockGUI): @@ -509,8 +501,6 @@ def testCoreTools_ProjectBuilderWrapper(monkeypatch, caplog, fncPath, mockGUI): assert builder.buildProject({"path": fncPath}) is False assert "The target folder is not empty." in caplog.text -# END Test testCoreTools_ProjectBuilderWrapper - @pytest.mark.core def testCoreTools_ProjectBuilderA(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd): @@ -544,8 +534,6 @@ def testCoreTools_ProjectBuilderA(monkeypatch, fncPath, tstPaths, mockGUI, mockR copyfile(projFile, testFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) -# END Test testCoreTools_ProjectBuilderA - @pytest.mark.core def testCoreTools_ProjectBuilderB(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd): @@ -579,8 +567,6 @@ def testCoreTools_ProjectBuilderB(monkeypatch, fncPath, tstPaths, mockGUI, mockR copyfile(projFile, testFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) -# END Test testCoreTools_ProjectBuilderB - @pytest.mark.core def testCoreTools_ProjectBuilderCopyPlain(monkeypatch, caplog, mockGUI, prjLipsum, fncPath): @@ -645,8 +631,6 @@ def testCoreTools_ProjectBuilderCopyPlain(monkeypatch, caplog, mockGUI, prjLipsu assert dstProject.data.autoCount < 5 assert dstProject.data.editTime < 10 -# END Test testCoreTools_ProjectBuilderCopyPlain - @pytest.mark.core def testCoreTools_ProjectBuilderCopyZipped(monkeypatch, caplog, mockGUI, fncPath, mockRnd): @@ -723,8 +707,6 @@ def testCoreTools_ProjectBuilderCopyZipped(monkeypatch, caplog, mockGUI, fncPath assert dstProject.data.autoCount < 5 assert dstProject.data.editTime < 10 -# END Test testCoreTools_ProjectBuilderCopyZipped - @pytest.mark.core def testCoreTools_ProjectBuilderSample(monkeypatch, mockGUI, fncPath, tstPaths): @@ -769,5 +751,3 @@ def testCoreTools_ProjectBuilderSample(monkeypatch, mockGUI, fncPath, tstPaths): # Can't create to the same target again assert builder.buildProject(data) is False dstSample.unlink() - -# END Test testCoreTools_ProjectBuilderSample diff --git a/tests/test_core/test_core_docbuild.py b/tests/test_core/test_core_docbuild.py index 928d5d73..6054b272 100644 --- a/tests/test_core/test_core_docbuild.py +++ b/tests/test_core/test_core_docbuild.py @@ -182,8 +182,6 @@ def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstP "Build: Failed to build '04468803b92e1'", ] -# END Test testCoreDocBuild_OpenDocument - @pytest.mark.core def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): @@ -252,8 +250,6 @@ def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): assert docBuild.error == "OSError: Mock OSError" assert not docFile.is_file() -# END Test testCoreDocBuild_HTML - @pytest.mark.core def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): @@ -322,8 +318,6 @@ def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths assert docBuild.error == "OSError: Mock OSError" assert not docFile.is_file() -# END Test testCoreDocBuild_Markdown - @pytest.mark.core def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): @@ -392,8 +386,6 @@ def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths): assert docBuild.error == "OSError: Mock OSError" assert not docFile.is_file() -# END Test testCoreDocBuild_NWD - @pytest.mark.core def testCoreDocBuild_Custom(mockGUI, fncPath: Path): @@ -457,8 +449,6 @@ def testCoreDocBuild_Custom(mockGUI, fncPath: Path): ) docFile.unlink() -# END Test testCoreDocBuild_Custom - @pytest.mark.core def testCoreDocBuild_IterBuild(mockGUI, fncPath: Path, mockRnd): @@ -600,5 +590,3 @@ def testCoreDocBuild_IterBuild(mockGUI, fncPath: Path, mockRnd): assert "meta" in data assert "text" in data docFile.unlink() - -# END Test testCoreDocBuild_IterBuild diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index 3dbdd454..7382995f 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -22,12 +22,12 @@ from __future__ import annotations import pytest -from tools import C, MOCK_TIME, buildTestProject, readFile, writeFile -from mocked import causeOSError - -from novelwriter.enum import nwItemClass, nwItemLayout -from novelwriter.core.project import NWProject from novelwriter.core.document import NWDocument +from novelwriter.core.project import NWProject +from novelwriter.enum import nwItemClass, nwItemLayout + +from tests.mocked import causeOSError +from tests.tools import MOCK_TIME, C, buildTestProject, readFile, writeFile @pytest.mark.core @@ -189,8 +189,6 @@ def testCoreDocument_LoadSave(monkeypatch, mockGUI, fncPath, mockRnd): assert doc.deleteDocument() is True assert not docPath.exists() -# END Test testCoreDocument_Load - @pytest.mark.core def testCoreDocument_Methods(monkeypatch, mockGUI, fncPath, mockRnd): @@ -234,5 +232,3 @@ def testCoreDocument_Methods(monkeypatch, mockGUI, fncPath, mockRnd): ) assert doc.readDocument() == "### Test File\n\nText ...\n\n" - -# END Test testCoreDocument_Methods diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 71f4bc5d..176174bd 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -156,8 +156,6 @@ def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, mockGUI, tstPaths): # Regression test for issue #1718 project.closeProject() -# END Test testCoreIndex_LoadSave - @pytest.mark.core def testCoreIndex_ScanThis(mockGUI): @@ -214,8 +212,6 @@ def testCoreIndex_ScanThis(mockGUI): project.closeProject() -# END Test testCoreIndex_ScanThis - @pytest.mark.core def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd): @@ -305,8 +301,6 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreIndex_CheckThese - @pytest.mark.core def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd): @@ -550,8 +544,6 @@ def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreIndex_ScanText - @pytest.mark.core def testCoreIndex_CommentKeys(monkeypatch, mockGUI, fncPath, mockRnd): @@ -589,8 +581,6 @@ def testCoreIndex_CommentKeys(monkeypatch, mockGUI, fncPath, mockRnd): # Check invalid comment style assert index.newCommentKey(C.hSceneDoc, None) == "err" # type: ignore -# END Test testCoreIndex_CommentKeys - @pytest.mark.core def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd): @@ -931,8 +921,6 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd): assert project.saveProject() is True project.closeProject() -# END Test testCoreIndex_ExtractData - @pytest.mark.core def testCoreIndex_TagsIndex(): @@ -1119,8 +1107,6 @@ def testCoreIndex_TagsIndex(): } }) -# END Test testCoreIndex_TagsIndex - @pytest.mark.core def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd): @@ -1391,8 +1377,6 @@ def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd): } }) -# END Test testCoreIndex_ItemIndex - @pytest.mark.core def testCoreIndex_checkModKey(): @@ -1425,8 +1409,6 @@ def testCoreIndex_checkModKey(): assert _checkModKey("note", "a1.2") is False assert _checkModKey("note", "a1_2") is True -# END Test testCoreIndex_checkModKey - @pytest.mark.core def testCoreIndex_processComment(): @@ -1477,5 +1459,3 @@ def testCoreIndex_processComment(): assert processComment("% note.term: Hi") == (nwComment.NOTE, "term", "Hi", 7, 12) assert processComment("% note. term : Hi") == (nwComment.PLAIN, "", "note. term : Hi", 0, 0) assert processComment("% note . term : Hi") == (nwComment.PLAIN, "", "note . term : Hi", 0, 0) - -# END Test testCoreIndex_processComment diff --git a/tests/test_core/test_core_item.py b/tests/test_core/test_core_item.py index 65cf7b5f..3e0fd0bb 100644 --- a/tests/test_core/test_core_item.py +++ b/tests/test_core/test_core_item.py @@ -21,15 +21,16 @@ along with this program. If not, see . from __future__ import annotations import copy + import pytest from PyQt5.QtGui import QIcon -from tools import C, buildTestProject - -from novelwriter.enum import nwItemClass, nwItemType, nwItemLayout from novelwriter.core.item import NWItem from novelwriter.core.project import NWProject +from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType + +from tests.tools import C, buildTestProject @pytest.mark.core @@ -180,8 +181,6 @@ def testCoreItem_Setters(mockGUI, mockRnd, fncPath): item.saveInitialCount() assert item.initCount == 234 -# END Test testCoreItem_Setters - @pytest.mark.core def testCoreItem_Methods(mockGUI, mockRnd, fncPath): @@ -326,8 +325,6 @@ def testCoreItem_Methods(mockGUI, mockRnd, fncPath): del scItem assert cpItem.pack() == cpData -# END Test testCoreItem_Methods - @pytest.mark.core def testCoreItem_TypeSetter(mockGUI): @@ -355,8 +352,6 @@ def testCoreItem_TypeSetter(mockGUI): item.setType(nwItemType.ROOT) assert item.itemType == nwItemType.ROOT -# END Test testCoreItem_TypeSetter - @pytest.mark.core def testCoreItem_ClassSetter(mockGUI): @@ -461,8 +456,6 @@ def testCoreItem_ClassSetter(mockGUI): item.setClass(nwItemClass.NOVEL) assert item.itemClass == nwItemClass.NOVEL -# END Test testCoreItem_ClassSetter - @pytest.mark.core def testCoreItem_LayoutSetter(mockGUI): @@ -490,8 +483,6 @@ def testCoreItem_LayoutSetter(mockGUI): item.setLayout(nwItemLayout.NOTE) assert item.itemLayout == nwItemLayout.NOTE -# END Test testCoreItem_LayoutSetter - @pytest.mark.core def testCoreItem_ClassDefaults(mockGUI): @@ -546,8 +537,6 @@ def testCoreItem_ClassDefaults(mockGUI): assert item.itemStatus is not None assert item.itemImport is not None -# END Test testCoreItem_ClassDefaults - @pytest.mark.core def testCoreItem_PackUnpack(mockGUI, caplog, mockRnd): @@ -761,5 +750,3 @@ def testCoreItem_PackUnpack(mockGUI, caplog, mockRnd): "import": "i000001", } } - -# END Test testCoreItem_PackUnpack diff --git a/tests/test_core/test_core_options.py b/tests/test_core/test_core_options.py index fd291d08..0852cc5f 100644 --- a/tests/test_core/test_core_options.py +++ b/tests/test_core/test_core_options.py @@ -21,15 +21,16 @@ along with this program. If not, see . from __future__ import annotations import json -import pytest -from mocked import causeOSError +import pytest from novelwriter.constants import nwFiles from novelwriter.core.options import OptionState from novelwriter.core.project import NWProject from novelwriter.gui.noveltree import NovelTreeColumn +from tests.mocked import causeOSError + @pytest.mark.core def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath): @@ -102,8 +103,6 @@ def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath): }, } -# END Test testCoreOptions_LoadSave - @pytest.mark.core def testCoreOptions_SetGet(mockGUI): @@ -151,5 +150,3 @@ def testCoreOptions_SetGet(mockGUI): assert options.getFloat("SomeGroup", "mockItem", None) is None # type: ignore assert options.getBool("SomeGroup", "mockItem", None) is None # type: ignore assert options.getEnum("SomeGroup", "mockItem", NovelTreeColumn, None) is None # type: ignore - -# END Test testCoreOptions_SetGet diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index 3304fc14..ba617017 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -20,25 +20,25 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - from shutil import copyfile from zipfile import ZipFile -from mocked import causeOSError -from tools import C, cmpFiles, buildTestProject, XML_IGNORE +import pytest from PyQt5.QtWidgets import QMessageBox from novelwriter import CONFIG, SHARED -from novelwriter.enum import nwItemClass from novelwriter.constants import nwFiles -from novelwriter.core.item import NWItem -from novelwriter.core.tree import NWTree from novelwriter.core.index import NWIndex -from novelwriter.core.project import NWProject, NWProjectState +from novelwriter.core.item import NWItem from novelwriter.core.options import OptionState +from novelwriter.core.project import NWProject, NWProjectState from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState +from novelwriter.core.tree import NWTree +from novelwriter.enum import nwItemClass + +from tests.mocked import causeOSError +from tests.tools import XML_IGNORE, C, buildTestProject, cmpFiles @pytest.mark.core @@ -88,8 +88,6 @@ def testCoreProject_NewRoot(fncPath, tstPaths, mockGUI, mockRnd): assert "0000000000016" not in project.tree assert "0000000000017" not in project.tree -# END Test testCoreProject_NewRoot - @pytest.mark.core def testCoreProject_NewFileFolder(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd): @@ -192,8 +190,6 @@ def testCoreProject_NewFileFolder(monkeypatch, fncPath, tstPaths, mockGUI, mockR project.closeProject() -# END Test testCoreProject_NewFileFolder - @pytest.mark.core def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd): @@ -302,8 +298,6 @@ def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreProject_Open - @pytest.mark.core def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath): @@ -331,8 +325,6 @@ def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath): assert project.saveProject(autoSave=True) is True project.closeProject() -# END Test testCoreProject_Save - @pytest.mark.core def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd): @@ -397,8 +389,6 @@ def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd): ] assert nItem.itemParent is None -# END Test testCoreProject_AccessItems - @pytest.mark.core def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd): @@ -507,8 +497,6 @@ def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd): project.setTreeOrder(oldOrder) assert project.tree.handles() == oldOrder -# END Test testCoreProject_Methods - @pytest.mark.core def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths): @@ -566,5 +554,3 @@ def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths): fncPath / "nwProject.nwx", tstPaths.tmpDir / "extract" / "nwProject.nwx" ) - -# END Test testCoreProject_Backup diff --git a/tests/test_core/test_core_projectxml.py b/tests/test_core/test_core_projectxml.py index de277dfa..1119d338 100644 --- a/tests/test_core/test_core_projectxml.py +++ b/tests/test_core/test_core_projectxml.py @@ -246,8 +246,6 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, mockGUI, tstPaths, fncPath): copyfile(outFile, tstFile) assert cmpFiles(tstFile, refFile) -# END Test testCoreProjectXML_ReadCurrent - @pytest.mark.core def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockGUI, mockRnd): @@ -393,8 +391,6 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy10 - @pytest.mark.core def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockGUI, mockRnd): @@ -540,8 +536,6 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy11 - @pytest.mark.core def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockGUI, mockRnd): @@ -690,8 +684,6 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy12 - @pytest.mark.core def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockGUI, mockRnd): @@ -840,8 +832,6 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockGUI, mockRnd): copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) -# END Test testCoreProjectXML_ReadLegacy13 - @pytest.mark.core def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockGUI, mockRnd): @@ -990,5 +980,3 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockGUI, mockRnd): compFile = tstPaths.refDir / "projectXML_ReadLegacy14.nwx" copyfile(outFile, testFile) assert cmpFiles(testFile, compFile) - -# END Test testCoreProjectXML_ReadLegacy14 diff --git a/tests/test_core/test_core_sessions.py b/tests/test_core/test_core_sessions.py index 2ba49959..e9c8fcd5 100644 --- a/tests/test_core/test_core_sessions.py +++ b/tests/test_core/test_core_sessions.py @@ -20,18 +20,18 @@ along with this program. If not, see . """ from __future__ import annotations -import pytest - -from time import sleep from pathlib import Path +from time import sleep -from tools import buildTestProject -from mocked import causeOSError +import pytest from novelwriter.constants import nwFiles from novelwriter.core.project import NWProject from novelwriter.core.sessions import NWSessionLog +from tests.mocked import causeOSError +from tests.tools import buildTestProject + @pytest.mark.core def testCoreSessions_Main(monkeypatch, mockGUI, fncPath): @@ -111,5 +111,3 @@ def testCoreSessions_Main(monkeypatch, mockGUI, fncPath): with monkeypatch.context() as mp: mp.setattr("novelwriter.core.storage.NWStorage.getMetaFile", lambda *a: None) assert len(list(sessLog.iterRecords())) == 0 - -# END Test testCoreSessions_Main diff --git a/tests/test_core/test_core_spellcheck.py b/tests/test_core/test_core_spellcheck.py index 401df109..b3ea1dd1 100644 --- a/tests/test_core/test_core_spellcheck.py +++ b/tests/test_core/test_core_spellcheck.py @@ -21,18 +21,19 @@ along with this program. If not, see . from __future__ import annotations import sys -import pytest -import enchant from pathlib import Path -from tools import buildTestProject -from mocked import causeOSError +import enchant +import pytest from novelwriter.constants import nwFiles from novelwriter.core.project import NWProject from novelwriter.core.spellcheck import FakeEnchant, NWSpellEnchant, UserDictionary +from tests.mocked import causeOSError +from tests.tools import buildTestProject + @pytest.mark.core def testCoreSpell_UserDictionary(monkeypatch, mockGUI, fncPath): @@ -102,8 +103,6 @@ def testCoreSpell_UserDictionary(monkeypatch, mockGUI, fncPath): userDict.load() assert sorted(userDict) == ["bar", "foo"] -# END Test testCoreSpell_UserDictionary - @pytest.mark.core def testCoreSpell_FakeEnchant(monkeypatch, mockGUI, fncPath): @@ -137,8 +136,6 @@ def testCoreSpell_FakeEnchant(monkeypatch, mockGUI, fncPath): assert fkChk.suggest("whatchamajig") == [] assert fkChk.add_to_session("whatchamajig") is None -# END Test testCoreSpell_FakeEnchant - @pytest.mark.core def testCoreSpell_Enchant(monkeypatch, mockGUI, fncPath): @@ -189,5 +186,3 @@ def testCoreSpell_Enchant(monkeypatch, mockGUI, fncPath): mp.setattr("enchant.Broker.request_dict", lambda *a: None) spChk.setLanguage("en_US") assert isinstance(spChk._enchant, FakeEnchant) - -# END Test testCoreSpell_Enchant diff --git a/tests/test_core/test_core_status.py b/tests/test_core/test_core_status.py index 7c6b2fc4..e3869043 100644 --- a/tests/test_core/test_core_status.py +++ b/tests/test_core/test_core_status.py @@ -22,13 +22,13 @@ from __future__ import annotations import pytest -from tools import C - from PyQt5.QtGui import QColor, QIcon from novelwriter.core.status import NWStatus, StatusEntry, _ShapeCache from novelwriter.enum import nwStatusShape +from tests.tools import C + statusKeys = [C.sNew, C.sNote, C.sDraft, C.sFinished] importKeys = [C.iNew, C.iMinor, C.iMajor, C.iMain] @@ -59,8 +59,6 @@ def testCoreStatus_StatusEntry(): assert other.icon is not icon # Not the same icon, but a copy assert other.count == 42 -# END Test testCoreStatus_StatusEntry - @pytest.mark.core def testCoreStatus_Internal(mockGUI, mockRnd): @@ -116,8 +114,6 @@ def testCoreStatus_Internal(mockGUI, mockRnd): assert nImport._checkKey("s654321") == "i00000b" # Status key not accepted assert nImport._checkKey("i123456") == "i123456" # Import key accepted -# END Test testCoreStatus_Internal - @pytest.mark.core def testCoreStatus_Iterator(mockGUI, mockRnd): @@ -162,8 +158,6 @@ def testCoreStatus_Iterator(mockGUI, mockRnd): # Content : Count assert [e.count for _, e in nStatus.iterItems()] == [0, 1, 2, 3] -# END Test testCoreStatus_Iterator - @pytest.mark.core def testCoreStatus_Entries(mockGUI, mockRnd): @@ -309,8 +303,6 @@ def testCoreStatus_Entries(mockGUI, mockRnd): assert list(nStatus._store.keys()) == [statusKeys[3], statusKeys[2]] assert nStatus._default == statusKeys[3] -# END Test testCoreStatus_Entries - @pytest.mark.core def testCoreStatus_Pack(mockGUI, mockRnd): @@ -362,8 +354,6 @@ def testCoreStatus_Pack(mockGUI, mockRnd): }), ] -# END Test testCoreStatus_Pack - @pytest.mark.core def testCoreStatus_ShapeCache(): @@ -413,5 +403,3 @@ def testCoreStatus_ShapeCache(): assert shapes.getShape(nwStatusShape.BLOCK_2) is block2 assert shapes.getShape(nwStatusShape.BLOCK_3) is block3 assert shapes.getShape(nwStatusShape.BLOCK_4) is block4 - -# END Test testCoreStatus_ShapeCache diff --git a/tests/test_core/test_core_storage.py b/tests/test_core/test_core_storage.py index 76520078..ee6e50a0 100644 --- a/tests/test_core/test_core_storage.py +++ b/tests/test_core/test_core_storage.py @@ -21,20 +21,21 @@ along with this program. If not, see . from __future__ import annotations import json -import pytest from pathlib import Path from zipfile import ZipFile -from mocked import causeOSError -from tools import C, buildTestProject +import pytest from novelwriter import CONFIG from novelwriter.constants import nwFiles from novelwriter.core.document import NWDocument from novelwriter.core.project import NWProject from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter -from novelwriter.core.storage import NWStorage, NWStorageOpen, NWStorageCreate, _LegacyStorage +from novelwriter.core.storage import NWStorage, NWStorageCreate, NWStorageOpen, _LegacyStorage + +from tests.mocked import causeOSError +from tests.tools import C, buildTestProject class MockProject: @@ -82,8 +83,6 @@ def testCoreStorage_CreateNewProject(mockGUI, fncPath): project.closeProject() -# END Test testCoreStorage_CreateNewProject - @pytest.mark.core def testCoreStorage_InitProjectStorage(monkeypatch, mockGUI, fncPath, mockRnd): @@ -163,8 +162,6 @@ def testCoreStorage_InitProjectStorage(monkeypatch, mockGUI, fncPath, mockRnd): project.closeProject() -# END Test testCoreStorage_InitProjectStorage - @pytest.mark.core def testCoreStorage_InitProjectStorage_Invalid(mockGUI, fncPath): @@ -202,8 +199,6 @@ def testCoreStorage_InitProjectStorage_Invalid(mockGUI, fncPath): project.closeProject() -# END Test testCoreStorage_InitProjectStorage_Invalid - @pytest.mark.core def testCoreStorage_LockFile(monkeypatch, fncPath): @@ -265,8 +260,6 @@ def testCoreStorage_LockFile(monkeypatch, fncPath): assert storage._clearLockFile() is True assert not lockFilePath.exists() -# END Test testCoreStorage_LockFile - @pytest.mark.core def testCoreStorage_ZipIt(monkeypatch, mockGUI, fncPath, tstPaths, mockRnd): @@ -301,8 +294,6 @@ def testCoreStorage_ZipIt(monkeypatch, mockGUI, fncPath, tstPaths, mockRnd): project.closeProject() -# END Test testCoreStorage_ZipIt - @pytest.mark.core def testCoreStorage_LegacyDataFolder(monkeypatch, fncPath): @@ -369,8 +360,6 @@ def testCoreStorage_LegacyDataFolder(monkeypatch, fncPath): for c in "0123456789abcdef": assert (fncPath / "content" / f"{c}00000000000{c}.nwd").exists() -# END Test testCoreStorage_LegacyDataFolder - @pytest.mark.core def testCoreStorage_DeprecatedFiles(monkeypatch, fncPath): @@ -412,8 +401,6 @@ def testCoreStorage_DeprecatedFiles(monkeypatch, fncPath): for depFile in remove: assert not depFile.exists() -# END Test testCoreStorage_DeprecatedFiles - @pytest.mark.core def testCoreStorage_OldFormatConvert(monkeypatch, mockGUI, fncPath): @@ -529,5 +516,3 @@ def testCoreStorage_OldFormatConvert(monkeypatch, mockGUI, fncPath): "LABEL": [False, 267], "LINE": [True, 40] } - -# END Test testCoreStorage_OldFormatConvert diff --git a/tests/test_core/test_core_tohtml.py b/tests/test_core/test_core_tohtml.py index ba596b86..a5df4696 100644 --- a/tests/test_core/test_core_tohtml.py +++ b/tests/test_core/test_core_tohtml.py @@ -129,8 +129,6 @@ def testCoreToHtml_ConvertHeaders(mockGUI): html.doConvert() assert html.result == "

Heading Two

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

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

Some text ...

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

Test text **bold** and more.

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