Remove dependency on .mainConf class variable in tests
This commit is contained in:
@@ -31,7 +31,6 @@ class MockGuiMain(QObject):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.mainConf = None
|
|
||||||
self.hasProject = True
|
self.hasProject = True
|
||||||
self.theProject = None
|
self.theProject = None
|
||||||
self.mainStatus = MockStatusBar()
|
self.mainStatus = MockStatusBar()
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ from zipfile import ZipFile
|
|||||||
from mock import causeOSError
|
from mock import causeOSError
|
||||||
from tools import C, cmpFiles, writeFile, buildTestProject, XML_IGNORE
|
from tools import C, cmpFiles, writeFile, buildTestProject, XML_IGNORE
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwItemClass, nwItemType, nwItemLayout
|
from novelwriter.enum import nwItemClass, nwItemType, nwItemLayout
|
||||||
from novelwriter.common import formatTimeStamp
|
from novelwriter.common import formatTimeStamp
|
||||||
from novelwriter.constants import nwFiles
|
from novelwriter.constants import nwFiles
|
||||||
@@ -721,17 +722,17 @@ def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths):
|
|||||||
# ================
|
# ================
|
||||||
|
|
||||||
# Invalid path
|
# Invalid path
|
||||||
theProject.mainConf._backupPath = None
|
CONFIG._backupPath = None
|
||||||
assert theProject.backupProject(doNotify=False) is False
|
assert theProject.backupProject(doNotify=False) is False
|
||||||
|
|
||||||
# Missing project name
|
# Missing project name
|
||||||
theProject.mainConf._backupPath = tstPaths.tmpDir
|
CONFIG._backupPath = tstPaths.tmpDir
|
||||||
theProject.data.setName("")
|
theProject.data.setName("")
|
||||||
assert theProject.backupProject(doNotify=False) is False
|
assert theProject.backupProject(doNotify=False) is False
|
||||||
|
|
||||||
# Valid Settings
|
# Valid Settings
|
||||||
# ==============
|
# ==============
|
||||||
theProject.mainConf._backupPath = tstPaths.tmpDir
|
CONFIG._backupPath = tstPaths.tmpDir
|
||||||
theProject.data.setName("Test Minimal")
|
theProject.data.setName("Test Minimal")
|
||||||
|
|
||||||
# Can't make folder
|
# Can't make folder
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import pytest
|
|||||||
from mock import causeOSError
|
from mock import causeOSError
|
||||||
from tools import C, buildTestProject, writeFile
|
from tools import C, buildTestProject, writeFile
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.constants import nwFiles
|
from novelwriter.constants import nwFiles
|
||||||
from novelwriter.core.project import NWProject
|
from novelwriter.core.project import NWProject
|
||||||
from novelwriter.core.storage import NWStorage
|
from novelwriter.core.storage import NWStorage
|
||||||
@@ -148,9 +149,9 @@ def testCoreStorage_LockFile(monkeypatch, fncPath):
|
|||||||
|
|
||||||
# Successful read
|
# Successful read
|
||||||
assert storage.readLockFile() == [
|
assert storage.readLockFile() == [
|
||||||
storage.mainConf.hostName,
|
CONFIG.hostName,
|
||||||
storage.mainConf.osType,
|
CONFIG.osType,
|
||||||
storage.mainConf.kernelVer,
|
CONFIG.kernelVer,
|
||||||
"1000",
|
"1000",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QDialogButtonBox, QDialog, QAction, QFileDialog, QFontDialog
|
QDialogButtonBox, QDialog, QAction, QFileDialog, QFontDialog
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||||
from novelwriter.dialogs.preferences import GuiPreferences
|
from novelwriter.dialogs.preferences import GuiPreferences
|
||||||
|
|
||||||
@@ -211,7 +212,7 @@ def testDlgPreferences_Main(qtbot, monkeypatch, nwGUI, tstPaths):
|
|||||||
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
|
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
|
||||||
nwPrefs._doClose()
|
nwPrefs._doClose()
|
||||||
|
|
||||||
assert nwGUI.mainConf.saveConfig()
|
assert CONFIG.saveConfig()
|
||||||
projFile = tstPaths.cnfDir / "novelwriter.conf"
|
projFile = tstPaths.cnfDir / "novelwriter.conf"
|
||||||
testFile = tstPaths.outDir / "guiPreferences_novelwriter.conf"
|
testFile = tstPaths.outDir / "guiPreferences_novelwriter.conf"
|
||||||
compFile = tstPaths.refDir / "guiPreferences_novelwriter.conf"
|
compFile = tstPaths.refDir / "guiPreferences_novelwriter.conf"
|
||||||
|
|||||||
@@ -21,13 +21,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from novelwriter.enum import nwItemType
|
|
||||||
from tools import C, getGuiItem, buildTestProject
|
from tools import C, getGuiItem, buildTestProject
|
||||||
|
|
||||||
from PyQt5.QtGui import QColor
|
from PyQt5.QtGui import QColor
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QDialog, QAction, QColorDialog
|
from PyQt5.QtWidgets import QDialog, QAction, QColorDialog
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
|
from novelwriter.enum import nwItemType
|
||||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||||
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ def testDlgProjSettings_Main(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockR
|
|||||||
# Create new project
|
# Create new project
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
nwGUI.mainConf.setBackupPath(fncPath)
|
CONFIG.setBackupPath(fncPath)
|
||||||
|
|
||||||
# Set some values
|
# Set some values
|
||||||
theProject = nwGUI.theProject
|
theProject = nwGUI.theProject
|
||||||
@@ -156,7 +157,7 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, fncPath, projPat
|
|||||||
# Create new project
|
# Create new project
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
nwGUI.mainConf.setBackupPath(fncPath)
|
CONFIG.setBackupPath(fncPath)
|
||||||
|
|
||||||
# Set some values
|
# Set some values
|
||||||
theProject = nwGUI.theProject
|
theProject = nwGUI.theProject
|
||||||
@@ -357,7 +358,7 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, fncPath, projPath, mo
|
|||||||
# Create new project
|
# Create new project
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
nwGUI.mainConf.setBackupPath(fncPath)
|
CONFIG.setBackupPath(fncPath)
|
||||||
|
|
||||||
# Set some values
|
# Set some values
|
||||||
theProject = nwGUI.theProject
|
theProject = nwGUI.theProject
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from PyQt5.QtCore import Qt
|
|||||||
from PyQt5.QtGui import QTextBlock, QTextCursor, QTextOption
|
from PyQt5.QtGui import QTextBlock, QTextCursor, QTextOption
|
||||||
from PyQt5.QtWidgets import QAction, qApp
|
from PyQt5.QtWidgets import QAction, qApp
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwDocAction, nwDocInsert, nwItemLayout
|
from novelwriter.enum import nwDocAction, nwDocInsert, nwItemLayout
|
||||||
from novelwriter.constants import nwKeyWords, nwUnicode
|
from novelwriter.constants import nwKeyWords, nwUnicode
|
||||||
from novelwriter.core.index import countWords
|
from novelwriter.core.index import countWords
|
||||||
@@ -55,18 +56,18 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
assert nwGUI.docEditor._typPadChar == nwUnicode.U_NBSP
|
assert nwGUI.docEditor._typPadChar == nwUnicode.U_NBSP
|
||||||
|
|
||||||
# Check that editor handles settings
|
# Check that editor handles settings
|
||||||
nwGUI.mainConf.textFont = None
|
CONFIG.textFont = None
|
||||||
nwGUI.mainConf.doJustify = True
|
CONFIG.doJustify = True
|
||||||
nwGUI.mainConf.showTabsNSpaces = True
|
CONFIG.showTabsNSpaces = True
|
||||||
nwGUI.mainConf.showLineEndings = True
|
CONFIG.showLineEndings = True
|
||||||
nwGUI.mainConf.hideVScroll = True
|
CONFIG.hideVScroll = True
|
||||||
nwGUI.mainConf.hideHScroll = True
|
CONFIG.hideHScroll = True
|
||||||
nwGUI.mainConf.fmtPadThin = True
|
CONFIG.fmtPadThin = True
|
||||||
|
|
||||||
assert nwGUI.docEditor.initEditor()
|
assert nwGUI.docEditor.initEditor()
|
||||||
|
|
||||||
qDoc = nwGUI.docEditor.document()
|
qDoc = nwGUI.docEditor.document()
|
||||||
assert nwGUI.mainConf.textFont == qDoc.defaultFont().family()
|
assert CONFIG.textFont == qDoc.defaultFont().family()
|
||||||
assert qDoc.defaultTextOption().alignment() == Qt.AlignJustify
|
assert qDoc.defaultTextOption().alignment() == Qt.AlignJustify
|
||||||
assert qDoc.defaultTextOption().flags() & QTextOption.ShowTabsAndSpaces
|
assert qDoc.defaultTextOption().flags() & QTextOption.ShowTabsAndSpaces
|
||||||
assert qDoc.defaultTextOption().flags() & QTextOption.ShowLineAndParagraphSeparators
|
assert qDoc.defaultTextOption().flags() & QTextOption.ShowLineAndParagraphSeparators
|
||||||
@@ -114,7 +115,7 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
|||||||
assert "The document you are trying to open is too big." in caplog.text
|
assert "The document you are trying to open is too big." in caplog.text
|
||||||
|
|
||||||
# Big doc handling
|
# Big doc handling
|
||||||
nwGUI.mainConf.bigDocLimit = 50
|
CONFIG.bigDocLimit = 50
|
||||||
assert nwGUI.docEditor.loadText(C.hSceneDoc) is True
|
assert nwGUI.docEditor.loadText(C.hSceneDoc) is True
|
||||||
assert nwGUI.docEditor._bigDoc is True
|
assert nwGUI.docEditor._bigDoc is True
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from mock import causeException
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QUrl
|
from PyQt5.QtCore import Qt, QUrl
|
||||||
from PyQt5.QtGui import QTextCursor
|
from PyQt5.QtGui import QTextCursor
|
||||||
from PyQt5.QtWidgets import qApp, QAction
|
from PyQt5.QtWidgets import qApp, QAction
|
||||||
from mock import causeException
|
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwDocAction
|
from novelwriter.enum import nwDocAction
|
||||||
from novelwriter.core.tohtml import ToHtml
|
from novelwriter.core.tohtml import ToHtml
|
||||||
|
|
||||||
@@ -134,10 +136,10 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
|
|||||||
assert nwGUI.docViewer.docHeader.theTitle.text() == "Characters › Test Title"
|
assert nwGUI.docViewer.docHeader.theTitle.text() == "Characters › Test Title"
|
||||||
|
|
||||||
# Ttile without full path
|
# Ttile without full path
|
||||||
nwGUI.mainConf.showFullPath = False
|
CONFIG.showFullPath = False
|
||||||
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
||||||
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
|
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
|
||||||
nwGUI.mainConf.showFullPath = True
|
CONFIG.showFullPath = True
|
||||||
|
|
||||||
# Document footer show/hide references
|
# Document footer show/hide references
|
||||||
viewState = nwGUI.viewMeta.isVisible()
|
viewState = nwGUI.viewMeta.isVisible()
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from tools import (
|
|||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QDialog, QMessageBox, QInputDialog
|
from PyQt5.QtWidgets import QDialog, QMessageBox, QInputDialog
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwItemType, nwView, nwWidget
|
from novelwriter.enum import nwItemType, nwView, nwWidget
|
||||||
from novelwriter.constants import nwFiles
|
from novelwriter.constants import nwFiles
|
||||||
from novelwriter.gui.outline import GuiOutlineView
|
from novelwriter.gui.outline import GuiOutlineView
|
||||||
@@ -75,7 +76,7 @@ def testGuiMain_Launch(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
"""
|
"""
|
||||||
monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *a: None)
|
monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *a: None)
|
||||||
monkeypatch.setattr(GuiProjectLoad, "result", lambda *a: QDialog.Accepted)
|
monkeypatch.setattr(GuiProjectLoad, "result", lambda *a: QDialog.Accepted)
|
||||||
nwGUI.mainConf.lastNotes = "0x0"
|
CONFIG.lastNotes = "0x0"
|
||||||
|
|
||||||
# Open Lipsum project
|
# Open Lipsum project
|
||||||
nwGUI.postLaunchTasks(prjLipsum)
|
nwGUI.postLaunchTasks(prjLipsum)
|
||||||
@@ -244,10 +245,10 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
assert nwGUI.mainMenu._toggleSpellCheck()
|
assert nwGUI.mainMenu._toggleSpellCheck()
|
||||||
|
|
||||||
# Change some settings
|
# Change some settings
|
||||||
nwGUI.mainConf.hideHScroll = True
|
CONFIG.hideHScroll = True
|
||||||
nwGUI.mainConf.hideVScroll = True
|
CONFIG.hideVScroll = True
|
||||||
nwGUI.mainConf.autoScrollPos = 80
|
CONFIG.autoScrollPos = 80
|
||||||
nwGUI.mainConf.autoScroll = True
|
CONFIG.autoScroll = True
|
||||||
|
|
||||||
# Add a Character File
|
# Add a Character File
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI.switchFocus(nwWidget.TREE)
|
||||||
@@ -589,11 +590,11 @@ def testGuiMain_FocusFullMode(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
# Full Screen Mode
|
# Full Screen Mode
|
||||||
# ================
|
# ================
|
||||||
|
|
||||||
assert nwGUI.mainConf.isFullScreen is False
|
assert CONFIG.isFullScreen is False
|
||||||
nwGUI.toggleFullScreenMode()
|
nwGUI.toggleFullScreenMode()
|
||||||
assert nwGUI.mainConf.isFullScreen is True
|
assert CONFIG.isFullScreen is True
|
||||||
nwGUI.toggleFullScreenMode()
|
nwGUI.toggleFullScreenMode()
|
||||||
assert nwGUI.mainConf.isFullScreen is False
|
assert CONFIG.isFullScreen is False
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox
|
|||||||
|
|
||||||
from tools import C, writeFile, buildTestProject
|
from tools import C, writeFile, buildTestProject
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwDocAction, nwDocInsert
|
from novelwriter.enum import nwDocAction, nwDocInsert
|
||||||
from novelwriter.constants import nwKeyWords, nwUnicode
|
from novelwriter.constants import nwKeyWords, nwUnicode
|
||||||
from novelwriter.gui.doceditor import GuiDocEditor
|
from novelwriter.gui.doceditor import GuiDocEditor
|
||||||
@@ -461,19 +462,19 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd):
|
|||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteLS.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteLS.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtSQuoteOpen
|
assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteOpen
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteRS.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteRS.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtSQuoteClose
|
assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteClose
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteLD.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteLD.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtDQuoteOpen
|
assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteOpen
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsQuoteRD.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsQuoteRD.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwGUI.mainConf.fmtDQuoteClose
|
assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteClose
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsMSApos.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsMSApos.activate(QAction.Trigger)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ from PyQt5.QtGui import QFocusEvent
|
|||||||
from PyQt5.QtCore import Qt, QEvent
|
from PyQt5.QtCore import Qt, QEvent
|
||||||
from PyQt5.QtWidgets import QInputDialog, QToolTip
|
from PyQt5.QtWidgets import QInputDialog, QToolTip
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwWidget, nwItemType
|
from novelwriter.enum import nwWidget, nwItemType
|
||||||
from novelwriter.gui.noveltree import NovelTreeColumn
|
from novelwriter.gui.noveltree import NovelTreeColumn
|
||||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||||
@@ -67,14 +68,14 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
# Show/Hide Scrollbars
|
# Show/Hide Scrollbars
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
nwGUI.mainConf.hideVScroll = True
|
CONFIG.hideVScroll = True
|
||||||
nwGUI.mainConf.hideHScroll = True
|
CONFIG.hideHScroll = True
|
||||||
novelView.initSettings()
|
novelView.initSettings()
|
||||||
assert not novelTree.verticalScrollBar().isVisible()
|
assert not novelTree.verticalScrollBar().isVisible()
|
||||||
assert not novelTree.horizontalScrollBar().isVisible()
|
assert not novelTree.horizontalScrollBar().isVisible()
|
||||||
|
|
||||||
nwGUI.mainConf.hideVScroll = False
|
CONFIG.hideVScroll = False
|
||||||
nwGUI.mainConf.hideHScroll = False
|
CONFIG.hideHScroll = False
|
||||||
novelView.initSettings()
|
novelView.initSettings()
|
||||||
assert novelTree.verticalScrollBar().isEnabled()
|
assert novelTree.verticalScrollBar().isEnabled()
|
||||||
assert novelTree.horizontalScrollBar().isEnabled()
|
assert novelTree.horizontalScrollBar().isEnabled()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from tools import buildTestProject, writeFile
|
|||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QWidget, QAction
|
from PyQt5.QtWidgets import QWidget, QAction
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwItemClass, nwOutline, nwView
|
from novelwriter.enum import nwItemClass, nwOutline, nwView
|
||||||
|
|
||||||
|
|
||||||
@@ -47,16 +48,16 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, projPath):
|
|||||||
outlineMenu = outlineView.outlineBar.mColumns
|
outlineMenu = outlineView.outlineBar.mColumns
|
||||||
|
|
||||||
# Toggle scrollbars
|
# Toggle scrollbars
|
||||||
nwGUI.mainConf.hideVScroll = True
|
CONFIG.hideVScroll = True
|
||||||
nwGUI.mainConf.hideHScroll = True
|
CONFIG.hideHScroll = True
|
||||||
outlineView.initSettings()
|
outlineView.initSettings()
|
||||||
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert outlineData.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert outlineData.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert outlineData.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert outlineData.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
|
|
||||||
nwGUI.mainConf.hideVScroll = False
|
CONFIG.hideVScroll = False
|
||||||
nwGUI.mainConf.hideHScroll = False
|
CONFIG.hideHScroll = False
|
||||||
outlineView.initSettings()
|
outlineView.initSettings()
|
||||||
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from tools import C, buildTestProject
|
|||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QMessageBox, QMenu, QTreeWidgetItem, QDialog
|
from PyQt5.QtWidgets import QMessageBox, QMenu, QTreeWidgetItem, QDialog
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwItemLayout, nwItemType, nwItemClass
|
from novelwriter.enum import nwItemLayout, nwItemType, nwItemClass
|
||||||
from novelwriter.gui.projtree import GuiProjectTree
|
from novelwriter.gui.projtree import GuiProjectTree
|
||||||
from novelwriter.dialogs.docmerge import GuiDocMerge
|
from novelwriter.dialogs.docmerge import GuiDocMerge
|
||||||
@@ -862,14 +863,14 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
# Test that the scrollbar setting works
|
# Test that the scrollbar setting works
|
||||||
nwGUI.mainConf.hideVScroll = True
|
CONFIG.hideVScroll = True
|
||||||
nwGUI.mainConf.hideHScroll = True
|
CONFIG.hideHScroll = True
|
||||||
projView.initSettings()
|
projView.initSettings()
|
||||||
assert projTree.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert projTree.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert projTree.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert projTree.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
|
|
||||||
nwGUI.mainConf.hideVScroll = False
|
CONFIG.hideVScroll = False
|
||||||
nwGUI.mainConf.hideHScroll = False
|
CONFIG.hideHScroll = False
|
||||||
projView.initSettings()
|
projView.initSettings()
|
||||||
assert projTree.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert projTree.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
assert projTree.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert projTree.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import pytest
|
|||||||
|
|
||||||
from tools import C, buildTestProject
|
from tools import C, buildTestProject
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.gui.statusbar import StatusLED
|
from novelwriter.gui.statusbar import StatusLED
|
||||||
|
|
||||||
|
|
||||||
@@ -60,13 +61,13 @@ def testGuiStatusBar_Main(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
assert nwGUI.mainStatus.docIcon._theCol == nwGUI.mainStatus.docIcon._colGood
|
assert nwGUI.mainStatus.docIcon._theCol == nwGUI.mainStatus.docIcon._colGood
|
||||||
|
|
||||||
# Idle Status
|
# Idle Status
|
||||||
nwGUI.mainStatus.mainConf.stopWhenIdle = False
|
CONFIG.stopWhenIdle = False
|
||||||
nwGUI.mainStatus.setUserIdle(True)
|
nwGUI.mainStatus.setUserIdle(True)
|
||||||
nwGUI.mainStatus.updateTime()
|
nwGUI.mainStatus.updateTime()
|
||||||
assert nwGUI.mainStatus.userIdle is False
|
assert nwGUI.mainStatus.userIdle is False
|
||||||
assert nwGUI.mainStatus.timeText.text() == "00:00:00"
|
assert nwGUI.mainStatus.timeText.text() == "00:00:00"
|
||||||
|
|
||||||
nwGUI.mainStatus.mainConf.stopWhenIdle = True
|
CONFIG.stopWhenIdle = True
|
||||||
nwGUI.mainStatus.setUserIdle(True)
|
nwGUI.mainStatus.setUserIdle(True)
|
||||||
nwGUI.mainStatus.updateTime(5)
|
nwGUI.mainStatus.updateTime(5)
|
||||||
assert nwGUI.mainStatus.userIdle is True
|
assert nwGUI.mainStatus.userIdle is True
|
||||||
@@ -84,10 +85,10 @@ def testGuiStatusBar_Main(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
assert nwGUI.mainStatus.langText.text() == "American English"
|
assert nwGUI.mainStatus.langText.text() == "American English"
|
||||||
|
|
||||||
# Project Stats
|
# Project Stats
|
||||||
nwGUI.mainStatus.mainConf.incNotesWCount = False
|
CONFIG.incNotesWCount = False
|
||||||
nwGUI._updateStatusWordCount()
|
nwGUI._updateStatusWordCount()
|
||||||
assert nwGUI.mainStatus.statsText.text() == "Words: 9 (+9)"
|
assert nwGUI.mainStatus.statsText.text() == "Words: 9 (+9)"
|
||||||
nwGUI.mainStatus.mainConf.incNotesWCount = True
|
CONFIG.incNotesWCount = True
|
||||||
nwGUI._updateStatusWordCount()
|
nwGUI._updateStatusWordCount()
|
||||||
assert nwGUI.mainStatus.statsText.text() == "Words: 11 (+11)"
|
assert nwGUI.mainStatus.statsText.text() == "Words: 11 (+11)"
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from tools import ODT_IGNORE, cmpFiles, getGuiItem
|
|||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QAction, QFileDialog
|
from PyQt5.QtWidgets import QAction, QFileDialog
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from novelwriter.tools.build import GuiBuildNovel
|
from novelwriter.tools.build import GuiBuildNovel
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, prjLipsum, tstPaths):
|
|||||||
assert not nwBuild._saveDocument(nwBuild.FMT_NWD)
|
assert not nwBuild._saveDocument(nwBuild.FMT_NWD)
|
||||||
|
|
||||||
# Default Settings
|
# Default Settings
|
||||||
nwGUI.mainConf._lastPath = prjLipsum
|
CONFIG._lastPath = prjLipsum
|
||||||
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
|
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
||||||
@@ -231,7 +232,7 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, prjLipsum, tstPaths):
|
|||||||
assert (prjLipsum / "Lorem Ipsum.odt").is_file()
|
assert (prjLipsum / "Lorem Ipsum.odt").is_file()
|
||||||
|
|
||||||
# Print to PDF
|
# Print to PDF
|
||||||
if not nwGUI.mainConf.osDarwin:
|
if not CONFIG.osDarwin:
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_PDF)
|
assert nwBuild._saveDocument(nwBuild.FMT_PDF)
|
||||||
assert (prjLipsum / "Lorem Ipsum.pdf").is_file()
|
assert (prjLipsum / "Lorem Ipsum.pdf").is_file()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user