From 5bdbd7c1958b80a2eac191810bbcacfe342b326b Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 27 Aug 2025 21:04:32 +0200 Subject: [PATCH] Update linting for tests --- tests/conftest.py | 12 ++---------- tests/mocked.py | 7 +++---- tests/test_base/test_base_common.py | 3 +-- tests/test_base/test_base_config.py | 2 +- tests/test_base/test_base_error.py | 2 +- tests/test_base/test_base_init.py | 4 ++-- tests/test_base/test_base_shared.py | 2 +- tests/test_core/test_core_buildsettings.py | 4 ++-- tests/test_core/test_core_coretools.py | 3 +-- tests/test_core/test_core_docbuild.py | 2 +- tests/test_core/test_core_document.py | 2 +- tests/test_core/test_core_index.py | 2 +- tests/test_core/test_core_indexdata.py | 2 +- tests/test_core/test_core_item.py | 5 ++--- tests/test_core/test_core_itemmodel.py | 2 +- tests/test_core/test_core_novelmodel.py | 2 +- tests/test_core/test_core_options.py | 2 +- tests/test_core/test_core_project.py | 2 +- tests/test_core/test_core_projectxml.py | 3 +-- tests/test_core/test_core_sessions.py | 2 +- tests/test_core/test_core_spellcheck.py | 2 +- tests/test_core/test_core_status.py | 2 +- tests/test_core/test_core_storage.py | 3 ++- tests/test_core/test_core_tree.py | 2 +- tests/test_dialogs/test_dlg_about.py | 2 +- tests/test_dialogs/test_dlg_dialogs.py | 2 +- tests/test_dialogs/test_dlg_docmerge.py | 2 +- tests/test_dialogs/test_dlg_docsplit.py | 2 +- tests/test_dialogs/test_dlg_preferences.py | 2 +- tests/test_dialogs/test_dlg_projectsettings.py | 2 +- tests/test_dialogs/test_dlg_wordlist.py | 4 ++-- tests/test_ext/test_ext_eventfilters.py | 4 +--- tests/test_ext/test_ext_modified.py | 4 +--- tests/test_ext/test_ext_progressbars.py | 2 +- tests/test_ext/test_ext_switch.py | 2 +- tests/test_ext/test_ext_versioninfo.py | 6 ++---- tests/test_formats/test_fmt_todocx.py | 2 +- tests/test_formats/test_fmt_tohtml.py | 2 +- tests/test_formats/test_fmt_tokenizer.py | 2 +- tests/test_formats/test_fmt_tomarkdown.py | 2 +- tests/test_formats/test_fmt_toodt.py | 2 +- tests/test_formats/test_fmt_toqdoc.py | 2 +- tests/test_gui/test_gui_doceditor.py | 2 +- tests/test_gui/test_gui_dochighlighter.py | 2 +- tests/test_gui/test_gui_docviewer.py | 2 +- tests/test_gui/test_gui_docviewerpanel.py | 2 +- tests/test_gui/test_gui_guimain.py | 2 +- tests/test_gui/test_gui_i18n.py | 2 +- tests/test_gui/test_gui_mainmenu.py | 2 +- tests/test_gui/test_gui_noveltree.py | 2 +- tests/test_gui/test_gui_outline.py | 2 +- tests/test_gui/test_gui_projtree.py | 2 +- tests/test_gui/test_gui_search.py | 2 +- tests/test_gui/test_gui_sidebar.py | 2 +- tests/test_gui/test_gui_statusbar.py | 2 +- tests/test_gui/test_gui_theme.py | 2 +- tests/test_text/test_text_comments.py | 2 +- tests/test_text/test_text_counting.py | 2 +- tests/test_text/test_text_patterns.py | 2 +- tests/test_tools/test_tools_dictionaries.py | 2 +- tests/test_tools/test_tools_lipsum.py | 2 +- tests/test_tools/test_tools_manusbuild.py | 3 +-- tests/test_tools/test_tools_manuscript.py | 2 +- tests/test_tools/test_tools_manussettings.py | 2 +- tests/test_tools/test_tools_noveldetails.py | 2 +- tests/test_tools/test_tools_welcome.py | 2 +- tests/test_tools/test_tools_writingstats.py | 2 +- tests/tools.py | 8 ++------ 68 files changed, 78 insertions(+), 101 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index d8407d28..765755bf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import logging @@ -70,8 +70,6 @@ def resetConfigVars(): CONFIG.emphLabels = True CONFIG.lineHighlight = True - return - ## # Auto Fixtures @@ -88,7 +86,6 @@ def sessionFixture(): (_TMP_ROOT / "manual.pdf").touch() (_SRC_ROOT / "novelwriter" / "assets"/ "manual.pdf").touch() (_SRC_ROOT / "novelwriter" / "assets"/ "manual_fr.pdf").touch() - return @pytest.fixture(scope="function", autouse=True) @@ -107,8 +104,6 @@ def functionFixture(qtbot): resetConfigVars() logging.getLogger("novelwriter").setLevel(logging.INFO) - return - ## # Core Test Folders @@ -251,13 +246,11 @@ def prjLipsum(): if dstDir.exists(): shutil.rmtree(dstDir) - return - @pytest.fixture(scope="session") def ipsumText(): """Return five paragraphs of Lorem Ipsum text.""" - thatIpsum = [( + return [( "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc maximus justo non dictum co" "mmodo. Curabitur lacinia tempor orci vel luctus. Phasellus porta metus eu massa luctus, e" "get euismod risus rhoncus. Vestibulum sed arcu nisi. Maecenas pretium facilisis velit, ve" @@ -305,4 +298,3 @@ def ipsumText(): " a nisl. Etiam eget tristique dui. Nulla sed mi finibus, venenatis tellus non, maximus en" "im." )] - return thatIpsum diff --git a/tests/mocked.py b/tests/mocked.py index 37cad04c..f86d5be0 100644 --- a/tests/mocked.py +++ b/tests/mocked.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from unittest.mock import MagicMock @@ -35,7 +35,6 @@ class MockGuiMain(QWidget): self.docViewer = MagicMock() self.mainProgress = MagicMock() self.projPath = "" - return def postLaunchTasks(self, cmdOpen): return @@ -45,7 +44,6 @@ class MockGuiMain(QWidget): def openProject(self, projPath): self.projPath = projPath - return def rebuildIndex(self): return @@ -64,7 +62,6 @@ class MockTheme: self.guiFont = QFont() self.guiFontB = QFont() self.guiFontBU = QFont() - return def initThemes(self) -> None: return @@ -96,8 +93,10 @@ class MockApp: # Mock functions that will raise errors instead. def causeOSError(*args, **kwargs): + """Raise an OSError.""" raise OSError("Mock OSError") def causeException(*args, **kwargs): + """Raise an Exception.""" raise Exception("Mock Exception") diff --git a/tests/test_base/test_base_common.py b/tests/test_base/test_base_common.py index a46f02d0..95d339df 100644 --- a/tests/test_base/test_base_common.py +++ b/tests/test_base/test_base_common.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import time @@ -794,7 +794,6 @@ def testBaseCommon_openExternalPath(monkeypatch, tstPaths): def mockOpenUrl(url: QUrl) -> None: nonlocal lastUrl lastUrl = url.toString() - return monkeypatch.setattr(QDesktopServices, "openUrl", mockOpenUrl) assert openExternalPath(Path("/foo/bar")) is False diff --git a/tests/test_base/test_base_config.py b/tests/test_base/test_base_config.py index 98a1063d..901aa1ee 100644 --- a/tests/test_base/test_base_config.py +++ b/tests/test_base/test_base_config.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import datetime diff --git a/tests/test_base/test_base_error.py b/tests/test_base/test_base_error.py index 65499666..9a8c1bd3 100644 --- a/tests/test_base/test_base_error.py +++ b/tests/test_base/test_base_error.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import sys diff --git a/tests/test_base/test_base_init.py b/tests/test_base/test_base_init.py index cc1fbeb8..45ac3c79 100644 --- a/tests/test_base/test_base_init.py +++ b/tests/test_base/test_base_init.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import logging @@ -40,7 +40,7 @@ from tests.tools import clearLogHandlers @pytest.mark.base def testBaseInit_Launch(caplog, monkeypatch, fncPath): - """Check launching the main GUI. This test """ + """Check launching the main GUI.""" monkeypatch.setattr(NSplashScreen, "finish", lambda *a: None) monkeypatch.setattr("novelwriter.splash.sleep", lambda *a: None) monkeypatch.setattr("novelwriter._createApp", lambda *a: Mock()) diff --git a/tests/test_base/test_base_shared.py b/tests/test_base/test_base_shared.py index 8873b5b3..64cc306b 100644 --- a/tests/test_base/test_base_shared.py +++ b/tests/test_base/test_base_shared.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from unittest.mock import MagicMock diff --git a/tests/test_core/test_core_buildsettings.py b/tests/test_core/test_core_buildsettings.py index 2b21b673..d51406b3 100644 --- a/tests/test_core/test_core_buildsettings.py +++ b/tests/test_core/test_core_buildsettings.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json @@ -39,7 +39,7 @@ from tests.tools import C, buildTestProject def isUUID(value): - """Checks if a value is a valid UUID object.""" + """Check if a value is a valid UUID object.""" try: uuid.UUID(value) return True diff --git a/tests/test_core/test_core_coretools.py b/tests/test_core/test_core_coretools.py index 0bd4b24c..da4e5551 100644 --- a/tests/test_core/test_core_coretools.py +++ b/tests/test_core/test_core_coretools.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import shutil @@ -669,7 +669,6 @@ def testCoreTools_ProjectBuilderCopyPlain(monkeypatch, caplog, mockGUI, prjLipsu @pytest.mark.core def testCoreTools_ProjectBuilderCopyZipped(monkeypatch, caplog, mockGUI, fncPath, mockRnd): """Create a new project copied from existing zipped project.""" - # Create a project origPath = fncPath / "original" srcProject = NWProject() diff --git a/tests/test_core/test_core_docbuild.py b/tests/test_core/test_core_docbuild.py index 15655298..0a7efee8 100644 --- a/tests/test_core/test_core_docbuild.py +++ b/tests/test_core/test_core_docbuild.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index 666a85af..78a14240 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index e86b8dc0..332c27c3 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json diff --git a/tests/test_core/test_core_indexdata.py b/tests/test_core/test_core_indexdata.py index d4797aee..faef5d51 100644 --- a/tests/test_core/test_core_indexdata.py +++ b/tests/test_core/test_core_indexdata.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_core/test_core_item.py b/tests/test_core/test_core_item.py index f6cd4278..1b6dba2d 100644 --- a/tests/test_core/test_core_item.py +++ b/tests/test_core/test_core_item.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import copy @@ -491,8 +491,7 @@ def testCoreItem_LayoutSetter(mockGUI): @pytest.mark.core def testCoreItem_ClassDefaults(mockGUI): - """Test the setter for the default values. - """ + """Test the setter for the default values.""" project = NWProject() item = NWItem(project, "0000000000000") diff --git a/tests/test_core/test_core_itemmodel.py b/tests/test_core/test_core_itemmodel.py index d6efd718..2869b7e5 100644 --- a/tests/test_core/test_core_itemmodel.py +++ b/tests/test_core/test_core_itemmodel.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_core/test_core_novelmodel.py b/tests/test_core/test_core_novelmodel.py index 22955c70..a2835ec0 100644 --- a/tests/test_core/test_core_novelmodel.py +++ b/tests/test_core/test_core_novelmodel.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_core/test_core_options.py b/tests/test_core/test_core_options.py index 51a45c8c..b830b0be 100644 --- a/tests/test_core/test_core_options.py +++ b/tests/test_core/test_core_options.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index b72c8132..cdb202c1 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from shutil import copyfile diff --git a/tests/test_core/test_core_projectxml.py b/tests/test_core/test_core_projectxml.py index ebccbbfa..efcd71a0 100644 --- a/tests/test_core/test_core_projectxml.py +++ b/tests/test_core/test_core_projectxml.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json @@ -53,7 +53,6 @@ def mockVersion(monkeypatch): """Mock the version info to prevent diff from failing.""" monkeypatch.setattr("novelwriter.core.projectxml.__version__", "2.7b1") monkeypatch.setattr("novelwriter.core.projectxml.__hexversion__", "0x020700b1") - return @pytest.mark.core diff --git a/tests/test_core/test_core_sessions.py b/tests/test_core/test_core_sessions.py index d601fcd7..af47a4aa 100644 --- a/tests/test_core/test_core_sessions.py +++ b/tests/test_core/test_core_sessions.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from pathlib import Path diff --git a/tests/test_core/test_core_spellcheck.py b/tests/test_core/test_core_spellcheck.py index e96b1657..6c8af4bf 100644 --- a/tests/test_core/test_core_spellcheck.py +++ b/tests/test_core/test_core_spellcheck.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import sys diff --git a/tests/test_core/test_core_status.py b/tests/test_core/test_core_status.py index 7927678e..35a2b944 100644 --- a/tests/test_core/test_core_status.py +++ b/tests/test_core/test_core_status.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_core/test_core_storage.py b/tests/test_core/test_core_storage.py index 6e006d43..bbc68a44 100644 --- a/tests/test_core/test_core_storage.py +++ b/tests/test_core/test_core_storage.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json @@ -40,6 +40,7 @@ from tests.tools import C, buildTestProject class MockProject: """Test class for projects.""" + pass diff --git a/tests/test_core/test_core_tree.py b/tests/test_core/test_core_tree.py index 432ae8f7..9184a51a 100644 --- a/tests/test_core/test_core_tree.py +++ b/tests/test_core/test_core_tree.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import random diff --git a/tests/test_dialogs/test_dlg_about.py b/tests/test_dialogs/test_dlg_about.py index bde9ad7d..f143dd36 100644 --- a/tests/test_dialogs/test_dlg_about.py +++ b/tests/test_dialogs/test_dlg_about.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from pathlib import Path diff --git a/tests/test_dialogs/test_dlg_dialogs.py b/tests/test_dialogs/test_dlg_dialogs.py index ce3d6bc3..50359218 100644 --- a/tests/test_dialogs/test_dlg_dialogs.py +++ b/tests/test_dialogs/test_dlg_dialogs.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_dialogs/test_dlg_docmerge.py b/tests/test_dialogs/test_dlg_docmerge.py index 7431b3d7..0361fd12 100644 --- a/tests/test_dialogs/test_dlg_docmerge.py +++ b/tests/test_dialogs/test_dlg_docmerge.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_dialogs/test_dlg_docsplit.py b/tests/test_dialogs/test_dlg_docsplit.py index bd75ca01..38dda722 100644 --- a/tests/test_dialogs/test_dlg_docsplit.py +++ b/tests/test_dialogs/test_dlg_docsplit.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_dialogs/test_dlg_preferences.py b/tests/test_dialogs/test_dlg_preferences.py index 03b23a01..dd749aa5 100644 --- a/tests/test_dialogs/test_dlg_preferences.py +++ b/tests/test_dialogs/test_dlg_preferences.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_dialogs/test_dlg_projectsettings.py b/tests/test_dialogs/test_dlg_projectsettings.py index c20382d1..0219e359 100644 --- a/tests/test_dialogs/test_dlg_projectsettings.py +++ b/tests/test_dialogs/test_dlg_projectsettings.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_dialogs/test_dlg_wordlist.py b/tests/test_dialogs/test_dlg_wordlist.py index 9b42d5a7..f4cd819b 100644 --- a/tests/test_dialogs/test_dlg_wordlist.py +++ b/tests/test_dialogs/test_dlg_wordlist.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest @@ -37,7 +37,7 @@ from tests.tools import buildTestProject @pytest.mark.gui def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, fncPath, projPath): - """test the word list editor.""" + """Test the word list editor.""" buildTestProject(nwGUI, projPath) monkeypatch.setattr(GuiWordList, "exec", lambda *a: None) diff --git a/tests/test_ext/test_ext_eventfilters.py b/tests/test_ext/test_ext_eventfilters.py index 628932f1..feb998d1 100644 --- a/tests/test_ext/test_ext_eventfilters.py +++ b/tests/test_ext/test_ext_eventfilters.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest @@ -35,11 +35,9 @@ class MockWidget(QWidget): def __init__(self): super().__init__(None) self.count = 0 - return def wheelEvent(self, event: QWheelEvent) -> None: self.count += 1 - return @pytest.mark.gui diff --git a/tests/test_ext/test_ext_modified.py b/tests/test_ext/test_ext_modified.py index 844d47a6..7e65de1a 100644 --- a/tests/test_ext/test_ext_modified.py +++ b/tests/test_ext/test_ext_modified.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest @@ -43,12 +43,10 @@ class MockWheelEvent(QWheelEvent): Qt.ScrollPhase.ScrollUpdate, False ) self.ignored = False - return def ignore(self): super().ignore() self.ignored = True - return @pytest.mark.gui diff --git a/tests/test_ext/test_ext_progressbars.py b/tests/test_ext/test_ext_progressbars.py index f0d1e292..0cd8c80a 100644 --- a/tests/test_ext/test_ext_progressbars.py +++ b/tests/test_ext/test_ext_progressbars.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from time import sleep diff --git a/tests/test_ext/test_ext_switch.py b/tests/test_ext/test_ext_switch.py index 734a2257..edf05a92 100644 --- a/tests/test_ext/test_ext_switch.py +++ b/tests/test_ext/test_ext_switch.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_ext/test_ext_versioninfo.py b/tests/test_ext/test_ext_versioninfo.py index cbf1428c..a5cedc54 100644 --- a/tests/test_ext/test_ext_versioninfo.py +++ b/tests/test_ext/test_ext_versioninfo.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from urllib.error import HTTPError @@ -44,7 +44,6 @@ class MockDesktopServices: @staticmethod def openUrl(url): MockDesktopServices.url = url - return class MockData: @@ -61,8 +60,7 @@ class MockPayload: return def read(self): - data = MockData() - return data + return MockData() class MockHTTPError: diff --git a/tests/test_formats/test_fmt_todocx.py b/tests/test_formats/test_fmt_todocx.py index bf643739..eb88888a 100644 --- a/tests/test_formats/test_fmt_todocx.py +++ b/tests/test_formats/test_fmt_todocx.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import xml.etree.ElementTree as ET diff --git a/tests/test_formats/test_fmt_tohtml.py b/tests/test_formats/test_fmt_tohtml.py index c3bd64a7..a7479d02 100644 --- a/tests/test_formats/test_fmt_tohtml.py +++ b/tests/test_formats/test_fmt_tohtml.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json diff --git a/tests/test_formats/test_fmt_tokenizer.py b/tests/test_formats/test_fmt_tokenizer.py index 63c9cab0..dd61b3ea 100644 --- a/tests/test_formats/test_fmt_tokenizer.py +++ b/tests/test_formats/test_fmt_tokenizer.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_formats/test_fmt_tomarkdown.py b/tests/test_formats/test_fmt_tomarkdown.py index 90f26ff7..84c0dbc9 100644 --- a/tests/test_formats/test_fmt_tomarkdown.py +++ b/tests/test_formats/test_fmt_tomarkdown.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_formats/test_fmt_toodt.py b/tests/test_formats/test_fmt_toodt.py index eded1eeb..a859f6b9 100644 --- a/tests/test_formats/test_fmt_toodt.py +++ b/tests/test_formats/test_fmt_toodt.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import xml.etree.ElementTree as ET diff --git a/tests/test_formats/test_fmt_toqdoc.py b/tests/test_formats/test_fmt_toqdoc.py index 697d4833..04d51fdd 100644 --- a/tests/test_formats/test_fmt_toqdoc.py +++ b/tests/test_formats/test_fmt_toqdoc.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index d0ec924d..13589957 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from unittest.mock import MagicMock diff --git a/tests/test_gui/test_gui_dochighlighter.py b/tests/test_gui/test_gui_dochighlighter.py index 622154c2..2df0d39e 100644 --- a/tests/test_gui/test_gui_dochighlighter.py +++ b/tests/test_gui/test_gui_dochighlighter.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_gui/test_gui_docviewer.py b/tests/test_gui/test_gui_docviewer.py index 8890df22..ac16173b 100644 --- a/tests/test_gui/test_gui_docviewer.py +++ b/tests/test_gui/test_gui_docviewer.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from unittest.mock import MagicMock diff --git a/tests/test_gui/test_gui_docviewerpanel.py b/tests/test_gui/test_gui_docviewerpanel.py index f51d9a81..32c3c54e 100644 --- a/tests/test_gui/test_gui_docviewerpanel.py +++ b/tests/test_gui/test_gui_docviewerpanel.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py index 1ebfa42c..258d5e0a 100644 --- a/tests/test_gui/test_gui_guimain.py +++ b/tests/test_gui/test_gui_guimain.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import shutil diff --git a/tests/test_gui/test_gui_i18n.py b/tests/test_gui/test_gui_i18n.py index aab521ce..915d83a4 100644 --- a/tests/test_gui/test_gui_i18n.py +++ b/tests/test_gui/test_gui_i18n.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import sys diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index b13b18a1..9c327cda 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from unittest.mock import MagicMock diff --git a/tests/test_gui/test_gui_noveltree.py b/tests/test_gui/test_gui_noveltree.py index cd726e0a..39938a3e 100644 --- a/tests/test_gui/test_gui_noveltree.py +++ b/tests/test_gui/test_gui_noveltree.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from pathlib import Path diff --git a/tests/test_gui/test_gui_outline.py b/tests/test_gui/test_gui_outline.py index 8ee650df..f93171dc 100644 --- a/tests/test_gui/test_gui_outline.py +++ b/tests/test_gui/test_gui_outline.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import time diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py index 02216700..f6430f55 100644 --- a/tests/test_gui/test_gui_projtree.py +++ b/tests/test_gui/test_gui_projtree.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from unittest.mock import MagicMock diff --git a/tests/test_gui/test_gui_search.py b/tests/test_gui/test_gui_search.py index 3110fa3e..a4065dbf 100644 --- a/tests/test_gui/test_gui_search.py +++ b/tests/test_gui/test_gui_search.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from time import time diff --git a/tests/test_gui/test_gui_sidebar.py b/tests/test_gui/test_gui_sidebar.py index 45e372db..e4ec983e 100644 --- a/tests/test_gui/test_gui_sidebar.py +++ b/tests/test_gui/test_gui_sidebar.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_gui/test_gui_statusbar.py b/tests/test_gui/test_gui_statusbar.py index efb19f48..19c3f277 100644 --- a/tests/test_gui/test_gui_statusbar.py +++ b/tests/test_gui/test_gui_statusbar.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import time diff --git a/tests/test_gui/test_gui_theme.py b/tests/test_gui/test_gui_theme.py index aa2af3cf..aa613bd5 100644 --- a/tests/test_gui/test_gui_theme.py +++ b/tests/test_gui/test_gui_theme.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json diff --git a/tests/test_text/test_text_comments.py b/tests/test_text/test_text_comments.py index 30be4e37..9b42294e 100644 --- a/tests/test_text/test_text_comments.py +++ b/tests/test_text/test_text_comments.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_text/test_text_counting.py b/tests/test_text/test_text_counting.py index 8accab95..d7661e18 100644 --- a/tests/test_text/test_text_counting.py +++ b/tests/test_text/test_text_counting.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_text/test_text_patterns.py b/tests/test_text/test_text_patterns.py index 2670401e..1325b1d6 100644 --- a/tests/test_text/test_text_patterns.py +++ b/tests/test_text/test_text_patterns.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import re diff --git a/tests/test_tools/test_tools_dictionaries.py b/tests/test_tools/test_tools_dictionaries.py index e8a23c7b..b22ec074 100644 --- a/tests/test_tools/test_tools_dictionaries.py +++ b/tests/test_tools/test_tools_dictionaries.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from zipfile import ZipFile diff --git a/tests/test_tools/test_tools_lipsum.py b/tests/test_tools/test_tools_lipsum.py index 27098b5c..b73a78f3 100644 --- a/tests/test_tools/test_tools_lipsum.py +++ b/tests/test_tools/test_tools_lipsum.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_tools/test_tools_manusbuild.py b/tests/test_tools/test_tools_manusbuild.py index 50d04391..91924120 100644 --- a/tests/test_tools/test_tools_manusbuild.py +++ b/tests/test_tools/test_tools_manusbuild.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from pathlib import Path @@ -143,7 +143,6 @@ def testToolManuscriptBuild_Main( def mockOpenUrl(url: QUrl) -> None: nonlocal lastUrl lastUrl = url.toString() - return with monkeypatch.context() as mp: mp.setattr(QDesktopServices, "openUrl", mockOpenUrl) diff --git a/tests/test_tools/test_tools_manuscript.py b/tests/test_tools/test_tools_manuscript.py index 070b5db6..0e498ea1 100644 --- a/tests/test_tools/test_tools_manuscript.py +++ b/tests/test_tools/test_tools_manuscript.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import sys diff --git a/tests/test_tools/test_tools_manussettings.py b/tests/test_tools/test_tools_manussettings.py index 91a9f4f9..b5ce7880 100644 --- a/tests/test_tools/test_tools_manussettings.py +++ b/tests/test_tools/test_tools_manussettings.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_tools/test_tools_noveldetails.py b/tests/test_tools/test_tools_noveldetails.py index 067cbc08..64428cdf 100644 --- a/tests/test_tools/test_tools_noveldetails.py +++ b/tests/test_tools/test_tools_noveldetails.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import pytest diff --git a/tests/test_tools/test_tools_welcome.py b/tests/test_tools/test_tools_welcome.py index 42157b2d..846e3900 100644 --- a/tests/test_tools/test_tools_welcome.py +++ b/tests/test_tools/test_tools_welcome.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations from datetime import datetime diff --git a/tests/test_tools/test_tools_writingstats.py b/tests/test_tools/test_tools_writingstats.py index 0e2bc4ee..1992096a 100644 --- a/tests/test_tools/test_tools_writingstats.py +++ b/tests/test_tools/test_tools_writingstats.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import json diff --git a/tests/tools.py b/tests/tools.py index 7acc598f..9eec20d0 100644 --- a/tests/tools.py +++ b/tests/tools.py @@ -17,7 +17,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -""" +""" # noqa from __future__ import annotations import shutil @@ -124,7 +124,7 @@ def xmlToText(xElem): def readFile(fileName: str | Path): - """Returns the content of a file as a string.""" + """Return the content of a file as a string.""" with open(fileName, mode="r", encoding="utf-8") as inFile: return inFile.read() @@ -154,8 +154,6 @@ def cleanProject(path: str | Path): if tocFile.is_file(): tocFile.unlink() - return - def clearLogHandlers(): """Clear all log handlers.""" @@ -235,7 +233,6 @@ class SimpleDialog(QDialog): self.setLayout(layout) if widget: layout.addWidget(widget) - return @property def widget(self) -> QWidget | None: @@ -246,4 +243,3 @@ class SimpleDialog(QDialog): layout = self.layout() assert layout is not None layout.addWidget(widget) - return