diff --git a/novelWriter.py b/novelWriter.py index 2cfee6e4..17e40a09 100755 --- a/novelWriter.py +++ b/novelWriter.py @@ -7,9 +7,9 @@ import os import sys try: - import PyQt5.QtWidgets # noqa: F401 - import PyQt5.QtGui # noqa: F401 - import PyQt5.QtCore # noqa: F401 + import PyQt5.QtWidgets # noqa: F401 + import PyQt5.QtGui # noqa: F401 + import PyQt5.QtCore # noqa: F401 except Exception: print("ERROR: Failed to load dependency PyQt5") sys.exit(1) diff --git a/nw/__init__.py b/nw/__init__.py index d1562e5c..cc126822 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -233,7 +233,7 @@ def main(sysArgs=None): errorCode |= 16 try: - import lxml # noqa: F401 + import lxml # noqa: F401 except ImportError: errorData.append("Python module 'lxml' is missing.") errorCode |= 32 diff --git a/nw/common.py b/nw/common.py index 26017ee0..3def0edd 100644 --- a/nw/common.py +++ b/nw/common.py @@ -262,43 +262,43 @@ def fuzzyTime(secDiff): return QCoreApplication.translate( "Common", "a minute ago" ) - elif secDiff < 3300: # 55 minutes + elif secDiff < 3300: # 55 minutes return QCoreApplication.translate( "Common", "{0} minutes ago" ).format(int(round(secDiff/60))) - elif secDiff < 5400: # 90 minutes + elif secDiff < 5400: # 90 minutes return QCoreApplication.translate( "Common", "an hour ago" ) - elif secDiff < 84600: # 23.5 hours + elif secDiff < 84600: # 23.5 hours return QCoreApplication.translate( "Common", "{0} hours ago" ).format(int(round(secDiff/3600))) - elif secDiff < 129600: # 1.5 days + elif secDiff < 129600: # 1.5 days return QCoreApplication.translate( "Common", "a day ago" ) - elif secDiff < 561600: # 6.5 days + elif secDiff < 561600: # 6.5 days return QCoreApplication.translate( "Common", "{0} days ago" ).format(int(round(secDiff/86400))) - elif secDiff < 907200: # 10.5 days + elif secDiff < 907200: # 10.5 days return QCoreApplication.translate( "Common", "a week ago" ) - elif secDiff < 2419200: # 28 days + elif secDiff < 2419200: # 28 days return QCoreApplication.translate( "Common", "{0} weeks ago" ).format(int(round(secDiff/604800))) - elif secDiff < 3888000: # 45 days + elif secDiff < 3888000: # 45 days return QCoreApplication.translate( "Common", "a month ago" ) - elif secDiff < 29808000: # 345 days + elif secDiff < 29808000: # 345 days return QCoreApplication.translate( "Common", "{0} months ago" ).format(int(round(secDiff/2592000))) - elif secDiff < 47336400: # 1.5 years + elif secDiff < 47336400: # 1.5 years return QCoreApplication.translate( "Common", "a year ago" ) diff --git a/nw/config.py b/nw/config.py index f27b4eb6..d7cb9514 100644 --- a/nw/config.py +++ b/nw/config.py @@ -82,18 +82,18 @@ class Config: self.helpPath = None # The full path to the novelwriter .qhc help file # Runtime Settings and Variables - self.confChanged = False # True whenever the config has chenged, false after save - self.hasHelp = False # True if the Qt help files are present in the assets folder + self.confChanged = False # True whenever the config has chenged, false after save + self.hasHelp = False # True if the Qt help files are present in the assets folder # General self.guiTheme = "default" self.guiSyntax = "default_light" self.guiIcons = "typicons_colour_light" - self.guiDark = False # Load icons for dark backgrounds, if available - self.guiFont = "" # Defaults to system default font - self.guiFontSize = 11 # Is overridden if system default is loaded - self.guiScale = 1.0 # Set automatically by Theme class - self.lastNotes = "0x0" # The latest release notes that have been shown + self.guiDark = False # Load icons for dark backgrounds, if available + self.guiFont = "" # Defaults to system default font + self.guiFontSize = 11 # Is overridden if system default is loaded + self.guiScale = 1.0 # Set automatically by Theme class + self.lastNotes = "0x0" # The latest release notes that have been shown # Localisation self.qLocal = QLocale.system() @@ -115,51 +115,51 @@ class Config: self.isFullScreen = False # Features - self.hideVScroll = False # Hide vertical scroll bars on main widgets - self.hideHScroll = False # Hide horizontal scroll bars on main widgets + self.hideVScroll = False # Hide vertical scroll bars on main widgets + self.hideHScroll = False # Hide horizontal scroll bars on main widgets # Project - self.autoSaveProj = 60 # Interval for auto-saving project in seconds - self.autoSaveDoc = 30 # Interval for auto-saving document in seconds + self.autoSaveProj = 60 # Interval for auto-saving project in seconds + self.autoSaveDoc = 30 # Interval for auto-saving document in seconds # Text Editor - self.textFont = None # Editor font - self.textSize = 12 # Editor font size - self.textFixedW = True # Keep editor text fixed width - self.textWidth = 600 # Editor text width - self.textMargin = 40 # Editor/viewer text margin - self.tabWidth = 40 # Editor tabulator width + self.textFont = None # Editor font + self.textSize = 12 # Editor font size + self.textFixedW = True # Keep editor text fixed width + self.textWidth = 600 # Editor text width + self.textMargin = 40 # Editor/viewer text margin + self.tabWidth = 40 # Editor tabulator width - self.focusWidth = 800 # Focus Mode text width - self.hideFocusFooter = False # Hide document footer in Focus Mode - self.showFullPath = True # Show full document path in editor header - self.autoSelect = True # Auto-select word when applying format with no selection + self.focusWidth = 800 # Focus Mode text width + self.hideFocusFooter = False # Hide document footer in Focus Mode + self.showFullPath = True # Show full document path in editor header + self.autoSelect = True # Auto-select word when applying format with no selection - self.doJustify = False # Justify text - self.showTabsNSpaces = False # Show tabs and spaces in edior - self.showLineEndings = False # Show line endings in editor - self.showMultiSpaces = True # Highlight multiple spaces in the text + self.doJustify = False # Justify text + self.showTabsNSpaces = False # Show tabs and spaces in edior + self.showLineEndings = False # Show line endings in editor + self.showMultiSpaces = True # Highlight multiple spaces in the text - self.doReplace = True # Enable auto-replace as you type - self.doReplaceSQuote = True # Smart single quotes - self.doReplaceDQuote = True # Smart double quotes - self.doReplaceDash = True # Replace multiple hyphens with dashes - self.doReplaceDots = True # Replace three dots with ellipsis + self.doReplace = True # Enable auto-replace as you type + self.doReplaceSQuote = True # Smart single quotes + self.doReplaceDQuote = True # Smart double quotes + self.doReplaceDash = True # Replace multiple hyphens with dashes + self.doReplaceDots = True # Replace three dots with ellipsis - self.scrollPastEnd = True # Allow scrolling past end of document - self.autoScroll = False # Typewriter-like scrolling - self.autoScrollPos = 30 # Start point for typewriter-like scrolling + self.scrollPastEnd = True # Allow scrolling past end of document + self.autoScroll = False # Typewriter-like scrolling + self.autoScrollPos = 30 # Start point for typewriter-like scrolling - self.wordCountTimer = 5.0 # Interval for word count update in seconds - self.bigDocLimit = 800 # Size threshold for heavy editor features in kilobytes + self.wordCountTimer = 5.0 # Interval for word count update in seconds + self.bigDocLimit = 800 # Size threshold for heavy editor features in kilobytes - self.highlightQuotes = True # Highlight text in quotes - self.allowOpenSQuote = False # Allow open-ended single quotes - self.allowOpenDQuote = True # Allow open-ended double quotes - self.highlightEmph = True # Add colour to text emphasis + self.highlightQuotes = True # Highlight text in quotes + self.allowOpenSQuote = False # Allow open-ended single quotes + self.allowOpenDQuote = True # Allow open-ended double quotes + self.highlightEmph = True # Add colour to text emphasis - self.stopWhenIdle = True # Stop the status bar clock when the user is idle - self.userIdleTime = 300 # Time of inactivity to consider user idle + self.stopWhenIdle = True # Stop the status bar clock when the user is idle + self.userIdleTime = 300 # Time of inactivity to consider user idle # User-Selected Symbols self.fmtApostrophe = nwUnicode.U_RSQUO @@ -235,8 +235,8 @@ class Config: self.kernelVer = "Unknown" # Packages - self.hasEnchant = False # The pyenchant package - self.hasAssistant = False # The Qt Assistant executable + self.hasEnchant = False # The pyenchant package + self.hasAssistant = False # The Qt Assistant executable # Recent Cache self.recentProj = {} @@ -382,9 +382,9 @@ class Config: self.qtTrans = {} langList = [ - (self.qtLangPath, "qtbase"), # Qt 5.x - (self.nwLangPath, "qtbase"), # Alternative Qt 5.x - (self.nwLangPath, "nw"), # novelWriter + (self.qtLangPath, "qtbase"), # Qt 5.x + (self.nwLangPath, "qtbase"), # Alternative Qt 5.x + (self.nwLangPath, "nw"), # novelWriter ] for lngPath, lngBase in langList: for lngCode in self.qLocal.uiLanguages(): @@ -1119,7 +1119,7 @@ class Config: """Cheks if we have the optional packages used by some features. """ try: - import enchant # noqa: F401 + import enchant # noqa: F401 self.hasEnchant = True logger.debug("Checking package 'pyenchant': OK") except Exception: diff --git a/nw/constants.py b/nw/constants.py index 5d7066b3..c80c6adc 100644 --- a/nw/constants.py +++ b/nw/constants.py @@ -37,14 +37,14 @@ def trConst(tString): class nwConst(): # Date and Time Formats - FMT_TSTAMP = "%Y-%m-%d %H:%M:%S" # Default format - FMT_FSTAMP = "%Y-%m-%d %H.%M.%S" # FileName safe format - FMT_DSTAMP = "%Y-%m-%d" # Date only format + FMT_TSTAMP = "%Y-%m-%d %H:%M:%S" # Default format + FMT_FSTAMP = "%Y-%m-%d %H.%M.%S" # FileName safe format + FMT_DSTAMP = "%Y-%m-%d" # Date only format # Various Hard Limits - MAX_DEPTH = 30 # Maximum folder depth of a project - MAX_DOCSIZE = 5000000 # Maxium size of a single document - MAX_BUILDSIZE = 10000000 # Maxium size of a project build + MAX_DEPTH = 30 # Maximum folder depth of a project + MAX_DOCSIZE = 5000000 # Maxium size of a single document + MAX_BUILDSIZE = 10000000 # Maxium size of a project build # Spell Check Providers SP_INTERNAL = "internal" @@ -264,67 +264,67 @@ class nwUnicode: # ================= # Quotation Marks - U_QUOT = "\u0022" # Quotation mark - U_APOS = "\u0027" # Apostrophe - U_LAQUO = "\u00ab" # Left-pointing double angle quotation mark - U_RAQUO = "\u00bb" # Right-pointing double angle quotation mark - U_LSQUO = "\u2018" # Left single quotation mark - U_RSQUO = "\u2019" # Right single quotation mark - U_SBQUO = "\u201a" # Single low-9 quotation mark - U_SUQUO = "\u201b" # Single high-reversed-9 quotation mark - U_LDQUO = "\u201c" # Left double quotation mark - U_RDQUO = "\u201d" # Right double quotation mark - U_BDQUO = "\u201e" # Double low-9 quotation mark - U_UDQUO = "\u201f" # Double high-reversed-9 quotation mark - U_LSAQUO = "\u2039" # Single left-pointing angle quotation mark - U_RSAQUO = "\u203a" # Single right-pointing angle quotation mark - U_BDRQUO = "\u2e42" # Double low-reversed-9 quotation mark - U_LCQUO = "\u300c" # Left corner bracket - U_RCQUO = "\u300d" # Right corner bracket - U_LWCQUO = "\u300e" # Left white corner bracket - U_RWCQUO = "\u300f" # Right white corner bracket + U_QUOT = "\u0022" # Quotation mark + U_APOS = "\u0027" # Apostrophe + U_LAQUO = "\u00ab" # Left-pointing double angle quotation mark + U_RAQUO = "\u00bb" # Right-pointing double angle quotation mark + U_LSQUO = "\u2018" # Left single quotation mark + U_RSQUO = "\u2019" # Right single quotation mark + U_SBQUO = "\u201a" # Single low-9 quotation mark + U_SUQUO = "\u201b" # Single high-reversed-9 quotation mark + U_LDQUO = "\u201c" # Left double quotation mark + U_RDQUO = "\u201d" # Right double quotation mark + U_BDQUO = "\u201e" # Double low-9 quotation mark + U_UDQUO = "\u201f" # Double high-reversed-9 quotation mark + U_LSAQUO = "\u2039" # Single left-pointing angle quotation mark + U_RSAQUO = "\u203a" # Single right-pointing angle quotation mark + U_BDRQUO = "\u2e42" # Double low-reversed-9 quotation mark + U_LCQUO = "\u300c" # Left corner bracket + U_RCQUO = "\u300d" # Right corner bracket + U_LWCQUO = "\u300e" # Left white corner bracket + U_RWCQUO = "\u300f" # Right white corner bracket # Punctuation - U_FGDASH = "\u2012" # Figure dash - U_ENDASH = "\u2013" # Short dash - U_EMDASH = "\u2014" # Long dash - U_HBAR = "\u2015" # Horizontal bar - U_HELLIP = "\u2026" # Ellipsis - U_MAPOSS = "\u02bc" # Modifier letter single apostrophe - U_PRIME = "\u2032" # Prime - U_DPRIME = "\u2033" # Double prime + U_FGDASH = "\u2012" # Figure dash + U_ENDASH = "\u2013" # Short dash + U_EMDASH = "\u2014" # Long dash + U_HBAR = "\u2015" # Horizontal bar + U_HELLIP = "\u2026" # Ellipsis + U_MAPOSS = "\u02bc" # Modifier letter single apostrophe + U_PRIME = "\u2032" # Prime + U_DPRIME = "\u2033" # Double prime # Spaces and Lines - U_NBSP = "\u00a0" # Non-breaking space - U_THSP = "\u2009" # Thin space - U_THNBSP = "\u202f" # Thin non-breaking space - U_ENSP = "\u2002" # Short (en) space - U_EMSP = "\u2003" # Long (em) space - U_LSEP = "\u2028" # Line separator - U_PSEP = "\u2029" # Paragraph separator + U_NBSP = "\u00a0" # Non-breaking space + U_THSP = "\u2009" # Thin space + U_THNBSP = "\u202f" # Thin non-breaking space + U_ENSP = "\u2002" # Short (en) space + U_EMSP = "\u2003" # Long (em) space + U_LSEP = "\u2028" # Line separator + U_PSEP = "\u2029" # Paragraph separator # Symbols - U_CHECK = "\u2714" # Heavy check mark - U_CROSS = "\u2715" # Heavy cross mark - U_BULL = "\u2022" # List bullet - U_TRBULL = "\u2023" # Triangle bullet - U_HYBULL = "\u2043" # Hyphen bullet - U_FLOWER = "\u2055" # Flower punctuation mark - U_PERMIL = "\u2030" # Per mille sign - U_DEGREE = "\u00b0" # Degree symbol - U_MINUS = "\u2212" # Minus sign - U_TIMES = "\u00d7" # Multiplaction sign - U_DIVIDE = "\u00f7" # Division sign + U_CHECK = "\u2714" # Heavy check mark + U_CROSS = "\u2715" # Heavy cross mark + U_BULL = "\u2022" # List bullet + U_TRBULL = "\u2023" # Triangle bullet + U_HYBULL = "\u2043" # Hyphen bullet + U_FLOWER = "\u2055" # Flower punctuation mark + U_PERMIL = "\u2030" # Per mille sign + U_DEGREE = "\u00b0" # Degree symbol + U_MINUS = "\u2212" # Minus sign + U_TIMES = "\u00d7" # Multiplaction sign + U_DIVIDE = "\u00f7" # Division sign # Arrows - U_UTRI = "\u25b2" # Up-pointing triangle - U_UTRIS = "\u25b4" # Up-pointing triangle, small - U_RTRI = "\u25b6" # Right-pointing triangle - U_RTRIS = "\u25b8" # Right-pointing triangle, small - U_DTRI = "\u25bc" # Down-pointing triangle - U_DTRIS = "\u25be" # Down-pointing triangle, small - U_LTRI = "\u25c0" # Left-pointing triangle - U_LTRIS = "\u25c2" # Left-pointing triangle, small + U_UTRI = "\u25b2" # Up-pointing triangle + U_UTRIS = "\u25b4" # Up-pointing triangle, small + U_RTRI = "\u25b6" # Right-pointing triangle + U_RTRIS = "\u25b8" # Right-pointing triangle, small + U_DTRI = "\u25bc" # Down-pointing triangle + U_DTRIS = "\u25be" # Down-pointing triangle, small + U_LTRI = "\u25c0" # Left-pointing triangle + U_LTRIS = "\u25c2" # Left-pointing triangle, small # HTML Equivalents # ================ diff --git a/nw/core/document.py b/nw/core/document.py index 60ebd63a..70519c2a 100644 --- a/nw/core/document.py +++ b/nw/core/document.py @@ -39,11 +39,11 @@ class NWDoc(): self.theProject = theProject # Internal Variables - self._theItem = None # The currently open item - self._docHandle = None # The handle of the currently open item - self._fileLoc = None # The file location of the currently open item - self._docMeta = {} # The meta data of the currently open item - self._docError = "" # The latest encountered IO error + self._theItem = None # The currently open item + self._docHandle = None # The handle of the currently open item + self._fileLoc = None # The file location of the currently open item + self._docMeta = {} # The meta data of the currently open item + self._docError = "" # The latest encountered IO error if isHandle(theHandle): self._docHandle = theHandle diff --git a/nw/core/index.py b/nw/core/index.py index a1759dab..8b838d8e 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -482,10 +482,10 @@ class NWIndex(): """Scan a line starting with @ to check that it's valid. Then split it up into its elements and positions as two arrays. """ - theBits = [] # The elements of the string - thePos = [] # The absolute position of each element + theBits = [] # The elements of the string + thePos = [] # The absolute position of each element - aLine = aLine.rstrip() # Remove all trailing white spaces + aLine = aLine.rstrip() # Remove all trailing white spaces nChar = len(aLine) if nChar < 2: return False, theBits, thePos diff --git a/nw/core/item.py b/nw/core/item.py index 3880b5e2..de165b5a 100644 --- a/nw/core/item.py +++ b/nw/core/item.py @@ -51,11 +51,11 @@ class NWItem(): self.isExported = True # Document Meta Data - self.charCount = 0 # Current character count - self.wordCount = 0 # Current word count - self.paraCount = 0 # Current paragraph count - self.initCount = 0 # Initial word count - self.cursorPos = 0 # Last cursor position + self.charCount = 0 # Current character count + self.wordCount = 0 # Current word count + self.paraCount = 0 # Current paragraph count + self.initCount = 0 # Initial word count + self.cursorPos = 0 # Last cursor position return @@ -251,7 +251,7 @@ class NWItem(): if isinstance(expState, str): self.isExpanded = (expState == str(True)) else: - self.isExpanded = (expState == True) # noqa: E712 + self.isExpanded = (expState == True) # noqa: E712 return def setExported(self, expState): @@ -260,7 +260,7 @@ class NWItem(): if isinstance(expState, str): self.isExported = (expState == str(True)) else: - self.isExported = (expState == True) # noqa: E712 + self.isExported = (expState == True) # noqa: E712 return ## diff --git a/nw/core/project.py b/nw/core/project.py index 9adab86f..73c8aee9 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -59,48 +59,48 @@ class NWProject(): self.mainConf = nw.CONFIG # Core Elements - self.optState = OptionState(self) # Project-specific GUI options - self.projTree = NWTree(self) # The project tree - self.langData = {} # Localisation data + self.optState = OptionState(self) # Project-specific GUI options + self.projTree = NWTree(self) # The project tree + self.langData = {} # Localisation data # Project Status - self.projOpened = 0 # The time stamp of when the project file was opened - self.projChanged = False # The project has unsaved changes - self.projAltered = False # The project has been altered this session - self.lockedBy = None # Data on which computer has the project open - self.saveCount = 0 # Meta data: number of saves - self.autoCount = 0 # Meta data: number of automatic saves - self.editTime = 0 # The accumulated edit time read from the project file + self.projOpened = 0 # The time stamp of when the project file was opened + self.projChanged = False # The project has unsaved changes + self.projAltered = False # The project has been altered this session + self.lockedBy = None # Data on which computer has the project open + self.saveCount = 0 # Meta data: number of saves + self.autoCount = 0 # Meta data: number of automatic saves + self.editTime = 0 # The accumulated edit time read from the project file # Class Settings - self.projPath = None # The full path to where the currently open project is saved - self.projMeta = None # The full path to the project's meta data folder - self.projCache = None # The full path to the project's cache folder - self.projContent = None # The full path to the project's content folder - self.projDict = None # The spell check dictionary - self.projSpell = None # The spell check language, if different than default - self.projLang = None # The project language, used for builds - self.projFile = None # The file name of the project main XML file + self.projPath = None # The full path to where the currently open project is saved + self.projMeta = None # The full path to the project's meta data folder + self.projCache = None # The full path to the project's cache folder + self.projContent = None # The full path to the project's content folder + self.projDict = None # The spell check dictionary + self.projSpell = None # The spell check language, if different than default + self.projLang = None # The project language, used for builds + self.projFile = None # The file name of the project main XML file # Project Meta - self.projName = "" # Project name (working title) - self.bookTitle = "" # The final title; should only be used for exports - self.bookAuthors = [] # A list of book authors + self.projName = "" # Project name (working title) + self.bookTitle = "" # The final title; should only be used for exports + self.bookAuthors = [] # A list of book authors # Project Settings - self.autoReplace = {} # Text to auto-replace on exports - self.titleFormat = {} # The formatting of titles for exports - self.spellCheck = False # Controls the spellcheck-as-you-type feature - self.autoOutline = True # If true, the Project Outline is updated automatically - self.statusItems = None # Novel file progress status values - self.importItems = None # Note file importance values - self.lastEdited = None # The handle of the last file to be edited - self.lastViewed = None # The handle of the last file to be viewed - self.lastWCount = 0 # The project word count from last session - self.currWCount = 0 # The project word count in current session - self.novelWCount = 0 # Total number of words in novel files - self.notesWCount = 0 # Total number of words in note files - self.doBackup = True # Run project backup on exit + self.autoReplace = {} # Text to auto-replace on exports + self.titleFormat = {} # The formatting of titles for exports + self.spellCheck = False # Controls the spellcheck-as-you-type feature + self.autoOutline = True # If true, the Project Outline is updated automatically + self.statusItems = None # Novel file progress status values + self.importItems = None # Note file importance values + self.lastEdited = None # The handle of the last file to be edited + self.lastViewed = None # The handle of the last file to be viewed + self.lastWCount = 0 # The project word count from last session + self.currWCount = 0 # The project word count in current session + self.novelWCount = 0 # Total number of words in novel files + self.notesWCount = 0 # Total number of words in note files + self.doBackup = True # Run project backup on exit # Internal Mapping self.makeAlert = self.theParent.makeAlert @@ -383,7 +383,7 @@ class NWProject(): # Check for Old Legacy Data # ========================= - legacyList = [] # Cleanup is done later + legacyList = [] # Cleanup is done later for projItem in os.listdir(self.projPath): logger.verbose("Project contains: %s" % projItem) if projItem.startswith("data_"): diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py index f638d53f..c06943d5 100644 --- a/nw/core/tohtml.py +++ b/nw/core/tohtml.py @@ -33,9 +33,9 @@ logger = logging.getLogger(__name__) class ToHtml(Tokenizer): - M_PREVIEW = 0 # Tweak output for the DocViewer - M_EXPORT = 1 # Tweak output for saving to HTML or printing - M_EBOOK = 2 # Tweak output for converting to epub + M_PREVIEW = 0 # Tweak output for the DocViewer + M_EXPORT = 1 # Tweak output for saving to HTML or printing + M_EBOOK = 2 # Tweak output for converting to epub def __init__(self, theProject): Tokenizer.__init__(self, theProject) diff --git a/nw/core/tokenizer.py b/nw/core/tokenizer.py index c6f06cc0..e78c182b 100644 --- a/nw/core/tokenizer.py +++ b/nw/core/tokenizer.py @@ -51,33 +51,33 @@ class Tokenizer(): FMT_D_E = 6 # End strikeout # Block Type - T_EMPTY = 1 # Empty line (new paragraph) - T_SYNOPSIS = 2 # Synopsis comment - T_COMMENT = 3 # Comment line - T_KEYWORD = 4 # Command line - T_TITLE = 5 # Title - T_HEAD1 = 6 # Header 1 - T_HEAD2 = 7 # Header 2 - T_HEAD3 = 8 # Header 3 - T_HEAD4 = 9 # Header 4 - T_TEXT = 10 # Text line - T_SEP = 11 # Scene separator - T_SKIP = 12 # Paragraph break + T_EMPTY = 1 # Empty line (new paragraph) + T_SYNOPSIS = 2 # Synopsis comment + T_COMMENT = 3 # Comment line + T_KEYWORD = 4 # Command line + T_TITLE = 5 # Title + T_HEAD1 = 6 # Header 1 + T_HEAD2 = 7 # Header 2 + T_HEAD3 = 8 # Header 3 + T_HEAD4 = 9 # Header 4 + T_TEXT = 10 # Text line + T_SEP = 11 # Scene separator + T_SKIP = 12 # Paragraph break # Block Style - A_NONE = 0x0000 # No special style - A_LEFT = 0x0001 # Left aligned - A_RIGHT = 0x0002 # Right aligned - A_CENTRE = 0x0004 # Centred - A_JUSTIFY = 0x0008 # Justified - A_PBB = 0x0010 # Page break before always - A_PBB_AUT = 0x0020 # Page break before auto - A_PBA = 0x0040 # Page break after always - A_PBA_AUT = 0x0080 # Page break after auto - A_Z_TOPMRG = 0x0100 # Zero top margin - A_Z_BTMMRG = 0x0200 # Zero bottom margin - A_IND_L = 0x0400 # Left indentation - A_IND_R = 0x0800 # Right indentation + A_NONE = 0x0000 # No special style + A_LEFT = 0x0001 # Left aligned + A_RIGHT = 0x0002 # Right aligned + A_CENTRE = 0x0004 # Centred + A_JUSTIFY = 0x0008 # Justified + A_PBB = 0x0010 # Page break before always + A_PBB_AUT = 0x0020 # Page break before auto + A_PBA = 0x0040 # Page break after always + A_PBA_AUT = 0x0080 # Page break after auto + A_Z_TOPMRG = 0x0100 # Zero top margin + A_Z_BTMMRG = 0x0200 # Zero bottom margin + A_IND_L = 0x0400 # Left indentation + A_IND_R = 0x0800 # Right indentation def __init__(self, theProject): @@ -86,26 +86,26 @@ class Tokenizer(): self.mainConf = nw.CONFIG # Data Variables - self.theText = "" # The raw text to be tokenized - self.theHandle = None # The handle associated with the text - self.theItem = None # The NWItem associated with the handle - self.theTokens = [] # The list of the processed tokens - self.theResult = "" # The result of the last document + self.theText = "" # The raw text to be tokenized + self.theHandle = None # The handle associated with the text + self.theItem = None # The NWItem associated with the handle + self.theTokens = [] # The list of the processed tokens + self.theResult = "" # The result of the last document - self.keepMarkdown = False # Whether to keep the markdown text - self.theMarkdown = [] # The result novelWriter markdown of all documents + self.keepMarkdown = False # Whether to keep the markdown text + self.theMarkdown = [] # The result novelWriter markdown of all documents # User Settings - self.textFont = "Serif" # Output text font - self.textSize = 11 # Output text size - self.textFixed = False # Fixed width text - self.lineHeight = 1.15 # Line height in units of em - self.blockIndent = 4.00 # Block indent in units of em - self.doJustify = False # Justify text - self.doBodyText = True # Include body text - self.doSynopsis = False # Also process synopsis comments - self.doComments = False # Also process comments - self.doKeywords = False # Also process keywords like tags and references + self.textFont = "Serif" # Output text font + self.textSize = 11 # Output text size + self.textFixed = False # Fixed width text + self.lineHeight = 1.15 # Line height in units of em + self.blockIndent = 4.00 # Block indent in units of em + self.doJustify = False # Justify text + self.doBodyText = True # Include body text + self.doSynopsis = False # Also process synopsis comments + self.doComments = False # Also process comments + self.doKeywords = False # Also process keywords like tags and references # Margins self.marginTitle = (1.000, 0.500) @@ -117,22 +117,22 @@ class Tokenizer(): self.marginMeta = (0.000, 0.584) # Title Formats - self.fmtTitle = "%title%" # Formatting for titles - self.fmtChapter = "%title%" # Formatting for numbered chapters - self.fmtUnNum = "%title%" # Formatting for unnumbered chapters - self.fmtScene = "%title%" # Formatting for scenes - self.fmtSection = "%title%" # Formatting for sections + self.fmtTitle = "%title%" # Formatting for titles + self.fmtChapter = "%title%" # Formatting for numbered chapters + self.fmtUnNum = "%title%" # Formatting for unnumbered chapters + self.fmtScene = "%title%" # Formatting for scenes + self.fmtSection = "%title%" # Formatting for sections - self.hideScene = False # Do not include scene headers - self.hideSection = False # Do not include section headers + self.hideScene = False # Do not include scene headers + self.hideSection = False # Do not include section headers - self.linkHeaders = False # Add an anchor before headers + self.linkHeaders = False # Add an anchor before headers # Instance Variables - self.numChapter = 0 # Counter for chapter numbers - self.numChScene = 0 # Counter for scene number within chapter - self.numAbsScene = 0 # Counter for scene number within novel - self.firstScene = False # Flag to indicate that the first scene of the chapter + self.numChapter = 0 # Counter for chapter numbers + self.numChScene = 0 # Counter for scene number within chapter + self.numAbsScene = 0 # Counter for scene number within novel + self.firstScene = False # Flag to indicate that the first scene of the chapter # This File self.isNone = False diff --git a/nw/core/tomd.py b/nw/core/tomd.py index b1b1b093..b66cf902 100644 --- a/nw/core/tomd.py +++ b/nw/core/tomd.py @@ -33,8 +33,8 @@ logger = logging.getLogger(__name__) class ToMarkdown(Tokenizer): - M_STD = 0 # Standard Markdown - M_GH = 1 # GitHub Markdown + M_STD = 0 # Standard Markdown + M_GH = 1 # GitHub Markdown def __init__(self, theProject): Tokenizer.__init__(self, theProject) diff --git a/nw/core/toodt.py b/nw/core/toodt.py index 998df118..3b9aca4b 100644 --- a/nw/core/toodt.py +++ b/nw/core/toodt.py @@ -59,36 +59,36 @@ TAG_STNM = "{%s}style-name" % XML_NS["text"] class ToOdt(Tokenizer): - X_BLD = 0x01 # Bold format - X_ITA = 0x02 # Italic format - X_DEL = 0x04 # Strikethrough format - X_BRK = 0x08 # Line break - X_TAB = 0x10 # Tab + X_BLD = 0x01 # Bold format + X_ITA = 0x02 # Italic format + X_DEL = 0x04 # Strikethrough format + X_BRK = 0x08 # Line break + X_TAB = 0x10 # Tab def __init__(self, theProject, isFlat): Tokenizer.__init__(self, theProject) self.mainConf = nw.CONFIG - self._isFlat = isFlat # Flat: .fodt, otherwise .odt + self._isFlat = isFlat # Flat: .fodt, otherwise .odt - self._dFlat = None # FODT file XML root - self._dCont = None # ODT content.xml root - self._dMeta = None # ODT meta.xml root - self._dStyl = None # ODT styles.xml root + self._dFlat = None # FODT file XML root + self._dCont = None # ODT content.xml root + self._dMeta = None # ODT meta.xml root + self._dStyl = None # ODT styles.xml root - self._xMeta = None # Office meta root - self._xStyl = None # Office styles root - self._xAuto = None # Office auto-styles root - self._xMast = None # Office master-styles root - self._xBody = None # Office body root - self._xText = None # Office text root + self._xMeta = None # Office meta root + self._xStyl = None # Office styles root + self._xAuto = None # Office auto-styles root + self._xMast = None # Office master-styles root + self._xBody = None # Office body root + self._xText = None # Office text root - self._xAut2 = None # Page layout auto-styles for ODT file + self._xAut2 = None # Page layout auto-styles for ODT file - self._mainPara = {} # User-accessible paragraph styles - self._autoPara = {} # Auto-generated paragraph styles - self._autoText = {} # Auto-generated text styles + self._mainPara = {} # User-accessible paragraph styles + self._autoPara = {} # Auto-generated paragraph styles + self._autoText = {} # Auto-generated text styles # Properties self.textFont = "Liberation Serif" @@ -315,15 +315,15 @@ class ToOdt(Tokenizer): def doConvert(self): """Convert the list of text tokens into XML elements. """ - self.theResult = "" # Not used, but cleared just in case + self.theResult = "" # Not used, but cleared just in case odtTags = { - self.FMT_B_B : "_B", # Bold open format - self.FMT_B_E : "b_", # Bold close format - self.FMT_I_B : "I", # Italic open format - self.FMT_I_E : "i", # Italic close format - self.FMT_D_B : "_S", # Strikethrough open format - self.FMT_D_E : "s_", # Strikethrough close format + self.FMT_B_B : "_B", # Bold open format + self.FMT_B_E : "b_", # Bold close format + self.FMT_I_B : "I", # Italic open format + self.FMT_I_E : "i", # Italic close format + self.FMT_D_B : "_S", # Strikethrough open format + self.FMT_D_E : "s_", # Strikethrough close format } thisPar = [] diff --git a/nw/core/tree.py b/nw/core/tree.py index b2d53ad8..6393e42d 100644 --- a/nw/core/tree.py +++ b/nw/core/tree.py @@ -68,16 +68,16 @@ class NWTree(): self.theProject = theProject - self._projTree = {} # Holds all the items of the project - self._treeOrder = [] # The order of the tree items on the tree view - self._treeRoots = [] # The root items of the tree - self._trashRoot = None # The handle of the trash root folder - self._archRoot = None # The handle of the archive root folder - self._theIndex = 0 # The current iterator index - self._treeChanged = False # True if tree structure has changed + self._projTree = {} # Holds all the items of the project + self._treeOrder = [] # The order of the tree items on the tree view + self._treeRoots = [] # The root items of the tree + self._trashRoot = None # The handle of the trash root folder + self._archRoot = None # The handle of the archive root folder + self._theIndex = 0 # The current iterator index + self._treeChanged = False # True if tree structure has changed - self._handleSeed = None # Used for generating handles for testing - self._handleCount = 0 # A counter that is added to the handle generator + self._handleSeed = None # Used for generating handles for testing + self._handleCount = 0 # A counter that is added to the handle generator return diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 869ea1ed..8c2142a8 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -84,24 +84,24 @@ class GuiDocEditor(QTextEdit): self._nwDocument = None self._nwItem = None - self._docChanged = False # Flag for changed status of document - self._docHandle = None # The handle of the open file - self._docHeaders = [] # Record of headers in the file + self._docChanged = False # Flag for changed status of document + self._docHandle = None # The handle of the open file + self._docHeaders = [] # Record of headers in the file - self._spellCheck = False # Flag for spell checking enabled - self._theDict = None # The current spell check dictionary - self._nonWord = "\"'" # Characters to not include in spell checking + self._spellCheck = False # Flag for spell checking enabled + self._theDict = None # The current spell check dictionary + self._nonWord = "\"'" # Characters to not include in spell checking # Document Variables - self._charCount = 0 # Character count - self._wordCount = 0 # Word count - self._paraCount = 0 # Paragraph count - self._lastEdit = 0 # Time stamp of last edit - self._lastActive = 0 # Time stamp of last activity - self._lastFind = None # Position of the last found search word - self._bigDoc = False # Flag for very large document size - self._doReplace = False # Switch to temporarily disable auto-replace - self._queuePos = None # Used for delayed change of cursor position + self._charCount = 0 # Character count + self._wordCount = 0 # Word count + self._paraCount = 0 # Paragraph count + self._lastEdit = 0 # Time stamp of last edit + self._lastActive = 0 # Time stamp of last activity + self._lastFind = None # Position of the last found search word + self._bigDoc = False # Flag for very large document size + self._doReplace = False # Switch to temporarily disable auto-replace + self._queuePos = None # Used for delayed change of cursor position # Typography self._typDQOpen = '"' @@ -597,8 +597,8 @@ class GuiDocEditor(QTextEdit): """ if self.mainConf.verQtValue >= 50900: theText = self._qDocument.toRawText() - theText = theText.replace(nwUnicode.U_LSEP, "\n") # Line separators - theText = theText.replace(nwUnicode.U_PSEP, "\n") # Paragraph separators + theText = theText.replace(nwUnicode.U_LSEP, "\n") # Line separators + theText = theText.replace(nwUnicode.U_PSEP, "\n") # Paragraph separators else: theText = self.toPlainText() return theText @@ -1424,7 +1424,7 @@ class GuiDocEditor(QTextEdit): theTwo = theText[thePos-2:thePos] theThree = theText[thePos-3:thePos] - if not theOne: # Makes Neo sad + if not theOne: # Makes Neo sad return nDelete = 0 @@ -1961,7 +1961,7 @@ class BackgroundWordCounter(QRunnable): self._isRunning = False return -## END Class BackgroundWordCounter +# END Class BackgroundWordCounter class BackgroundWordCounterSignals(QObject): @@ -2236,7 +2236,7 @@ class GuiDocEditSearch(QFrame): self._alertSearchValid(theRegEx.isValid()) return theRegEx - else: # >= 50300 to < 51300 + else: # >= 50300 to < 51300 if self.isCaseSense: rxOpt = Qt.CaseSensitive else: diff --git a/nw/gui/dochighlight.py b/nw/gui/dochighlight.py index 193689e9..4b4eed12 100644 --- a/nw/gui/dochighlight.py +++ b/nw/gui/dochighlight.py @@ -288,7 +288,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): if self.theHandle is None or not theText: return - if theText.startswith("@"): # Keywords and commands + if theText.startswith("@"): # Keywords and commands self.setCurrentBlockState(self.BLOCK_META) tItem = self.theParent.theProject.projTree[self.theHandle] isValid, theBits, thePos = self.theIndex.scanThis(theText) @@ -312,27 +312,27 @@ class GuiDocHighlighter(QSyntaxHighlighter): # so we force a return here return - elif theText.startswith("# "): # Header 1 + elif theText.startswith("# "): # Header 1 self.setCurrentBlockState(self.BLOCK_TITLE) self.setFormat(0, 1, self.hStyles["header1h"]) self.setFormat(1, len(theText), self.hStyles["header1"]) - elif theText.startswith("## "): # Header 2 + elif theText.startswith("## "): # Header 2 self.setCurrentBlockState(self.BLOCK_TITLE) self.setFormat(0, 2, self.hStyles["header2h"]) self.setFormat(2, len(theText), self.hStyles["header2"]) - elif theText.startswith("### "): # Header 3 + elif theText.startswith("### "): # Header 3 self.setCurrentBlockState(self.BLOCK_TITLE) self.setFormat(0, 3, self.hStyles["header3h"]) self.setFormat(3, len(theText), self.hStyles["header3"]) - elif theText.startswith("#### "): # Header 4 + elif theText.startswith("#### "): # Header 4 self.setCurrentBlockState(self.BLOCK_TITLE) self.setFormat(0, 4, self.hStyles["header4h"]) self.setFormat(4, len(theText), self.hStyles["header4"]) - elif theText.startswith("%"): # Comments + elif theText.startswith("%"): # Comments self.setCurrentBlockState(self.BLOCK_TEXT) toCheck = theText[1:].lstrip() synTag = toCheck[:9].lower() @@ -345,7 +345,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): else: self.setFormat(0, tLen, self.hStyles["hidden"]) - else: # Text Paragraph + else: # Text Paragraph self.setCurrentBlockState(self.BLOCK_TEXT) for rX, xFmt in self.rxRules: rxItt = rX.globalMatch(theText, 0) diff --git a/nw/gui/itemdetails.py b/nw/gui/itemdetails.py index 5ab8b640..9a2b1d30 100644 --- a/nw/gui/itemdetails.py +++ b/nw/gui/itemdetails.py @@ -235,10 +235,10 @@ class GuiItemDetails(QWidget): itStatus = nwItem.itemStatus if nwItem.itemClass == nwItemClass.NOVEL: - itStatus = self.theProject.statusItems.checkEntry(itStatus) # Make sure it's valid + itStatus = self.theProject.statusItems.checkEntry(itStatus) # Make sure it's valid flagIcon = self.theParent.statusIcons[itStatus] else: - itStatus = self.theProject.importItems.checkEntry(itStatus) # Make sure it's valid + itStatus = self.theProject.importItems.checkEntry(itStatus) # Make sure it's valid flagIcon = self.theParent.importIcons[itStatus] if nwItem.itemType == nwItemType.FILE: diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 3c94d854..c297380a 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -241,7 +241,7 @@ class GuiMainMenu(QMenuBar): self.rootItems[nwItemClass.ARCHIVE] = QAction(self.tr("Outtakes Root"), self.rootMenu) nCount = 0 for itemClass in self.rootItems.keys(): - nCount += 1 # This forces the lambdas to be unique + nCount += 1 # This forces the lambdas to be unique self.rootItems[itemClass].triggered.connect( lambda nCount, itemClass=itemClass: self._newTreeItem(nwItemType.ROOT, itemClass) ) @@ -982,7 +982,7 @@ class GuiMainMenu(QMenuBar): self.aSpellCheck.setStatusTip(self.tr("Toggle check spelling")) self.aSpellCheck.setCheckable(True) self.aSpellCheck.setChecked(self.theProject.spellCheck) - self.aSpellCheck.triggered.connect(self._toggleSpellCheck) # triggered, not toggled! + self.aSpellCheck.triggered.connect(self._toggleSpellCheck) # triggered, not toggled! self.aSpellCheck.setShortcut("Ctrl+F7") self.toolsMenu.addAction(self.aSpellCheck) diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 71fdae90..c9dbc49e 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -620,10 +620,10 @@ class GuiProjectTree(QTreeWidget): iStatus = nwItem.itemStatus if nwItem.itemClass == nwItemClass.NOVEL: - iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid + iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid flagIcon = self.theParent.statusIcons[iStatus] else: - iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid + iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid flagIcon = self.theParent.importIcons[iStatus] trItem.setText(self.C_NAME, nwItem.itemName) @@ -790,7 +790,7 @@ class GuiProjectTree(QTreeWidget): selItem = self.itemAt(clickPos) if isinstance(selItem, QTreeWidgetItem): tHandle = selItem.data(self.C_NAME, Qt.UserRole) - self.setSelectedHandle(tHandle) # Just to be safe + self.setSelectedHandle(tHandle) # Just to be safe tItem = self.theProject.projTree[tHandle] if tItem is not None: if self.ctxMenu.filterActions(tItem): diff --git a/nw/guimain.py b/nw/guimain.py index 97fbbd74..337d2904 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -613,9 +613,9 @@ class GuiMain(QMainWindow): return False self.treeView.flushTreeOrder() - nHandle = None # The next handle after tHandle - fHandle = None # The first file handle we encounter - foundIt = False # We've found tHandle, pick the next we see + nHandle = None # The next handle after tHandle + fHandle = None # The first file handle we encounter + foundIt = False # We've found tHandle, pick the next we see for tItem in self.theProject.projTree: if tItem is None: continue diff --git a/nw/tools/build.py b/nw/tools/build.py index bd1c923c..2929cd51 100644 --- a/nw/tools/build.py +++ b/nw/tools/build.py @@ -54,17 +54,17 @@ logger = logging.getLogger(__name__) class GuiBuildNovel(QDialog): - FMT_PDF = 1 # Print to PDF + FMT_PDF = 1 # Print to PDF - FMT_ODT = 2 # Open Document file - FMT_FODT = 3 # Flat Open Document file - FMT_HTM = 4 # HTML5 - FMT_NWD = 5 # nW Markdown - FMT_MD = 6 # Standard Markdown - FMT_GH = 7 # GitHub Markdown + FMT_ODT = 2 # Open Document file + FMT_FODT = 3 # Flat Open Document file + FMT_HTM = 4 # HTML5 + FMT_NWD = 5 # nW Markdown + FMT_MD = 6 # Standard Markdown + FMT_GH = 7 # GitHub Markdown - FMT_JSON_H = 8 # HTML5 wrapped in JSON - FMT_JSON_M = 9 # nW Markdown wrapped in JSON + FMT_JSON_H = 8 # HTML5 wrapped in JSON + FMT_JSON_M = 9 # nW Markdown wrapped in JSON def __init__(self, theParent): QDialog.__init__(self, theParent) @@ -78,10 +78,10 @@ class GuiBuildNovel(QDialog): self.theProject = theParent.theProject self.optState = theParent.theProject.optState - self.htmlText = [] # List of html documents - self.htmlStyle = [] # List of html styles - self.htmlSize = 0 # Size of the html document - self.buildTime = 0 # The timestamp of the last build + self.htmlText = [] # List of html documents + self.htmlStyle = [] # List of html styles + self.htmlSize = 0 # Size of the html document + self.buildTime = 0 # The timestamp of the last build self.setWindowTitle(self.tr("Build Novel Project")) self.setMinimumWidth(self.mainConf.pxInt(700)) @@ -991,7 +991,7 @@ class GuiBuildNovel(QDialog): else: # If the if statements above and here match, it should not # be possible to reach this else statement. - return False # pragma: no cover + return False # pragma: no cover # Report to User # ============== @@ -1035,7 +1035,7 @@ class GuiBuildNovel(QDialog): self.textFont.setText(theFont.family()) self.textSize.setValue(theFont.pointSize()) - self.raise_() # Move the dialog to front (fixes a bug on macOS) + self.raise_() # Move the dialog to front (fixes a bug on macOS) return diff --git a/nw/tools/writingstats.py b/nw/tools/writingstats.py index 5724f268..e37c03c7 100644 --- a/nw/tools/writingstats.py +++ b/nw/tools/writingstats.py @@ -570,7 +570,7 @@ class GuiWritingStats(QDialog): if isFirst: # Subtract the offset from the first list entry dwTotal -= self.wordOffset - dwTotal = max(dwTotal, 1) # Don't go zero or negative + dwTotal = max(dwTotal, 1) # Don't go zero or negative isFirst = False if groupByDay: diff --git a/setup.cfg b/setup.cfg index 57716486..bc11c66e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,6 @@ gui_scripts = universal = 0 [flake8] -ignore = E203,E221,E226,E228,E241,E251,E261 +ignore = E203,E221,E226,E228,E241,E251 max-line-length = 99 exclude = docs/* diff --git a/setup.py b/setup.py index aa24164e..238590b7 100755 --- a/setup.py +++ b/setup.py @@ -1294,7 +1294,7 @@ if __name__ == "__main__": sys.exit(0) # Run the standard setup - import setuptools # noqa: F401 + import setuptools # noqa: F401 setuptools.setup() # END Main diff --git a/tests/conftest.py b/tests/conftest.py index c1ae3f47..8db6da21 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,9 +29,9 @@ from tools import cleanProject sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) -import nw # noqa: E402 +import nw # noqa: E402 -from nw.config import Config # noqa: E402 +from nw.config import Config # noqa: E402 ## diff --git a/tests/test_base/test_base_config.py b/tests/test_base/test_base_config.py index 0fcbf876..14e24ec3 100644 --- a/tests/test_base/test_base_config.py +++ b/tests/test_base/test_base_config.py @@ -96,7 +96,7 @@ 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 *args: fncDir) + mp.setattr("PyQt5.QtCore.QStandardPaths.writableLocation", lambda *a: fncDir) tstConf.verQtValue = 50600 tstConf.initConfig() assert tstConf.confPath == os.path.join(fncDir, tstConf.appHandle) @@ -133,7 +133,7 @@ def testBaseConfig_Init(monkeypatch, tmpDir, fncDir, outDir, refDir, filesDir): # Run again and set the paths directly and correctly # This should create a config file as well with monkeypatch.context() as mp: - mp.setattr("os.path.expanduser", lambda *args: "") + mp.setattr("os.path.expanduser", lambda *a: "") tstConf.spellTool = nwConst.SP_INTERNAL tstConf.initConfig(confPath=tmpDir, dataPath=tmpDir) assert tstConf.confPath == tmpDir diff --git a/tests/test_base/test_base_error.py b/tests/test_base/test_base_error.py index 6d976568..03cbbb5d 100644 --- a/tests/test_base/test_base_error.py +++ b/tests/test_base/test_base_error.py @@ -86,28 +86,28 @@ def testBaseError_Handler(qtbot, monkeypatch, fncDir, tmpDir): # Normal shutdown with monkeypatch.context() as mp: - mp.setattr(NWErrorMessage, "exec_", lambda *args: None) - mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None) + mp.setattr(NWErrorMessage, "exec_", lambda *a: None) + mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *a: None) exceptionHandler(Exception, "Error Message", None) # Should not crash when no GUI is found with monkeypatch.context() as mp: - mp.setattr(NWErrorMessage, "exec_", lambda *args: None) - mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None) + mp.setattr(NWErrorMessage, "exec_", lambda *a: None) + mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *a: None) mp.setattr("PyQt5.QtWidgets.qApp.topLevelWidgets", lambda: []) exceptionHandler(Exception, "Error Message", None) # Should handle qApp failing with monkeypatch.context() as mp: - mp.setattr(NWErrorMessage, "exec_", lambda *args: None) - mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None) + mp.setattr(NWErrorMessage, "exec_", lambda *a: None) + mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *a: None) mp.setattr("PyQt5.QtWidgets.qApp.topLevelWidgets", causeException) exceptionHandler(Exception, "Error Message", None) # Should handle failing to close main GUI with monkeypatch.context() as mp: - mp.setattr(NWErrorMessage, "exec_", lambda *args: None) - mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *args: None) + mp.setattr(NWErrorMessage, "exec_", lambda *a: None) + mp.setattr("PyQt5.QtWidgets.qApp.exit", lambda *a: None) mp.setattr(nwGUI, "closeMain", causeException) exceptionHandler(Exception, "Error Message", None) diff --git a/tests/test_base/test_base_init.py b/tests/test_base/test_base_init.py index 72062bbf..a0b2cf70 100644 --- a/tests/test_base/test_base_init.py +++ b/tests/test_base/test_base_init.py @@ -158,10 +158,10 @@ def testBaseInit_Imports(caplog, monkeypatch, tmpDir): ["--testmode", "--config=%s" % tmpDir, "--data=%s" % tmpDir] ) - assert ex.value.code & 4 == 4 # Python version not satisfied - assert ex.value.code & 8 == 8 # Qt version not satisfied - assert ex.value.code & 16 == 16 # PyQt version not satisfied - assert ex.value.code & 32 == 32 # lxml package missing + assert ex.value.code & 4 == 4 # Python version not satisfied + assert ex.value.code & 8 == 8 # Qt version not satisfied + assert ex.value.code & 16 == 16 # PyQt version not satisfied + assert ex.value.code & 32 == 32 # lxml package missing assert "At least Python" in caplog.messages[0] assert "At least Qt5" in caplog.messages[1] diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index a5ead206..f165655b 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -122,7 +122,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal): @pytest.mark.core -def testCoreDocument_Methods(monkeypatch, dummyGUI, nwMinimal): +def testCoreDocument_Methods(dummyGUI, nwMinimal): """Test other methods of the NWDoc class. """ theProject = NWProject(dummyGUI) diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 888882e3..4dcbbfd2 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -50,12 +50,12 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, dummyGUI, outDir, refDir): theIndex = NWIndex(theProject) notIndexable = { - "b3643d0f92e32": False, # Novel ROOT - "45e6b01ca35c1": False, # Chapter One FOLDER - "6bd935d2490cd": False, # Chapter Two FOLDER - "67a8707f2f249": False, # Character ROOT - "6c6afb1247750": False, # Plot ROOT - "60bdf227455cc": False, # World ROOT + "b3643d0f92e32": False, # Novel ROOT + "45e6b01ca35c1": False, # Chapter One FOLDER + "6bd935d2490cd": False, # Chapter Two FOLDER + "67a8707f2f249": False, # Character ROOT + "6c6afb1247750": False, # Plot ROOT + "60bdf227455cc": False, # World ROOT } for tItem in theProject.projTree: assert theIndex.reIndexHandle(tItem.itemHandle) is notIndexable.get(tItem.itemHandle, True) @@ -204,7 +204,7 @@ def testCoreIndex_CheckThese(nwMinimal, dummyGUI): assert theIndex.scanText(nHandle, ( "# Hello World!\n" "@pov: Jane\n" - "@invalid: John\n" # Checks for issue #688 + "@invalid: John\n" # Checks for issue #688 )) assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]} assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!" @@ -312,29 +312,29 @@ def testCoreIndex_ScanText(nwMinimal, dummyGUI): "#### Title Four\n\n" "% synopsis: Synopsis Four.\n\n" "Paragraph Four.\n\n" - "##### Title Five\n\n" # Not interpreted as a title, the hashes are counted as a word + "##### Title Five\n\n" # Not interpreted as a title, the hashes are counted as a word "Paragraph Five.\n\n" )) - assert theIndex._refIndex[nHandle].get("T000000", None) is not None # Always there - assert theIndex._refIndex[nHandle].get("T000001", None) is not None # Heading 1 + assert theIndex._refIndex[nHandle].get("T000000", None) is not None # Always there + assert theIndex._refIndex[nHandle].get("T000001", None) is not None # Heading 1 assert theIndex._refIndex[nHandle].get("T000002", None) is None assert theIndex._refIndex[nHandle].get("T000003", None) is None assert theIndex._refIndex[nHandle].get("T000004", None) is None assert theIndex._refIndex[nHandle].get("T000005", None) is None assert theIndex._refIndex[nHandle].get("T000006", None) is None - assert theIndex._refIndex[nHandle].get("T000007", None) is not None # Heading 2 + assert theIndex._refIndex[nHandle].get("T000007", None) is not None # Heading 2 assert theIndex._refIndex[nHandle].get("T000008", None) is None assert theIndex._refIndex[nHandle].get("T000009", None) is None assert theIndex._refIndex[nHandle].get("T000010", None) is None assert theIndex._refIndex[nHandle].get("T000011", None) is None assert theIndex._refIndex[nHandle].get("T000012", None) is None - assert theIndex._refIndex[nHandle].get("T000013", None) is not None # Heading 3 + assert theIndex._refIndex[nHandle].get("T000013", None) is not None # Heading 3 assert theIndex._refIndex[nHandle].get("T000014", None) is None assert theIndex._refIndex[nHandle].get("T000015", None) is None assert theIndex._refIndex[nHandle].get("T000016", None) is None assert theIndex._refIndex[nHandle].get("T000017", None) is None assert theIndex._refIndex[nHandle].get("T000018", None) is None - assert theIndex._refIndex[nHandle].get("T000019", None) is not None # Heading 4 + assert theIndex._refIndex[nHandle].get("T000019", None) is not None # Heading 4 assert theIndex._refIndex[nHandle].get("T000020", None) is None assert theIndex._refIndex[nHandle].get("T000021", None) is None assert theIndex._refIndex[nHandle].get("T000022", None) is None @@ -403,9 +403,9 @@ def testCoreIndex_ScanText(nwMinimal, dummyGUI): assert theIndex.scanText(sHandle, ( "# Title One\n\n" - "@pov: One\n\n" # Valid - "@char: Two\n\n" # Invalid tag - "@:\n\n" # Invalid line + "@pov: One\n\n" # Valid + "@char: Two\n\n" # Invalid tag + "@:\n\n" # Invalid line "% synopsis: Synopsis One.\n\n" "Paragraph One.\n\n" )) @@ -503,9 +503,9 @@ def testCoreIndex_ExtractData(nwMinimal, dummyGUI): # The novel file should have the correct counts cC, wC, pC = theIndex.getCounts(nHandle) - assert cC == 62 # Characters in text and title only - assert wC == 12 # Words in text and title only - assert pC == 2 # Paragraphs in text only + assert cC == 62 # Characters in text and title only + assert wC == 12 # Words in text and title only + assert pC == 2 # Paragraphs in text only # getReferences # ============= diff --git a/tests/test_core/test_core_options.py b/tests/test_core/test_core_options.py index 823ce937..d41ba293 100644 --- a/tests/test_core/test_core_options.py +++ b/tests/test_core/test_core_options.py @@ -102,7 +102,7 @@ def testCoreOptions_LoadSave(monkeypatch, dummyGUI, tmpDir): @pytest.mark.core -def testCoreOptions_SetGet(monkeypatch, dummyGUI, tmpDir): +def testCoreOptions_SetGet(dummyGUI): """Test setting and getting values from the OptionState class. """ theProject = NWProject(dummyGUI) diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index afbcac95..7bc6b612 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -36,7 +36,7 @@ from nw.constants import nwFiles @pytest.mark.core -def testCoreProject_NewMinimal(fncDir, outDir, refDir, tmpDir, dummyGUI): +def testCoreProject_NewMinimal(fncDir, outDir, refDir, dummyGUI): """Create a new project from a project wizard dictionary. With default setting, creating a Minimal project. """ @@ -564,7 +564,7 @@ def testCoreProject_Helpers(monkeypatch, fncDir, dummyGUI): # Block user's home folder with monkeypatch.context() as mp: - mp.setattr("os.path.expanduser", lambda *args, **kwargs: fncDir) + mp.setattr("os.path.expanduser", lambda *a, **k: fncDir) assert theProject.ensureFolderStructure() is False # Create a file to block meta folder @@ -603,24 +603,24 @@ def testCoreProject_AccessItems(nwMinimal, dummyGUI): # Move Novel ROOT to after its files oldOrder = [ - "a508bb932959c", # ROOT: Novel - "a35baf2e93843", # FILE: Title Page - "a6d311a93600a", # FOLDER: New Chapter - "f5ab3e30151e1", # FILE: New Chapter - "8c659a11cd429", # FILE: New Scene - "7695ce551d265", # ROOT: Plot - "afb3043c7b2b3", # ROOT: Characters - "9d5247ab588e0", # ROOT: World + "a508bb932959c", # ROOT: Novel + "a35baf2e93843", # FILE: Title Page + "a6d311a93600a", # FOLDER: New Chapter + "f5ab3e30151e1", # FILE: New Chapter + "8c659a11cd429", # FILE: New Scene + "7695ce551d265", # ROOT: Plot + "afb3043c7b2b3", # ROOT: Characters + "9d5247ab588e0", # ROOT: World ] newOrder = [ - "a35baf2e93843", # FILE: Title Page - "f5ab3e30151e1", # FILE: New Chapter - "8c659a11cd429", # FILE: New Scene - "a6d311a93600a", # FOLDER: New Chapter - "a508bb932959c", # ROOT: Novel - "7695ce551d265", # ROOT: Plot - "afb3043c7b2b3", # ROOT: Characters - "9d5247ab588e0", # ROOT: World + "a35baf2e93843", # FILE: Title Page + "f5ab3e30151e1", # FILE: New Chapter + "8c659a11cd429", # FILE: New Scene + "a6d311a93600a", # FOLDER: New Chapter + "a508bb932959c", # ROOT: Novel + "7695ce551d265", # ROOT: Plot + "afb3043c7b2b3", # ROOT: Characters + "9d5247ab588e0", # ROOT: World ] assert theProject.projTree.handles() == oldOrder assert theProject.setTreeOrder(newOrder) @@ -639,15 +639,15 @@ def testCoreProject_AccessItems(nwMinimal, dummyGUI): retOrder.append(tItem.itemHandle) assert retOrder == [ - "a508bb932959c", # ROOT: Novel - "7695ce551d265", # ROOT: Plot - "afb3043c7b2b3", # ROOT: Characters - "9d5247ab588e0", # ROOT: World - nHandle, # FILE: Test File - "a35baf2e93843", # FILE: Title Page - "a6d311a93600a", # FOLDER: New Chapter - "f5ab3e30151e1", # FILE: New Chapter - "8c659a11cd429", # FILE: New Scene + "a508bb932959c", # ROOT: Novel + "7695ce551d265", # ROOT: Plot + "afb3043c7b2b3", # ROOT: Characters + "9d5247ab588e0", # ROOT: World + nHandle, # FILE: Test File + "a35baf2e93843", # FILE: Title Page + "a6d311a93600a", # FOLDER: New Chapter + "f5ab3e30151e1", # FILE: New Chapter + "8c659a11cd429", # FILE: New Scene ] assert theProject.projTree[nHandle].itemParent is None @@ -801,10 +801,10 @@ def testCoreProject_Methods(monkeypatch, nwMinimal, dummyGUI, tmpDir): theProject.projTree["8c659a11cd429"].setStatus("Finished") newList = [ ("New", 1, 1, 1, "New"), - ("Draft", 2, 2, 2, "Note"), # These are swapped - ("Note", 3, 3, 3, "Draft"), # These are swapped - ("Edited", 4, 4, 4, "Finished"), # Renamed - ("Finished", 5, 5, 5, None), # New, with reused name + ("Draft", 2, 2, 2, "Note"), # These are swapped + ("Note", 3, 3, 3, "Draft"), # These are swapped + ("Edited", 4, 4, 4, "Finished"), # Renamed + ("Finished", 5, 5, 5, None), # New, with reused name ] assert theProject.setStatusColours(newList) assert theProject.statusItems._theLabels == [ @@ -813,10 +813,10 @@ def testCoreProject_Methods(monkeypatch, nwMinimal, dummyGUI, tmpDir): assert theProject.statusItems._theColours == [ (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5) ] - assert theProject.projTree["a35baf2e93843"].itemStatus == "Edited" # Renamed - assert theProject.projTree["a6d311a93600a"].itemStatus == "Note" # Swapped - assert theProject.projTree["f5ab3e30151e1"].itemStatus == "Draft" # Swapped - assert theProject.projTree["8c659a11cd429"].itemStatus == "Edited" # Renamed + assert theProject.projTree["a35baf2e93843"].itemStatus == "Edited" # Renamed + assert theProject.projTree["a6d311a93600a"].itemStatus == "Note" # Swapped + assert theProject.projTree["f5ab3e30151e1"].itemStatus == "Draft" # Swapped + assert theProject.projTree["8c659a11cd429"].itemStatus == "Edited" # Renamed # Change importance fHandle = theProject.newFile("Jane Doe", nwItemClass.CHARACTER, "afb3043c7b2b3") @@ -851,7 +851,7 @@ def testCoreProject_Methods(monkeypatch, nwMinimal, dummyGUI, tmpDir): # Session stats with monkeypatch.context() as mp: - mp.setattr("os.path.isdir", lambda *args, **kwargs: False) + mp.setattr("os.path.isdir", lambda *a, **k: False) assert not theProject._appendSessionStats(idleTime=0) # Block open diff --git a/tests/test_core/test_core_tree.py b/tests/test_core/test_core_tree.py index 443525a6..6be08c31 100644 --- a/tests/test_core/test_core_tree.py +++ b/tests/test_core/test_core_tree.py @@ -274,9 +274,9 @@ def testCoreTree_UpdateItemLayout(dummyGUI, dummyItems): assert len(theTree) == len(dummyItems) # Check rejected items - assert not theTree.updateItemLayout("0000000000000", "H1") # Non-existent handle - assert not theTree.updateItemLayout("a000000000004", "H2") # Character file - assert not theTree.updateItemLayout("c000000000002", "H0") # Wrong header level + assert not theTree.updateItemLayout("0000000000000", "H1") # Non-existent handle + assert not theTree.updateItemLayout("a000000000004", "H2") # Character file + assert not theTree.updateItemLayout("c000000000002", "H0") # Wrong header level cHandle = "c000000000002" diff --git a/tests/test_dialogs/test_dlg_about.py b/tests/test_dialogs/test_dlg_about.py index 4b9ed5ee..bf2c18af 100644 --- a/tests/test_dialogs/test_dlg_about.py +++ b/tests/test_dialogs/test_dlg_about.py @@ -37,7 +37,7 @@ def testDlgAbout_Dialog(qtbot, monkeypatch, nwGUI): """Test the full about dialogs. """ # NW About - monkeypatch.setattr(GuiAbout, "exec_", lambda *args: None) + monkeypatch.setattr(GuiAbout, "exec_", lambda *a: None) nwGUI.mainMenu.aAboutNW.activate(QAction.Trigger) qtbot.waitUntil(lambda: getGuiItem("GuiAbout") is not None, timeout=1000) @@ -61,7 +61,7 @@ def testDlgAbout_Dialog(qtbot, monkeypatch, nwGUI): assert msgAbout.tabBox.currentWidget() == msgAbout.pageNotes # Qt About - monkeypatch.setattr(QMessageBox, "aboutQt", lambda *args, **kwargs: None) + monkeypatch.setattr(QMessageBox, "aboutQt", lambda *a, **k: None) nwGUI.mainMenu.aAboutQt.activate(QAction.Trigger) # qtbot.stopForInteraction() diff --git a/tests/test_dialogs/test_dlg_dialogs.py b/tests/test_dialogs/test_dlg_dialogs.py index 7faa48b1..1d8033b0 100644 --- a/tests/test_dialogs/test_dlg_dialogs.py +++ b/tests/test_dialogs/test_dlg_dialogs.py @@ -32,11 +32,11 @@ stepDelay = 20 @pytest.mark.gui -def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI, nwMinimal): +def testDlgOther_QuoteSelect(monkeypatch, nwGUI): """Test the quote symbols dialog. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) nwQuot = GuiQuoteSelect(nwGUI) nwQuot.show() diff --git a/tests/test_dialogs/test_dlg_itemeditor.py b/tests/test_dialogs/test_dlg_itemeditor.py index d955b1f4..2a61444c 100644 --- a/tests/test_dialogs/test_dlg_itemeditor.py +++ b/tests/test_dialogs/test_dlg_itemeditor.py @@ -37,7 +37,7 @@ stepDelay = 20 @pytest.mark.gui -def testDlgItemEditor_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir, outDir): +def testDlgItemEditor_Dialog(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir): """Test the full item editor dialog. """ projFile = os.path.join(fncProj, "nwProject.nwx") @@ -45,8 +45,8 @@ def testDlgItemEditor_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir, compFile = os.path.join(refDir, "guiItemEditor_Dialog_nwProject.nwx") # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True) # Create new, save, open project nwGUI.theProject.projTree.setSeed(42) @@ -54,7 +54,7 @@ def testDlgItemEditor_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir, assert nwGUI.openDocument("0e17daca5f3e1") assert nwGUI.treeView.setSelectedHandle("0e17daca5f3e1", doScroll=True) - monkeypatch.setattr(GuiItemEditor, "exec_", lambda *args: None) + monkeypatch.setattr(GuiItemEditor, "exec_", lambda *a: None) nwGUI.mainMenu.aEditItem.activate(QAction.Trigger) qtbot.waitUntil(lambda: getGuiItem("GuiItemEditor") is not None, timeout=1000) diff --git a/tests/test_dialogs/test_dlg_merge.py b/tests/test_dialogs/test_dlg_merge.py index 8cc0eda9..5bcf6906 100644 --- a/tests/test_dialogs/test_dlg_merge.py +++ b/tests/test_dialogs/test_dlg_merge.py @@ -37,7 +37,7 @@ stepDelay = 20 @pytest.mark.gui -def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj): +def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj): """Test the merge documents tool. """ # Block message box diff --git a/tests/test_dialogs/test_dlg_preferences.py b/tests/test_dialogs/test_dlg_preferences.py index 5ba8cdc2..2e89f63c 100644 --- a/tests/test_dialogs/test_dlg_preferences.py +++ b/tests/test_dialogs/test_dlg_preferences.py @@ -45,8 +45,8 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir): """Test the load project wizard. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) # Must create a clean config and GUI object as the test-wide # nw.CONFIG object is created on import an can be tainted by other tests @@ -69,8 +69,8 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir): assert theConf.confPath == fncDir theConf.spellTool = nwConst.SP_INTERNAL - monkeypatch.setattr(GuiPreferences, "exec_", lambda *args: None) - monkeypatch.setattr(GuiPreferences, "result", lambda *args: QDialog.Accepted) + monkeypatch.setattr(GuiPreferences, "exec_", lambda *a: None) + monkeypatch.setattr(GuiPreferences, "result", lambda *a: QDialog.Accepted) nwGUI.mainMenu.aPreferences.activate(QAction.Trigger) qtbot.waitUntil(lambda: getGuiItem("GuiPreferences") is not None, timeout=1000) @@ -125,9 +125,9 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir): # qtbot.stopForInteraction() # Check Browse button - monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "") + monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: "") assert not tabProjects._backupFolder() - monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "some/dir") + monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: "some/dir") qtbot.mouseClick(tabProjects.backupGetPath, Qt.LeftButton) qtbot.wait(keyDelay) diff --git a/tests/test_dialogs/test_dlg_projload.py b/tests/test_dialogs/test_dlg_projload.py index f02e4354..0dcc6d79 100644 --- a/tests/test_dialogs/test_dlg_projload.py +++ b/tests/test_dialogs/test_dlg_projload.py @@ -48,8 +48,8 @@ def testDlgLoadProject_Main(qtbot, monkeypatch, nwGUI, nwMinimal): assert nwGUI.closeProject() qtbot.wait(stepDelay) - monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *args: None) - monkeypatch.setattr(GuiProjectLoad, "result", lambda *args: QDialog.Accepted) + monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *a: None) + monkeypatch.setattr(GuiProjectLoad, "result", lambda *a: QDialog.Accepted) nwGUI.mainMenu.aOpenProject.activate(QAction.Trigger) qtbot.waitUntil(lambda: getGuiItem("GuiProjectLoad") is not None, timeout=1000) @@ -106,7 +106,7 @@ def testDlgLoadProject_Main(qtbot, monkeypatch, nwGUI, nwMinimal): assert nwLoad.listBox.topLevelItemCount() == recentCount - 1 getFile = os.path.join(nwMinimal, "nwProject.nwx") - monkeypatch.setattr(QFileDialog, "getOpenFileName", lambda *args, **kwargs: (getFile, None)) + monkeypatch.setattr(QFileDialog, "getOpenFileName", lambda *a, **k: (getFile, None)) qtbot.mouseClick(nwLoad.browseButton, Qt.LeftButton) assert nwLoad.openPath == nwMinimal assert nwLoad.openState == nwLoad.OPEN_STATE diff --git a/tests/test_dialogs/test_dlg_projsettings.py b/tests/test_dialogs/test_dlg_projsettings.py index bdceb4bd..acdfad21 100644 --- a/tests/test_dialogs/test_dlg_projsettings.py +++ b/tests/test_dialogs/test_dlg_projsettings.py @@ -47,8 +47,8 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, outDi compFile = os.path.join(refDir, "guiProjSettings_Dialog_nwProject.nwx") # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "critical", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes) # Check that we cannot open when there is no project nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger) @@ -64,8 +64,8 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, outDi nwGUI.theProject.setAutoReplace({"A": "B", "C": "D"}) # Get the dialog object - monkeypatch.setattr(GuiProjectSettings, "exec_", lambda *args: None) - monkeypatch.setattr(GuiProjectSettings, "result", lambda *args: QDialog.Accepted) + monkeypatch.setattr(GuiProjectSettings, "exec_", lambda *a: None) + monkeypatch.setattr(GuiProjectSettings, "result", lambda *a: QDialog.Accepted) nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger) qtbot.waitUntil(lambda: getGuiItem("GuiProjectSettings") is not None, timeout=1000) @@ -135,7 +135,7 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, outDi assert projEdit.tabStatus.listBox.topLevelItemCount() == 3 # Add a new item - monkeypatch.setattr(QColorDialog, "getColor", lambda *args: QColor(20, 30, 40)) + monkeypatch.setattr(QColorDialog, "getColor", lambda *a: QColor(20, 30, 40)) qtbot.mouseClick(projEdit.tabStatus.addButton, Qt.LeftButton) projEdit.tabStatus.listBox.topLevelItem(3).setSelected(True) for n in range(8): diff --git a/tests/test_dialogs/test_dlg_split.py b/tests/test_dialogs/test_dlg_split.py index 588cba24..1c761615 100644 --- a/tests/test_dialogs/test_dlg_split.py +++ b/tests/test_dialogs/test_dlg_split.py @@ -38,7 +38,7 @@ stepDelay = 20 @pytest.mark.gui -def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj): +def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, fncProj): """Test the split document tool. """ # Block message box diff --git a/tests/test_dialogs/test_dlg_wordlist.py b/tests/test_dialogs/test_dlg_wordlist.py index 79baaab7..c854f073 100644 --- a/tests/test_dialogs/test_dlg_wordlist.py +++ b/tests/test_dialogs/test_dlg_wordlist.py @@ -20,6 +20,7 @@ along with this program. If not, see . """ import os +import pytest from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog, QMessageBox, QAction @@ -35,14 +36,15 @@ typeDelay = 1 stepDelay = 20 -def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, nwMinimal, tmpDir): +@pytest.mark.gui +def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, nwMinimal): """test the word list editor. """ - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "critical", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(GuiWordList, "exec_", lambda *args: None) - monkeypatch.setattr(GuiWordList, "result", lambda *args: QDialog.Accepted) - monkeypatch.setattr(GuiWordList, "accept", lambda *args: None) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(GuiWordList, "exec_", lambda *a: None) + monkeypatch.setattr(GuiWordList, "result", lambda *a: QDialog.Accepted) + monkeypatch.setattr(GuiWordList, "accept", lambda *a: None) # Open project nwGUI.openProject(nwMinimal) @@ -66,7 +68,7 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, nwMinimal, tmpDir): "word_a\n" "word_c\n" "word_g\n" - " \n" # Should be ignored + " \n" # Should be ignored "word_f\n" "word_b\n" )) diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index 176c0276..aee859a3 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -19,8 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ -import pytest import os +import pytest from shutil import copyfile from tools import cmpFiles @@ -44,12 +44,12 @@ def testGuiEditor_Main(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir): """Test the document editor. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(GuiItemEditor, "exec_", lambda *args: None) - monkeypatch.setattr(GuiItemEditor, "result", lambda *args: QDialog.Accepted) - monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True) - monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *args: True) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(GuiItemEditor, "exec_", lambda *a: None) + monkeypatch.setattr(GuiItemEditor, "result", lambda *a: QDialog.Accepted) + monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True) + monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True) # Create new, save, close project nwGUI.theProject.projTree.setSeed(42) @@ -315,7 +315,7 @@ def testGuiEditor_Main(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir): assert nwGUI.treeView.deleteItem() assert nwGUI.treeView.setSelectedHandle(newHandle) assert nwGUI.treeView.deleteItem() - assert nwGUI.theProject.projTree["2fca346db6561"] is not None # Trash + assert nwGUI.theProject.projTree["2fca346db6561"] is not None # Trash assert nwGUI.saveProject() # Check the files @@ -359,8 +359,8 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum): """Test the document editor search functionality. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *args: True) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True) nwGUI.theProject.projTree.setSeed(42) assert nwGUI.openProject(nwLipsum) @@ -415,7 +415,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum): # Set Invalid RegEx assert nwGUI.docEditor.docSearch.setSearchText(r"\bSus[") qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=keyDelay) - assert nwGUI.docEditor.getCursorPosition() < 3 # No result + assert nwGUI.docEditor.getCursorPosition() < 3 # No result # Set Valid RegEx assert nwGUI.docEditor.docSearch.setSearchText(r"\bSus") @@ -504,7 +504,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, nwLipsum): # Next Match nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) - assert nwGUI.docEditor.docHandle() == "2426c6f0ca922" # Next document + assert nwGUI.docEditor.docHandle() == "2426c6f0ca922" # Next document nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) assert abs(nwGUI.docEditor.getCursorPosition() - 620) < 3 nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) diff --git a/tests/test_gui/test_gui_docviewer.py b/tests/test_gui/test_gui_docviewer.py index 86ccac26..98276853 100644 --- a/tests/test_gui/test_gui_docviewer.py +++ b/tests/test_gui/test_gui_docviewer.py @@ -37,8 +37,8 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum): """Test the document viewer. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) # Open project nwGUI.theProject.projTree.setSeed(42) diff --git a/tests/test_gui/test_gui_noveltree.py b/tests/test_gui/test_gui_noveltree.py index a991f939..aae675d8 100644 --- a/tests/test_gui/test_gui_noveltree.py +++ b/tests/test_gui/test_gui_noveltree.py @@ -29,12 +29,12 @@ from PyQt5.QtWidgets import QMessageBox @pytest.mark.gui -def testGuiNovelTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal): +def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, nwMinimal): """Test navigating the novel tree. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) nwGUI.openProject(nwMinimal) nwGUI.theProject.projTree.setSeed(42) diff --git a/tests/test_gui/test_gui_outline.py b/tests/test_gui/test_gui_outline.py index 21e13b94..83a9d57f 100644 --- a/tests/test_gui/test_gui_outline.py +++ b/tests/test_gui/test_gui_outline.py @@ -36,8 +36,8 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, nwLipsum): """Test the outline view. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) assert nwGUI.openProject(nwLipsum) nwGUI.mainConf.lastPath = nwLipsum diff --git a/tests/test_gui/test_gui_projdetails.py b/tests/test_gui/test_gui_projdetails.py index bb523cf1..ae20e613 100644 --- a/tests/test_gui/test_gui_projdetails.py +++ b/tests/test_gui/test_gui_projdetails.py @@ -37,10 +37,10 @@ def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum): """Test the project details dialog. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "warning", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "critical", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes) # Create a project to work on assert nwGUI.openProject(nwLipsum) diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py index 7652657f..f73de6d6 100644 --- a/tests/test_gui/test_gui_projtree.py +++ b/tests/test_gui/test_gui_projtree.py @@ -37,11 +37,11 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal): """Test adding and removing items from the project tree. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "critical", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "warning", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(GuiMain, "editItem", lambda *args: None) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(GuiMain, "editItem", lambda *a: None) nwGUI.theProject.projTree.setSeed(42) nwTree = nwGUI.treeView @@ -82,8 +82,8 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal): ] # Add roots - assert not nwTree.newTreeItem(nwItemType.ROOT, nwItemClass.WORLD) # Duplicate - assert nwTree.newTreeItem(nwItemType.ROOT, nwItemClass.CUSTOM) # Valid + assert not nwTree.newTreeItem(nwItemType.ROOT, nwItemClass.WORLD) # Duplicate + assert nwTree.newTreeItem(nwItemType.ROOT, nwItemClass.CUSTOM) # Valid # Change max depth and try to add a subfolder that is too deep monkeypatch.setattr("nw.constants.nwConst.MAX_DEPTH", 2) @@ -98,12 +98,12 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal): nwTree.setSelectedHandle("8c659a11cd429") # Shift focus and try to move item - monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: False) + monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: False) assert not nwTree.moveTreeItem(1) assert nwTree.getTreeFromHandle("a6d311a93600a") == [ "a6d311a93600a", "f5ab3e30151e1", "8c659a11cd429", "44cb730c42048", "71ee45a3c0db9" ] - monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True) + monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True) # Move second item up twice (should give same result) nwGUI.mainMenu.aMoveUp.activate(QAction.Trigger) @@ -168,12 +168,12 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal): # Delete the items we added earlier nwTree.clearSelection() - assert not nwTree.emptyTrash() # No folder yet + assert not nwTree.emptyTrash() # No folder yet assert not nwTree.deleteItem(None) assert not nwTree.deleteItem("1111111111111") - assert nwTree.deleteItem("73475cb40a568") # New File - assert nwTree.deleteItem("71ee45a3c0db9") # New Folder - assert nwTree.deleteItem("811786ad1ae74") # Custom Root + assert nwTree.deleteItem("73475cb40a568") # New File + assert nwTree.deleteItem("71ee45a3c0db9") # New Folder + assert nwTree.deleteItem("811786ad1ae74") # Custom Root assert "73475cb40a568" in nwGUI.theProject.projTree._treeOrder assert "71ee45a3c0db9" not in nwGUI.theProject.projTree._treeOrder assert "811786ad1ae74" not in nwGUI.theProject.projTree._treeOrder @@ -181,7 +181,7 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal): # The file is in trash, empty it assert os.path.isfile(os.path.join(nwMinimal, "content", "73475cb40a568.nwd")) assert nwTree.emptyTrash() - assert not nwTree.emptyTrash() # Already empty + assert not nwTree.emptyTrash() # Already empty assert not os.path.isfile(os.path.join(nwMinimal, "content", "73475cb40a568.nwd")) assert "73475cb40a568" not in nwGUI.theProject.projTree._treeOrder @@ -228,7 +228,7 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal): nwTree.clearSelection() # Add a file with no parent, and fail to find a suitable parent item - monkeypatch.setattr("nw.core.tree.NWTree.findRoot", lambda *args: None) + monkeypatch.setattr("nw.core.tree.NWTree.findRoot", lambda *a: None) assert not nwTree.newTreeItem(nwItemType.FILE, nwItemClass.NOVEL) assert not nwTree.newTreeItem(nwItemType.FOLDER, nwItemClass.NOVEL) diff --git a/tests/test_gui/test_gui_theme.py b/tests/test_gui/test_gui_theme.py index 875d2bf6..b9fc1f69 100644 --- a/tests/test_gui/test_gui_theme.py +++ b/tests/test_gui/test_gui_theme.py @@ -35,7 +35,7 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir): """Test the theme and icon classes. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) nwGUI = nw.main(["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir, nwMinimal]) qtbot.addWidget(nwGUI) diff --git a/tests/test_tools/test_tools_build.py b/tests/test_tools/test_tools_build.py index 56ba58c3..f91625c7 100644 --- a/tests/test_tools/test_tools_build.py +++ b/tests/test_tools/test_tools_build.py @@ -40,9 +40,9 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir): """Test the build tool. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda a, b, c, **kwargs: (c, None)) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda a, b, c, **k: (c, None)) # Check that we cannot open when there is no project nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger) @@ -69,7 +69,7 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir): # Non-existent path with monkeypatch.context() as mp: - mp.setattr("os.path.expanduser", lambda *args, **kwargs: nwLipsum) + mp.setattr("os.path.expanduser", lambda *a, **k: nwLipsum) assert nwGUI.mainConf.lastPath != nwLipsum nwGUI.mainConf.lastPath = "no_such_path" assert nwBuild._saveDocument(nwBuild.FMT_NWD) @@ -77,7 +77,7 @@ def testToolBuild_Main(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir): # No path selected with monkeypatch.context() as mp: - mp.setattr(QFileDialog, "getSaveFileName", lambda *args, **kwargs: ("", "")) + mp.setattr(QFileDialog, "getSaveFileName", lambda *a, **k: ("", "")) assert not nwBuild._saveDocument(nwBuild.FMT_NWD) # Default Settings diff --git a/tests/test_tools/test_tools_projwizard.py b/tests/test_tools/test_tools_projwizard.py index 79d41692..2e6a76d4 100644 --- a/tests/test_tools/test_tools_projwizard.py +++ b/tests/test_tools/test_tools_projwizard.py @@ -44,8 +44,8 @@ def testToolProjectWizard_Main(qtbot, monkeypatch, nwGUI, nwMinimal): """Test the new project wizard. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "critical", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes) if sys.platform.startswith("darwin"): # Disable for macOS because the test segfaults on QWizard.show() @@ -62,22 +62,22 @@ def testToolProjectWizard_Main(qtbot, monkeypatch, nwGUI, nwMinimal): # Close project, but call with invalid path assert nwGUI.closeProject() with monkeypatch.context() as mp: - mp.setattr(nwGUI, "showNewProjectDialog", lambda *args: None) + mp.setattr(nwGUI, "showNewProjectDialog", lambda *a: None) assert not nwGUI.newProject() # Now, with an empty dictionary - mp.setattr(nwGUI, "showNewProjectDialog", lambda *args: {}) + mp.setattr(nwGUI, "showNewProjectDialog", lambda *a: {}) assert not nwGUI.newProject() # Now, with a non-empty folder - mp.setattr(nwGUI, "showNewProjectDialog", lambda *args: {"projPath": nwMinimal}) + mp.setattr(nwGUI, "showNewProjectDialog", lambda *a: {"projPath": nwMinimal}) assert not nwGUI.newProject() ## # Test the Wizard ## - monkeypatch.setattr(GuiProjectWizard, "exec_", lambda *args: None) + monkeypatch.setattr(GuiProjectWizard, "exec_", lambda *a: None) nwGUI.mainConf.lastPath = " " nwGUI.closeProject() @@ -184,7 +184,7 @@ def testToolProjectWizard_Main(qtbot, monkeypatch, nwGUI, nwMinimal): # Final Page finalPage = nwWiz.currentPage() assert isinstance(finalPage, ProjWizardFinalPage) - assert nwWiz.button(QWizard.FinishButton).isEnabled() # But we don't click it + assert nwWiz.button(QWizard.FinishButton).isEnabled() # But we don't click it # Check Data projData = nwGUI._assembleProjectWizardData(nwWiz) diff --git a/tests/test_tools/test_tools_writingstats.py b/tests/test_tools/test_tools_writingstats.py index 09008d96..995bc2fb 100644 --- a/tests/test_tools/test_tools_writingstats.py +++ b/tests/test_tools/test_tools_writingstats.py @@ -42,10 +42,10 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj): """Test the full writing stats tool. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "warning", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(QMessageBox, "critical", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Yes) # Create a project to work on assert nwGUI.newProject({"projPath": fncProj}) @@ -116,13 +116,13 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj): sessLog.populateGUI() # Make the saving fail - monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda *args, **kwargs: ("", "")) + monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda *a, **k: ("", "")) assert not sessLog._saveData(sessLog.FMT_CSV) assert not sessLog._saveData(sessLog.FMT_JSON) assert not sessLog._saveData(None) # Make the save succeed - monkeypatch.setattr("os.path.expanduser", lambda *args: fncDir) + monkeypatch.setattr("os.path.expanduser", lambda *a: fncDir) monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda ss, tt, pp, options: (pp, "")) sessLog.listBox.sortByColumn(sessLog.C_TIME, 0)