From 30661130ca81fc5ff48b12bc7975b69a051c1521 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 15 Oct 2022 22:56:18 +0200 Subject: [PATCH] Ignore coverage of lines of old Qt versions --- novelwriter/gui/doceditor.py | 3 ++- novelwriter/gui/docviewer.py | 4 ++-- novelwriter/tools/build.py | 2 +- tests/test_base/test_base_config.py | 6 ------ tests/test_gui/test_gui_mainmenu.py | 10 ++-------- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 5454341f..2c908c2f 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -2474,7 +2474,8 @@ class GuiDocEditSearch(QFrame): self._alertSearchValid(theRegEx.isValid()) return theRegEx - else: # >= 50300 to < 51300 + else: # pragma: no cover + # >= 50300 to < 51300 if self.isCaseSense: rxOpt = Qt.CaseSensitive else: diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index f4413805..5c9ae4ab 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -152,7 +152,7 @@ class GuiDocViewer(QTextBrowser): # Refresh the tab stops if self.mainConf.verQtValue >= 51000: self.setTabStopDistance(self.mainConf.getTabWidth()) - else: + else: # pragma: no cover self.setTabStopWidth(self.mainConf.getTabWidth()) # If we have a document open, we should reload it in case the font changed @@ -195,7 +195,7 @@ class GuiDocViewer(QTextBrowser): # Refresh the tab stops if self.mainConf.verQtValue >= 51000: self.setTabStopDistance(self.mainConf.getTabWidth()) - else: + else: # pragma: no cover self.setTabStopWidth(self.mainConf.getTabWidth()) # Must be before setHtml diff --git a/novelwriter/tools/build.py b/novelwriter/tools/build.py index 6260b039..1518a079 100644 --- a/novelwriter/tools/build.py +++ b/novelwriter/tools/build.py @@ -1267,7 +1267,7 @@ class GuiBuildNovelDocView(QTextBrowser): # Set the tab stops if self.mainConf.verQtValue >= 51000: self.setTabStopDistance(self.mainConf.getTabWidth()) - else: + else: # pragma: no cover self.setTabStopWidth(self.mainConf.getTabWidth()) docPalette = self.palette() diff --git a/tests/test_base/test_base_config.py b/tests/test_base/test_base_config.py index 83ff3160..49387ab0 100644 --- a/tests/test_base/test_base_config.py +++ b/tests/test_base/test_base_config.py @@ -96,12 +96,6 @@ def testBaseConfig_Init(monkeypatch, tmpDir, fncDir, outDir, refDir, filesDir): # Let the config class figure out the path with monkeypatch.context() as mp: mp.setattr("PyQt5.QtCore.QStandardPaths.writableLocation", lambda *a: fncDir) - tstConf.verQtValue = 50600 - tstConf.initConfig() - assert tstConf.confPath == os.path.join(fncDir, tstConf.appHandle) - assert tstConf.dataPath == os.path.join(fncDir, tstConf.appHandle) - assert not os.path.isfile(confFile) - tstConf.verQtValue = 50000 tstConf.initConfig() assert tstConf.confPath == os.path.join(fncDir, tstConf.appHandle) assert tstConf.dataPath == os.path.join(fncDir, tstConf.appHandle) diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index 8aeb6cd4..c4bf2dd3 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -566,10 +566,7 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd): nwGUI.docEditor.clear() nwGUI.mainMenu.aInsNBSpace.activate(QAction.Trigger) - if nwGUI.mainConf.verQtValue >= 50900: - assert nwGUI.docEditor.getText() == nwUnicode.U_NBSP - else: - assert nwGUI.docEditor.getText() == " " + assert nwGUI.docEditor.getText() == nwUnicode.U_NBSP nwGUI.docEditor.clear() nwGUI.mainMenu.aInsThinSpace.activate(QAction.Trigger) @@ -577,10 +574,7 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd): nwGUI.docEditor.clear() nwGUI.mainMenu.aInsThinNBSpace.activate(QAction.Trigger) - if nwGUI.mainConf.verQtValue >= 50900: - assert nwGUI.docEditor.getText() == nwUnicode.U_THNBSP - else: - assert nwGUI.docEditor.getText() == " " + assert nwGUI.docEditor.getText() == nwUnicode.U_THNBSP nwGUI.docEditor.clear() ##