Adds: references tests, corrects bugs

This commit is contained in:
Olivier Keshavjee 2017-11-20 15:42:30 +01:00
parent 7db2848474
commit 9d3b64de8f
10 changed files with 265 additions and 80 deletions

View file

@ -14,11 +14,11 @@ from manuskript.version import getVersion
faulthandler.enable()
def prepare():
def prepare(tests=False):
app = QApplication(sys.argv)
app.setOrganizationName("manuskript")
app.setOrganizationName("manuskript"+"_tests" if tests else "")
app.setOrganizationDomain("www.theologeek.ch")
app.setApplicationName("manuskript")
app.setApplicationName("manuskript"+"_tests" if tests else "")
app.setApplicationVersion(getVersion())
print("Running manuskript version {}.".format(getVersion()))

View file

@ -10,7 +10,7 @@ from PyQt5.QtWidgets import QMainWindow, QHeaderView, qApp, QMenu, QActionGroup,
from manuskript import settings
from manuskript.enums import Character, PlotStep, Plot, World, Outline
from manuskript.functions import AUC, wordCount, appPath, findWidgetsOfClass
from manuskript.functions import wordCount, appPath, findWidgetsOfClass
import manuskript.functions as F
from manuskript import loadSave
from manuskript.models.characterModel import characterModel
@ -57,6 +57,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# Var
self.currentProject = None
self._lastFocus = None
self._defaultCursorFlashTime = 1000 # Overriden at startup with system
# value. In manuskript.main.
self.readSettings()
@ -745,20 +747,20 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def makeUIConnections(self):
"Connections that have to be made once only, even when a new project is loaded."
self.lstCharacters.currentItemChanged.connect(self.changeCurrentCharacter, AUC)
self.lstCharacters.currentItemChanged.connect(self.changeCurrentCharacter, F.AUC)
self.txtPlotFilter.textChanged.connect(self.lstPlots.setFilter, AUC)
self.lstPlots.currentItemChanged.connect(self.changeCurrentPlot, AUC)
self.txtPlotFilter.textChanged.connect(self.lstPlots.setFilter, F.AUC)
self.lstPlots.currentItemChanged.connect(self.changeCurrentPlot, F.AUC)
self.txtSubPlotSummary.document().contentsChanged.connect(
self.updateSubPlotSummary, AUC)
self.lstSubPlots.clicked.connect(self.changeCurrentSubPlot, AUC)
self.updateSubPlotSummary, F.AUC)
self.lstSubPlots.clicked.connect(self.changeCurrentSubPlot, F.AUC)
self.btnRedacAddFolder.clicked.connect(self.treeRedacOutline.addFolder, AUC)
self.btnOutlineAddFolder.clicked.connect(self.treeOutlineOutline.addFolder, AUC)
self.btnRedacAddText.clicked.connect(self.treeRedacOutline.addText, AUC)
self.btnOutlineAddText.clicked.connect(self.treeOutlineOutline.addText, AUC)
self.btnRedacRemoveItem.clicked.connect(self.outlineRemoveItemsRedac, AUC)
self.btnOutlineRemoveItem.clicked.connect(self.outlineRemoveItemsOutline, AUC)
self.btnRedacAddFolder.clicked.connect(self.treeRedacOutline.addFolder, F.AUC)
self.btnOutlineAddFolder.clicked.connect(self.treeOutlineOutline.addFolder, F.AUC)
self.btnRedacAddText.clicked.connect(self.treeRedacOutline.addText, F.AUC)
self.btnOutlineAddText.clicked.connect(self.treeOutlineOutline.addText, F.AUC)
self.btnRedacRemoveItem.clicked.connect(self.outlineRemoveItemsRedac, F.AUC)
self.btnOutlineRemoveItem.clicked.connect(self.outlineRemoveItemsOutline, F.AUC)
self.tabMain.currentChanged.connect(self.toolbar.setCurrentGroup)
self.tabMain.currentChanged.connect(self.tabMainChanged)
@ -803,12 +805,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.lstCharacters.setCharactersModel(self.mdlCharacter)
self.tblPersoInfos.setModel(self.mdlCharacter)
self.btnAddPerso.clicked.connect(self.mdlCharacter.addCharacter, AUC)
self.btnAddPerso.clicked.connect(self.mdlCharacter.addCharacter, F.AUC)
try:
self.btnRmPerso.clicked.connect(self.lstCharacters.removeCharacter, AUC)
self.btnPersoColor.clicked.connect(self.lstCharacters.choseCharacterColor, AUC)
self.btnPersoAddInfo.clicked.connect(self.lstCharacters.addCharacterInfo, AUC)
self.btnPersoRmInfo.clicked.connect(self.lstCharacters.removeCharacterInfo, AUC)
self.btnRmPerso.clicked.connect(self.lstCharacters.removeCharacter, F.AUC)
self.btnPersoColor.clicked.connect(self.lstCharacters.choseCharacterColor, F.AUC)
self.btnPersoAddInfo.clicked.connect(self.lstCharacters.addCharacterInfo, F.AUC)
self.btnPersoRmInfo.clicked.connect(self.lstCharacters.removeCharacterInfo, F.AUC)
except TypeError:
# Connection has already been made
pass
@ -834,15 +836,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.lstPlotPerso.setModel(self.mdlPlots)
self.lstPlots.setPlotModel(self.mdlPlots)
self._updatingSubPlot = False
self.btnAddPlot.clicked.connect(self.mdlPlots.addPlot, AUC)
self.btnAddPlot.clicked.connect(self.mdlPlots.addPlot, F.AUC)
self.btnRmPlot.clicked.connect(lambda:
self.mdlPlots.removePlot(self.lstPlots.currentPlotIndex()), AUC)
self.btnAddSubPlot.clicked.connect(self.mdlPlots.addSubPlot, AUC)
self.btnAddSubPlot.clicked.connect(self.updateSubPlotView, AUC)
self.btnRmSubPlot.clicked.connect(self.mdlPlots.removeSubPlot, AUC)
self.mdlPlots.removePlot(self.lstPlots.currentPlotIndex()), F.AUC)
self.btnAddSubPlot.clicked.connect(self.mdlPlots.addSubPlot, F.AUC)
self.btnAddSubPlot.clicked.connect(self.updateSubPlotView, F.AUC)
self.btnRmSubPlot.clicked.connect(self.mdlPlots.removeSubPlot, F.AUC)
self.lstPlotPerso.selectionModel().selectionChanged.connect(self.plotPersoSelectionChanged)
self.btnRmPlotPerso.clicked.connect(self.mdlPlots.removePlotPerso, AUC)
self.lstSubPlots.selectionModel().currentRowChanged.connect(self.changeCurrentSubPlot, AUC)
self.btnRmPlotPerso.clicked.connect(self.mdlPlots.removePlotPerso, F.AUC)
self.lstSubPlots.selectionModel().currentRowChanged.connect(self.changeCurrentSubPlot, F.AUC)
for w, c in [
(self.txtPlotName, Plot.name),
@ -869,9 +871,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.treeWorld.hideColumn(i)
self.treeWorld.showColumn(0)
self.btnWorldEmptyData.setMenu(self.mdlWorld.emptyDataMenu())
self.treeWorld.selectionModel().selectionChanged.connect(self.changeCurrentWorld, AUC)
self.btnAddWorld.clicked.connect(self.mdlWorld.addItem, AUC)
self.btnRmWorld.clicked.connect(self.mdlWorld.removeItem, AUC)
self.treeWorld.selectionModel().selectionChanged.connect(self.changeCurrentWorld, F.AUC)
self.btnAddWorld.clicked.connect(self.mdlWorld.addItem, F.AUC)
self.btnRmWorld.clicked.connect(self.mdlWorld.removeItem, F.AUC)
for w, c in [
(self.txtWorldName, World.name),
(self.txtWorldDescription, World.description),
@ -898,14 +900,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# self.redacEditor.setModel(self.mdlOutline)
self.storylineView.setModels(self.mdlOutline, self.mdlCharacter, self.mdlPlots)
self.treeOutlineOutline.selectionModel().selectionChanged.connect(self.outlineItemEditor.selectionChanged, AUC)
self.treeOutlineOutline.clicked.connect(self.outlineItemEditor.selectionChanged, AUC)
self.treeOutlineOutline.selectionModel().selectionChanged.connect(self.outlineItemEditor.selectionChanged, F.AUC)
self.treeOutlineOutline.clicked.connect(self.outlineItemEditor.selectionChanged, F.AUC)
# Sync selection
self.treeRedacOutline.selectionModel().selectionChanged.connect(self.redacMetadata.selectionChanged, AUC)
self.treeRedacOutline.clicked.connect(self.redacMetadata.selectionChanged, AUC)
self.treeRedacOutline.selectionModel().selectionChanged.connect(self.redacMetadata.selectionChanged, F.AUC)
self.treeRedacOutline.clicked.connect(self.redacMetadata.selectionChanged, F.AUC)
self.treeRedacOutline.selectionModel().selectionChanged.connect(self.mainEditor.selectionChanged, AUC)
self.treeRedacOutline.selectionModel().selectionChanged.connect(self.mainEditor.selectionChanged, F.AUC)
# Cheat Sheet
self.cheatSheet.setModels()
@ -918,7 +920,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.tblDebugPersos.selectionModel().currentChanged.connect(
lambda: self.tblDebugPersosInfos.setRootIndex(self.mdlCharacter.index(
self.tblDebugPersos.selectionModel().currentIndex().row(),
Character.name)), AUC)
Character.name)), F.AUC)
self.tblDebugPlots.setModel(self.mdlPlots)
self.tblDebugPlotsPersos.setModel(self.mdlPlots)
@ -926,11 +928,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.tblDebugPlots.selectionModel().currentChanged.connect(
lambda: self.tblDebugPlotsPersos.setRootIndex(self.mdlPlots.index(
self.tblDebugPlots.selectionModel().currentIndex().row(),
Plot.characters)), AUC)
Plot.characters)), F.AUC)
self.tblDebugPlots.selectionModel().currentChanged.connect(
lambda: self.tblDebugSubPlots.setRootIndex(self.mdlPlots.index(
self.tblDebugPlots.selectionModel().currentIndex().row(),
Plot.steps)), AUC)
Plot.steps)), F.AUC)
self.treeDebugWorld.setModel(self.mdlWorld)
self.treeDebugOutline.setModel(self.mdlOutline)
self.lstDebugLabels.setModel(self.mdlLabels)
@ -1173,7 +1175,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
for widget, text, pos in references:
label = helpLabel(text, self)
self.actShowHelp.toggled.connect(label.setVisible, AUC)
self.actShowHelp.toggled.connect(label.setVisible, F.AUC)
widget.layout().insertWidget(pos, label)
self.actShowHelp.setChecked(False)
@ -1185,17 +1187,17 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.updateMenuDict()
self.menuTools.addMenu(self.menuDict)
self.actSpellcheck.toggled.connect(self.toggleSpellcheck, AUC)
self.dictChanged.connect(self.mainEditor.setDict, AUC)
self.dictChanged.connect(self.redacMetadata.setDict, AUC)
self.dictChanged.connect(self.outlineItemEditor.setDict, AUC)
self.actSpellcheck.toggled.connect(self.toggleSpellcheck, F.AUC)
self.dictChanged.connect(self.mainEditor.setDict, F.AUC)
self.dictChanged.connect(self.redacMetadata.setDict, F.AUC)
self.dictChanged.connect(self.outlineItemEditor.setDict, F.AUC)
else:
# No Spell check support
self.actSpellcheck.setVisible(False)
a = QAction(self.tr("Install PyEnchant to use spellcheck"), self)
a.setIcon(self.style().standardIcon(QStyle.SP_MessageBoxWarning))
a.triggered.connect(self.openPyEnchantWebPage, AUC)
a.triggered.connect(self.openPyEnchantWebPage, F.AUC)
self.menuTools.addAction(a)
###############################################################################
@ -1215,7 +1217,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
settings.dict = enchant.get_default_language()
if str(i[0]) == settings.dict:
a.setChecked(True)
a.triggered.connect(self.setDictionary, AUC)
a.triggered.connect(self.setDictionary, F.AUC)
self.menuDictGroup.addAction(a)
self.menuDict.addAction(a)
@ -1334,7 +1336,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
a.setData("{},{},{}".format(mnud, sd, vd))
if settings.viewSettings[mnud][sd] == vd:
a.setChecked(True)
a.triggered.connect(self.setViewSettingsAction, AUC)
a.triggered.connect(self.setViewSettingsAction, F.AUC)
agp.addAction(a)
m2.addAction(a)
m.addMenu(m2)

View file

@ -296,4 +296,4 @@ class CharacterInfo():
def __init__(self, character, description="", value=""):
self.description = description
self.value = value
self.character = character
self.character = character

View file

@ -187,6 +187,9 @@ def infos(ref):
elif _type == CharacterLetter:
m = mainWindow().mdlCharacter
c = m.getCharacterByID(int(_ref))
if c is None:
return qApp.translate("references", "Unknown reference: {}.").format(ref)
index = c.index()
name = c.name()
@ -267,6 +270,9 @@ def infos(ref):
index = m.getIndexFromID(_ref)
name = m.getPlotNameByID(_ref)
if not index.isValid():
return qApp.translate("references", "Unknown reference: {}.").format(ref)
# Titles
descriptionTitle = qApp.translate("references", "Description")
resultTitle = qApp.translate("references", "Result")
@ -343,6 +349,9 @@ def infos(ref):
index = m.indexByID(_ref)
name = m.name(index)
if not index.isValid():
return qApp.translate("references", "Unknown reference: {}.").format(ref)
# Titles
descriptionTitle = qApp.translate("references", "Description")
passionTitle = qApp.translate("references", "Passion")
@ -532,7 +541,9 @@ def refToLink(ref):
elif _type == CharacterLetter:
m = mainWindow().mdlCharacter
text = m.getCharacterByID(int(_ref)).name()
c = m.getCharacterByID(int(_ref))
if c:
text = c.name()
elif _type == PlotLetter:
m = mainWindow().mdlPlots
@ -540,7 +551,9 @@ def refToLink(ref):
elif _type == WorldLetter:
m = mainWindow().mdlWorld
text = m.itemByID(_ref).text()
item = m.itemByID(_ref)
if item:
text = item.text()
if text:
return "<a href='{ref}'>{text}</a>".format(
@ -549,12 +562,10 @@ def refToLink(ref):
else:
return ref
def linkifyAllRefs(text):
"""Takes all the references in ``text`` and transform them into HMTL links."""
return re.sub(RegEx, lambda m: refToLink(m.group(0)), text)
def findReferencesTo(ref, parent=None, recursive=True):
"""List of text items containing references ref, and returns IDs.
Starts from item parent. If None, starts from root."""
@ -591,7 +602,6 @@ def listReferences(ref, title=qApp.translate("references", "Referenced in:")):
title=title,
ref=listRefs) if listRefs else ""
def basicFormat(text):
if not text:
return ""
@ -599,7 +609,6 @@ def basicFormat(text):
text = linkifyAllRefs(text)
return text
def open(ref):
"""Identify ``ref`` and open it."""
match = re.fullmatch(RegEx, ref)

View file

@ -3,19 +3,39 @@
"""Tests."""
import pytest
# METHOD 1
# ========
# Don't know why, this causes seg fault on SemaphoreCI
# Seg fault in app = QApplication(...)
# Workaround: create and discard an app first...
from PyQt5.QtWidgets import QApplication
QApplication([])
## Don't know why, this causes seg fault on SemaphoreCI
## Seg fault in app = QApplication(...)
# from manuskript import main
# app, MW = main.prepare()
# Create app and mainWindow
from manuskript import main
app, MW = main.prepare(tests=True)
# FIXME: Again, don't know why, but when closing a project and then reopening
# one, we get a `TypeError: connection is not unique` in MainWindow:
# self.btnAddSubPlot.clicked.connect(self.updateSubPlotView, F.AUC)
# Yet the disconnectAll() function has been called.
# Workaround: we remove the necessity for connection to be unique. This
# works for now, but could create issues later one when we want to tests
# those specific functionnality. Maybe it will be called several times.
# At that moment, we will need to catch the exception in the MainWindow,
# or better: understand why it happens at all, and only on some signals.
from manuskript import functions as F
from PyQt5.QtCore import Qt
F.AUC = Qt.AutoConnection
# METHOD 2
# ========
# We need a qApplication to be running, or all the calls to qApp
# will throw a seg fault.
from PyQt5.QtWidgets import QApplication
app = QApplication([])
app.setOrganizationName("manuskript_tests")
app.setApplicationName("manuskript_tests")
# from PyQt5.QtWidgets import QApplication
# app = QApplication([])
# app.setOrganizationName("manuskript_tests")
# app.setApplicationName("manuskript_tests")
from manuskript.mainWindow import MainWindow
MW = MainWindow()
# from manuskript.mainWindow import MainWindow
# MW = MainWindow()

View file

@ -5,21 +5,60 @@
import pytest
@pytest.fixture(scope='session', autouse=True)
def MWEmptyProject():
@pytest.fixture
def MW():
"""
Sets the mainWindow to load an empty project.
Returns the mainWindow
"""
from manuskript.functions import mainWindow
MW = mainWindow()
import tempfile
tf = tempfile.NamedTemporaryFile(suffix=".msk")
MW.welcome.createFile(tf.name, overwrite=True)
assert MW.currentProject is not None
from manuskript import functions as F
MW = F.mainWindow()
assert MW is not None
assert MW == F.MW
return MW
@pytest.fixture
def MWEmptyProject(MW):
"""
Creates a MainWindow and load an empty project.
"""
import tempfile
tf = tempfile.NamedTemporaryFile(suffix=".msk")
MW.closeProject()
assert MW.currentProject is None
MW.welcome.createFile(tf.name, overwrite=True)
assert MW.currentProject is not None
return MW
# If using with: @pytest.fixture(scope='session', autouse=True)
# yield MW
# # Properly destructed after. Otherwise: seg fault.
# MW.deleteLater()
@pytest.fixture
def MWSampleProject(MW):
"""
Creates a MainWindow and load a copy of the Acts sample project.
"""
from manuskript import functions as F
import os
# Get the path of the first sample project. We assume it is here.
spDir = F.appPath("sample-projects")
lst = os.listdir(spDir)
# We assume it's saved in folder, so there is a `name.msk` file and a
# `name` folder.
src = [f for f in lst if f[-4:] == ".msk" and f[:-4] in lst][0]
src = os.path.join(spDir, src)
# Copy to a temp file
import tempfile
tf = tempfile.NamedTemporaryFile(suffix=".msk")
import shutil
shutil.copyfile(src, tf.name)
shutil.copytree(src[:-4], tf.name[:-4])
MW.closeProject()
MW.loadProject(tf.name)
assert MW.currentProject is not None
return MW

View file

@ -4,7 +4,6 @@
"""Conf for models."""
import pytest
from manuskript.models import outlineModel, outlineItem
@pytest.fixture
def outlineModelBasic(MWEmptyProject):
@ -13,6 +12,7 @@ def outlineModelBasic(MWEmptyProject):
* Text
* Text
"""
from manuskript.models import outlineItem
mdl = MWEmptyProject.mdlOutline
root = mdl.rootItem

View file

@ -5,16 +5,17 @@
import pytest
from manuskript.models import outlineItem
@pytest.fixture
def outlineItemFolder():
'''Returns a folder outlineItem title "Folder".'''
from manuskript.models import outlineItem
return outlineItem(title="Folder")
@pytest.fixture
def outlineItemText():
'''Returns a text outlineItem title "Text".'''
from manuskript.models import outlineItem
return outlineItem(title="Text", _type="md")
def test_outlineItemsProperties(outlineItemFolder, outlineItemText):
@ -158,6 +159,3 @@ def test_modelStuff(outlineModelBasic):
assert text3.ID() == "0"
root.checkIDs()
assert text3.ID() != "0"
#TODO: copy (with children), IDs check, childcountrecursive
# (cf. abstractItem)

View file

@ -0,0 +1,116 @@
#!/usr/bin/env python
# --!-- coding: utf8 --!--
"""Tests for references.py"""
import pytest
def test_references(MWSampleProject):
"""
Tests references using sample project.
"""
from manuskript.models import references as Ref
MW = MWSampleProject
# References
ref1 = Ref.plotReference("42", searchable=True)
ref2 = Ref.plotReference("42")
assert ref1 in ref2
ref1 = Ref.characterReference("42", searchable=True)
ref2 = Ref.characterReference("42")
assert ref1 in ref2
ref1 = Ref.textReference("42", searchable=True)
ref2 = Ref.textReference("42")
assert ref1 in ref2
ref1 = Ref.worldReference("42", searchable=True)
ref2 = Ref.worldReference("42")
assert ref1 in ref2
# Plots
mdlPlots = MW.mdlPlots
plotsImp = mdlPlots.getPlotsByImportance()
plots = []
[plots.extend(i) for i in plotsImp]
assert len(plots) == 3
plotID = plots[0]
assert "\n" in Ref.infos(Ref.plotReference(plotID))
assert "Not a ref" in Ref.infos("<invalid>")
assert "Unknown" in Ref.infos(Ref.plotReference("999"))
assert Ref.shortInfos(Ref.plotReference(plotID)) is not None
assert Ref.shortInfos(Ref.plotReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
# Character
mdlChar = MW.mdlCharacter
IDs = [mdlChar.ID(r) for r in range(mdlChar.rowCount())]
assert len(IDs) == 6 # Peter, Paul, Philip, Stephen, Barnabas, Herod
charID = IDs[0]
assert "\n" in Ref.infos(Ref.characterReference(charID))
assert "Unknown" in Ref.infos(Ref.characterReference("999"))
assert Ref.shortInfos(Ref.characterReference(charID)) is not None
assert Ref.shortInfos(Ref.characterReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
# Texts
mdlOutline = MW.mdlOutline
assert mdlOutline.rowCount() == 3 # Jerusalem, Samaria, Extremities
root = mdlOutline.rootItem
textID = root.child(0).ID()
assert "\n" in Ref.infos(Ref.textReference(textID))
assert "Unknown" in Ref.infos(Ref.textReference("999"))
assert Ref.shortInfos(Ref.textReference(textID)) is not None
assert Ref.shortInfos(Ref.textReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
# World
mdlWorld = MW.mdlWorld
assert mdlWorld.rowCount() == 3 # Places, Culture, Travel
worldID = mdlWorld.itemID(mdlWorld.item(2).child(1))
assert "\n" in Ref.infos(Ref.worldReference(worldID))
assert "Unknown" in Ref.infos(Ref.worldReference("999"))
assert Ref.shortInfos(Ref.worldReference(worldID)) is not None
assert Ref.shortInfos(Ref.worldReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
refs = [Ref.plotReference(plotID),
Ref.characterReference(charID),
Ref.textReference(textID),
Ref.worldReference(worldID),]
# Titles
for ref in refs:
assert Ref.title(ref) is not None
assert Ref.title("<invalid>") is None
assert Ref.title(Ref.plotReference("999")) is None
# Other stuff
assert Ref.type(Ref.plotReference(plotID)) == Ref.PlotLetter
assert Ref.ID(Ref.textReference(textID)) == textID
assert "Unknown" in Ref.tooltip(Ref.worldReference("999"))
assert "Not a ref" in Ref.tooltip("<invalid>")
for ref in refs:
assert Ref.tooltip(ref) is not None
# Links
assert Ref.refToLink("<invalid>") is None
assert Ref.refToLink(Ref.plotReference("999")) == Ref.plotReference("999")
assert Ref.refToLink(Ref.characterReference("999")) == Ref.characterReference("999")
assert Ref.refToLink(Ref.textReference("999")) == Ref.textReference("999")
assert Ref.refToLink(Ref.worldReference("999")) == Ref.worldReference("999")
for ref in refs:
assert "<a href" in Ref.refToLink(ref)
# Open
assert Ref.open("<invalid>") is None
assert Ref.open(Ref.plotReference("999")) == False
assert Ref.open(Ref.characterReference("999")) == False
assert Ref.open(Ref.textReference("999")) == False
assert Ref.open(Ref.worldReference("999")) == False
for ref in refs:
assert Ref.open(ref) == True
assert Ref.open(Ref.EmptyRef.format("Z", 14, "")) == False

View file

@ -85,7 +85,7 @@ def test_paths():
def test_mainWindow():
from PyQt5.QtWidgets import QWidget
from PyQt5.QtWidgets import QWidget, QLCDNumber
assert F.mainWindow() is not None
assert F.MW is not None
@ -93,3 +93,4 @@ def test_mainWindow():
F.statusMessage("Test")
F.printObjects()
assert len(F.findWidgetsOfClass(QWidget)) > 0
assert len(F.findWidgetsOfClass(QLCDNumber)) == 0