Use Ruff for linting and fix a ton of issues

This commit is contained in:
Veronica Berglyd Olsen
2025-04-03 01:15:52 +02:00
parent d2796d27c3
commit 53a2d0e691
43 changed files with 257 additions and 235 deletions
+1 -2
View File
@@ -195,8 +195,7 @@ def mockRnd(monkeypatch):
self.reset()
def _rnd(self, n):
for x in range(n):
yield x
yield from range(n)
def reset(self):
gen = self._rnd(1000)
+8 -8
View File
@@ -41,14 +41,14 @@ def testBaseSharedData_Init():
shared = SharedData()
# When not initialised, it should raise exceptions
with pytest.raises(Exception):
shared.mainGui
with pytest.raises(Exception):
shared.theme
with pytest.raises(Exception):
shared.project
with pytest.raises(Exception):
shared.spelling
with pytest.raises(RuntimeError):
_ = shared.mainGui
with pytest.raises(RuntimeError):
_ = shared.theme
with pytest.raises(RuntimeError):
_ = shared.project
with pytest.raises(RuntimeError):
_ = shared.spelling
# Create some mock objects
mockGui = MockGuiMain()
+3 -3
View File
@@ -885,9 +885,9 @@ def testCoreIndex_ExtractData(nwGUI, fncPath, mockRnd):
sHandle = project.newFile("Scene One", C.hNovelRoot)
tHandle = project.newFile("Scene Two", C.hNovelRoot)
project.tree[hHandle].itemLayout == nwItemLayout.DOCUMENT # type: ignore
project.tree[sHandle].itemLayout == nwItemLayout.DOCUMENT # type: ignore
project.tree[tHandle].itemLayout == nwItemLayout.DOCUMENT # type: ignore
assert project.tree[hHandle].itemLayout == nwItemLayout.DOCUMENT # type: ignore
assert project.tree[sHandle].itemLayout == nwItemLayout.DOCUMENT # type: ignore
assert project.tree[tHandle].itemLayout == nwItemLayout.DOCUMENT # type: ignore
assert index.scanText(hHandle, "## Chapter One\n\n") # type: ignore
assert index.scanText(sHandle, "### Scene One\n\n") # type: ignore
+22 -22
View File
@@ -74,7 +74,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
assert nwGUI.openDocument(C.hSceneDoc)
docEditor = nwGUI.docEditor
docEditor.setPlainText("### Lorem Ipsum\n\n%s" % ipsumText[0])
docEditor.setPlainText(f"### Lorem Ipsum\n\n{ipsumText[0]}")
nwGUI.saveDocument()
# Check Defaults
@@ -147,7 +147,7 @@ def testGuiEditor_LoadText(qtbot, nwGUI, projPath, ipsumText, mockRnd):
assert nwGUI.openDocument(C.hSceneDoc) is True
docEditor = nwGUI.docEditor
longText = "### Lorem Ipsum\n\n%s" % "\n\n".join(ipsumText*20)
longText = "### Lorem Ipsum\n\n{0}".format("\n\n".join(ipsumText*20))
docEditor.replaceText(longText)
nwGUI.saveDocument()
nwGUI.closeDocument()
@@ -179,7 +179,7 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
assert nwGUI.openDocument(C.hSceneDoc) is True
docEditor = nwGUI.docEditor
longText = "### Lorem Ipsum\n\n%s" % "\n\n".join(ipsumText)
longText = "### Lorem Ipsum\n\n{0}".format("\n\n".join(ipsumText))
docEditor.replaceText(longText)
# Missing item
@@ -483,7 +483,7 @@ def testGuiEditor_SpellChecking(qtbot, monkeypatch, nwGUI, projPath, ipsumText,
assert nwGUI.openDocument(C.hSceneDoc) is True
docEditor = nwGUI.docEditor
text = "### A Scene\n\n%s" % "\n\n".join(ipsumText)
text = "### A Scene\n\n{0}".format("\n\n".join(ipsumText))
docEditor.replaceText(text)
# Toggle State
@@ -584,7 +584,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
assert nwGUI.openDocument(C.hSceneDoc) is True
docEditor = nwGUI.docEditor
text = "### A Scene\n\n%s" % "\n\n".join(ipsumText)
text = "### A Scene\n\n{0}".format("\n\n".join(ipsumText))
docEditor.replaceText(text)
doc = docEditor.document()
@@ -650,7 +650,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Emphasis/Undo/Redo
# ==================
text = "### A Scene\n\n%s" % ipsumText[0]
text = f"### A Scene\n\n{ipsumText[0]}"
docEditor.replaceText(text)
# Emphasis
@@ -683,7 +683,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Shortcodes
# ==========
text = "### A Scene\n\n%s" % ipsumText[0]
text = f"### A Scene\n\n{ipsumText[0]}"
docEditor.replaceText(text)
# Italic
@@ -738,7 +738,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Quotes
# ======
text = "### A Scene\n\n%s" % ipsumText[0]
text = f"### A Scene\n\n{ipsumText[0]}"
docEditor.replaceText(text)
# Add Single Quotes
@@ -772,7 +772,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Remove Line Breaks
# ==================
text = "### A Scene\n\n%s" % ipsumText[0]
text = f"### A Scene\n\n{ipsumText[0]}"
repText = text[:100] + text[100:].replace(" ", "\n", 3)
docEditor.replaceText(repText)
assert docEditor.docAction(nwDocAction.RM_BREAKS) is True
@@ -974,7 +974,7 @@ def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd
buildTestProject(nwGUI, projPath)
assert nwGUI.openDocument(C.hSceneDoc) is True
docEditor = nwGUI.docEditor
text = "### A Scene\n\n%s" % ipsumText[0]
text = f"### A Scene\n\n{ipsumText[0]}"
# Insert Text
# ===========
@@ -1037,7 +1037,7 @@ def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd
# Insert KeyWords
# ===============
text = "### A Scene\n\n\n%s" % ipsumText[0]
text = f"### A Scene\n\n\n{ipsumText[0]}"
docEditor.replaceText(text)
docEditor.setCursorLine(3)
@@ -1076,13 +1076,13 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
assert nwGUI.openDocument(C.hSceneDoc) is True
docEditor = nwGUI.docEditor
text = "### A Scene\n\n%s" % "\n\n".join(ipsumText)
text = "### A Scene\n\n{0}".format("\n\n".join(ipsumText))
docEditor.replaceText(text)
# Wrap Selection
# ==============
text = "### A Scene\n\n%s" % "\n\n".join(ipsumText[0:2])
text = "### A Scene\n\n{0}".format("\n\n".join(ipsumText[0:2]))
docEditor.replaceText(text)
docEditor.setCursorPosition(45)
@@ -1114,7 +1114,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Toggle Format
# =============
text = "### A Scene\n\n%s" % "\n\n".join(ipsumText[0:2])
text = "### A Scene\n\n{0}".format("\n\n".join(ipsumText[0:2]))
# Block format repetition
docEditor.replaceText(text)
@@ -1186,7 +1186,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# ==============
# No Selection
text = "### A Scene\n\n%s" % ipsumText[0].replace("consectetur", "=consectetur=")
text = "### A Scene\n\n{0}".format(ipsumText[0].replace("consectetur", "=consectetur="))
docEditor.replaceText(text)
docEditor.setCursorPosition(45)
docEditor._replaceQuotes("=", "<", ">")
@@ -1194,7 +1194,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# First Paragraph Selected
# This should not replace anything in second paragraph
text = "### A Scene\n\n%s" % "\n\n".join(ipsumText[0:2]).replace("ipsum", "=ipsum=")
text = "### A Scene\n\n{0}".format("\n\n".join(ipsumText[0:2]).replace("ipsum", "=ipsum="))
docEditor.replaceText(text)
docEditor.setCursorPosition(45)
assert docEditor.docAction(nwDocAction.SEL_PARA)
@@ -1222,7 +1222,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Check Blocks
cursor = docEditor.textCursor()
cursor.clearSelection()
text = "### A Scene\n\n%s\n\n%s" % (parOne, parTwo)
text = f"### A Scene\n\n{parOne}\n\n{parTwo}"
docEditor.replaceText(text)
docEditor.setCursorPosition(45)
assert len(docEditor._selectedBlocks(cursor)) == 0
@@ -1231,15 +1231,15 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
assert len(docEditor._selectedBlocks(cursor)) == 15
# Remove All
text = "### A Scene\n\n%s\n\n%s" % (parOne, parTwo)
text = f"### A Scene\n\n{parOne}\n\n{parTwo}"
docEditor.replaceText(text)
docEditor.setCursorPosition(45)
docEditor._removeInParLineBreaks()
assert docEditor.getText() == "### A Scene\n\n%s\n" % "\n\n".join(ipsumText[0:2])
assert docEditor.getText() == "### A Scene\n\n{0}\n".format("\n\n".join(ipsumText[0:2]))
# Remove in First Paragraph
# Second paragraphs should remain unchanged
text = "### A Scene\n\n%s\n\n%s" % (parOne, parTwo)
text = f"### A Scene\n\n{parOne}\n\n{parTwo}"
docEditor.replaceText(text)
cursor = docEditor.textCursor()
cursor.setPosition(16, QtMoveAnchor)
@@ -1260,7 +1260,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Key Press Events
# ================
text = "### A Scene\n\n%s\n\n%s" % (parOne, parTwo)
text = f"### A Scene\n\n{parOne}\n\n{parTwo}"
docEditor.replaceText(text)
assert docEditor.getText() == text
@@ -1290,7 +1290,7 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText
# Invalid and Generic
# ===================
text = "### A Scene\n\n%s" % ipsumText[0]
text = f"### A Scene\n\n{ipsumText[0]}"
docEditor.replaceText(text)
# Invalid Block
+10 -10
View File
@@ -276,11 +276,11 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
# Other Checks
# Replace Quotes
docEditor.setPlainText((
docEditor.setPlainText(
"### New Text\n\n"
"Text with 'single' quotes and 'tricky stuff's'.\n\n"
"Also text with \"double\" quotes which are \"less tricky\".\n\n"
))
)
mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger)
mainMenu.aFmtReplSng.activate(QAction.ActionEvent.Trigger)
@@ -299,14 +299,14 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
)
# Remove in-paragraph line breaks
docEditor.setPlainText((
docEditor.setPlainText(
"### New Text\n\n"
"@char: Someone\n"
"@location: Somewhere\n\n"
"% Some comment ...\n\n"
"Here is some text\non multiple\nlines.\n\n"
"With another paragraph\nhere."
))
)
mainMenu.aFmtRmBreaks.activate(QAction.ActionEvent.Trigger)
assert docEditor.getText() == (
"### New Text\n\n"
@@ -317,14 +317,14 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"With another paragraph here.\n"
)
docEditor.setPlainText((
docEditor.setPlainText(
"### New Text\n\n"
"@char: Someone\n"
"@location: Somewhere\n\n"
"% Some comment ...\n\n"
"Here is some text\non multiple\nlines.\n\n"
"With another paragraph\nhere."
))
)
cursor = docEditor.textCursor()
cursor.setPosition(74)
cursor.movePosition(QtMoveRight, QtKeepAnchor, 29)
@@ -343,12 +343,12 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
assert not docEditor.docAction(nwDocAction.NO_ACTION)
# Test Invalid Formats
docEditor.setPlainText((
docEditor.setPlainText(
"### New Text\n\n"
"@tag: Bod\n\n"
"Text with 'single' quotes and 'tricky stuff's'.\n\n"
"Also text with \"double\" quotes which are \"less tricky\".\n\n"
))
)
# Cannot Format Tag
docEditor.setCursorPosition(17)
@@ -489,7 +489,7 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
# Insert Keywords
# ===============
for action, key in zip(mainMenu.mInsKeywords.actions(), nwKeyWords.ALL_KEYS):
for action, key in zip(mainMenu.mInsKeywords.actions(), nwKeyWords.ALL_KEYS, strict=False):
docEditor.setPlainText("Stuff")
action.activate(QAction.ActionEvent.Trigger)
assert docEditor.getText() == f"Stuff\n{key}: "
@@ -503,7 +503,7 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
# Insert Fields
# =============
for action, field in zip(mainMenu.mInsField.actions(), nwStats.ALL_FIELDS):
for action, field in zip(mainMenu.mInsField.actions(), nwStats.ALL_FIELDS, strict=False):
value = nwShortcode.FIELD_VALUE.format(field)
docEditor.setPlainText("Stuff ")
docEditor.setCursorPosition(6)
+16 -16
View File
@@ -86,7 +86,7 @@ def testTextCounting_standardCounter():
assert standardCounter(" <") == (0, 0, 0)
# General Text
cC, wC, pC = standardCounter((
cC, wC, pC = standardCounter(
"#! Title\n\n"
"##! Prologue\n\n"
"# Heading One\n"
@@ -100,47 +100,47 @@ def testTextCounting_standardCounter():
"The second paragraph.\n\n\n"
"The third paragraph.\n\n"
"Dashes\u2013and even longer\u2014dashes."
))
)
assert cC == 163
assert wC == 26
assert pC == 4
# Text Alignment
cC, wC, pC = standardCounter((
cC, wC, pC = standardCounter(
"# Title\n\n"
"Left aligned<<\n\n"
"Left aligned <<\n\n"
"Right indent<\n\n"
"Right indent <\n\n"
))
)
assert cC == 53
assert wC == 9
assert pC == 4
cC, wC, pC = standardCounter((
cC, wC, pC = standardCounter(
"# Title\n\n"
">>Right aligned\n\n"
">> Right aligned\n\n"
">Left indent\n\n"
"> Left indent\n\n"
))
)
assert cC == 53
assert wC == 9
assert pC == 4
cC, wC, pC = standardCounter((
cC, wC, pC = standardCounter(
"# Title\n\n"
">>Centre aligned<<\n\n"
">> Centre aligned <<\n\n"
">Double indent<\n\n"
"> Double indent <\n\n"
))
)
assert cC == 59
assert wC == 9
assert pC == 4
# Formatting Codes, Upper Case (Old Implementation)
cC, wC, pC = standardCounter((
cC, wC, pC = standardCounter(
"Some text\n\n"
"[NEWPAGE]\n\n"
"more text\n\n"
@@ -150,13 +150,13 @@ def testTextCounting_standardCounter():
"and some final text\n\n"
"[VSPACE:4]\n\n"
"THE END\n\n"
))
)
assert cC == 58
assert wC == 13
assert pC == 5
# Formatting Codes, Lower Case (Current Implementation)
cC, wC, pC = standardCounter((
cC, wC, pC = standardCounter(
"Some text\n\n"
"[newpage]\n\n"
"more text\n\n"
@@ -166,16 +166,16 @@ def testTextCounting_standardCounter():
"and some final text\n\n"
"[vspace:4]\n\n"
"THE END\n\n"
))
)
assert cC == 58
assert wC == 13
assert pC == 5
# Check ShortCodes
cC, wC, pC = standardCounter((
cC, wC, pC = standardCounter(
"Text with [b]bold[/b] text and padded [b] bold [/b] text.\n\n"
"Text with [b][i] nested [/i] emphasis [/b] in it.\n\n"
))
)
assert cC == 78
assert wC == 14
assert pC == 2
@@ -188,7 +188,7 @@ def testTextCounting_bodyTextCounter():
assert bodyTextCounter(None) == (0, 0, 0) # type: ignore
# General Text
wC, cC, sC = bodyTextCounter((
wC, cC, sC = bodyTextCounter(
"#! Title\n\n"
"##! Prologue\n\n"
"# Heading One\n"
@@ -201,7 +201,7 @@ def testTextCounting_bodyTextCounter():
"The second paragraph.\n\n\n"
"The third paragraph.\n\n"
"Dashes\u2013and even longer\u2014dashes."
))
)
assert wC == 14
assert cC == 91
assert sC == 81
+2 -2
View File
@@ -293,7 +293,7 @@ def testToolManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
obj.close()
break
else:
assert False
raise AssertionError
# Finish
manus.close()
@@ -327,7 +327,7 @@ def testToolManuscript_Print(monkeypatch, qtbot, nwGUI, projPath):
obj.close()
break
else:
assert False
raise AssertionError
# Finish
manus.close()
+57 -57
View File
@@ -121,41 +121,41 @@ def testToolWritingStats_Export(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
# Sort by time
sessLog.listBox.sortByColumn(sessLog.C_TIME, Qt.SortOrder.AscendingOrder)
assert sessLog.novelWords.text() == "{:n}".format(600)
assert sessLog.notesWords.text() == "{:n}".format(275)
assert sessLog.totalWords.text() == "{:n}".format(875)
assert sessLog.novelWords.text() == f"{600:n}"
assert sessLog.notesWords.text() == f"{275:n}"
assert sessLog.totalWords.text() == f"{875:n}"
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
assert item.text(sessLog.C_COUNT) == f"{1:n}"
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
assert item.text(sessLog.C_COUNT) == f"{-200:n}"
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
assert item.text(sessLog.C_COUNT) == f"{300:n}"
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-120)
assert item.text(sessLog.C_COUNT) == f"{-120:n}"
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
assert item.text(sessLog.C_COUNT) == f"{-20:n}"
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
assert item.text(sessLog.C_COUNT) == f"{40:n}"
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
assert item.text(sessLog.C_COUNT) == f"{-400:n}"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
assert item.text(sessLog.C_COUNT) == f"{200:n}"
assert sessLog._saveData(sessLog.FMT_CSV)
assert sessLog._saveData(sessLog.FMT_JSON)
@@ -230,35 +230,35 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
assert item.text(sessLog.C_COUNT) == f"{1:n}"
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
assert item.text(sessLog.C_COUNT) == f"{-200:n}"
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
assert item.text(sessLog.C_COUNT) == f"{300:n}"
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-120)
assert item.text(sessLog.C_COUNT) == f"{-120:n}"
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
assert item.text(sessLog.C_COUNT) == f"{-20:n}"
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
assert item.text(sessLog.C_COUNT) == f"{40:n}"
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
assert item.text(sessLog.C_COUNT) == f"{-400:n}"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
assert item.text(sessLog.C_COUNT) == f"{200:n}"
# No Novel Files
qtbot.mouseClick(sessLog.incNovel, QtMouseLeft)
@@ -270,35 +270,35 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
assert item.text(sessLog.C_COUNT) == f"{1:n}"
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-100)
assert item.text(sessLog.C_COUNT) == f"{-100:n}"
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(150)
assert item.text(sessLog.C_COUNT) == f"{150:n}"
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-60)
assert item.text(sessLog.C_COUNT) == f"{-60:n}"
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-10)
assert item.text(sessLog.C_COUNT) == f"{-10:n}"
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(20)
assert item.text(sessLog.C_COUNT) == f"{20:n}"
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
assert item.text(sessLog.C_COUNT) == f"{-200:n}"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(100)
assert item.text(sessLog.C_COUNT) == f"{100:n}"
assert jsonData == [
{
@@ -339,35 +339,35 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
assert item.text(sessLog.C_COUNT) == f"{1:n}"
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-100)
assert item.text(sessLog.C_COUNT) == f"{-100:n}"
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(150)
assert item.text(sessLog.C_COUNT) == f"{150:n}"
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-60)
assert item.text(sessLog.C_COUNT) == f"{-60:n}"
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-10)
assert item.text(sessLog.C_COUNT) == f"{-10:n}"
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(20)
assert item.text(sessLog.C_COUNT) == f"{20:n}"
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
assert item.text(sessLog.C_COUNT) == f"{-200:n}"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(100)
assert item.text(sessLog.C_COUNT) == f"{100:n}"
assert jsonData == [
{
@@ -408,19 +408,19 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
assert item.text(sessLog.C_COUNT) == f"{1:n}"
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
assert item.text(sessLog.C_COUNT) == f"{300:n}"
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
assert item.text(sessLog.C_COUNT) == f"{40:n}"
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
assert item.text(sessLog.C_COUNT) == f"{200:n}"
assert jsonData == [
{
@@ -449,43 +449,43 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
assert item.text(sessLog.C_COUNT) == f"{1:n}"
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(0)
assert item.text(sessLog.C_COUNT) == f"{0:n}"
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
assert item.text(sessLog.C_COUNT) == f"{-200:n}"
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
assert item.text(sessLog.C_COUNT) == f"{300:n}"
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-120)
assert item.text(sessLog.C_COUNT) == f"{-120:n}"
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
assert item.text(sessLog.C_COUNT) == f"{-20:n}"
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
assert item.text(sessLog.C_COUNT) == f"{40:n}"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
assert item.text(sessLog.C_COUNT) == f"{-400:n}"
item = sessLog.listBox.topLevelItem(8)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
assert item.text(sessLog.C_COUNT) == f"{200:n}"
item = sessLog.listBox.topLevelItem(9)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(0)
assert item.text(sessLog.C_COUNT) == f"{0:n}"
assert jsonData == [
{
@@ -542,35 +542,35 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
assert item.text(sessLog.C_COUNT) == f"{1:n}"
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
assert item.text(sessLog.C_COUNT) == f"{-200:n}"
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(180)
assert item.text(sessLog.C_COUNT) == f"{180:n}"
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
assert item.text(sessLog.C_COUNT) == f"{-20:n}"
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
assert item.text(sessLog.C_COUNT) == f"{40:n}"
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
assert item.text(sessLog.C_COUNT) == f"{-400:n}"
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
assert item.text(sessLog.C_COUNT) == f"{200:n}"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(0)
assert item.text(sessLog.C_COUNT) == f"{0:n}"
assert jsonData == [
{
+7 -7
View File
@@ -97,18 +97,18 @@ def cmpFiles(
lnTwo = txtTwo[n].strip()
if n+1 in ignoreLines:
print("Ignoring line %d" % (n+1))
print(f"Ignoring line {n+1}")
continue
if ignoreStart is not None:
if lnOne.startswith(ignoreStart):
print("Ignoring line %d" % (n+1))
print(f"Ignoring line {n+1}")
continue
if lnOne != lnTwo:
print("Diff on line %d:" % (n+1))
print(" << '%s'" % lnOne)
print(" >> '%s'" % lnTwo)
print(f"Diff on line {n+1}:")
print(f" << '{lnOne}'")
print(f" >> '{lnTwo}'")
diffFound = True
return not diffFound
@@ -205,11 +205,11 @@ def buildTestProject(obj: object, projPath: Path) -> None:
project.index.reIndexHandle(tdHandle)
aDoc = project.storage.getDocument(cdHandle)
aDoc.writeDocument("## %s\n\n" % project.tr("New Chapter"))
aDoc.writeDocument("## {0}\n\n".format(project.tr("New Chapter")))
project.index.reIndexHandle(cdHandle)
aDoc = project.storage.getDocument(sdHandle)
aDoc.writeDocument("### %s\n\n" % project.tr("New Scene"))
aDoc.writeDocument("### {0}\n\n".format(project.tr("New Scene")))
project.index.reIndexHandle(sdHandle)
project.session.startSession()