From 318e90f89318585c120fab1320045979ae457952 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 2 Jul 2018 22:38:47 +0200 Subject: [PATCH] Fixes for pycodestyle --- openlp/core/api/endpoint/pluginhelpers.py | 2 +- openlp/core/api/tab.py | 2 +- openlp/core/lib/__init__.py | 2 +- openlp/core/projectors/pjlink.py | 2 +- openlp/core/ui/media/__init__.py | 2 +- openlp/plugins/bibles/forms/editbibleform.py | 2 +- openlp/plugins/bibles/lib/__init__.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 2 +- .../media/forms/mediaclipselectorform.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 4 ++-- openlp/plugins/songs/lib/__init__.py | 4 ++-- .../plugins/songs/lib/importers/easyslides.py | 4 ++-- .../songs/lib/importers/foilpresenter.py | 24 +++++++++---------- openlp/plugins/songs/lib/importers/lyrix.py | 2 +- .../plugins/songs/lib/importers/opensong.py | 6 ++--- openlp/plugins/songs/lib/importers/opspro.py | 22 ++++++++--------- .../lib/importers/presentationmanager.py | 2 +- .../songs/lib/importers/songsoffellowship.py | 2 +- .../songs/lib/importers/worshipassistant.py | 2 +- scripts/lp-merge.py | 2 +- setup.cfg | 7 +++++- tests/functional/openlp_core/api/test_tab.py | 2 +- .../openlp_core/common/test_init.py | 2 +- .../openlp_core/ui/test_filerenamedialog.py | 2 +- 24 files changed, 55 insertions(+), 50 deletions(-) diff --git a/openlp/core/api/endpoint/pluginhelpers.py b/openlp/core/api/endpoint/pluginhelpers.py index a74fa524a..75dc8e8e6 100644 --- a/openlp/core/api/endpoint/pluginhelpers.py +++ b/openlp/core/api/endpoint/pluginhelpers.py @@ -115,7 +115,7 @@ def display_thumbnails(request, controller_name, log, dimensions, file_name, sli height = -1 image = None if dimensions: - match = re.search('(\d+)x(\d+)', dimensions) + match = re.search(r'(\d+)x(\d+)', dimensions) if match: # let's make sure that the dimensions are within reason width = sorted([10, int(match.group(1)), 1000])[1] diff --git a/openlp/core/api/tab.py b/openlp/core/api/tab.py index 840fb0d0b..722c7547a 100644 --- a/openlp/core/api/tab.py +++ b/openlp/core/api/tab.py @@ -55,7 +55,7 @@ class ApiTab(SettingsTab): self.address_label.setObjectName('address_label') self.address_edit = QtWidgets.QLineEdit(self.server_settings_group_box) self.address_edit.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) - self.address_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), + self.address_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), self)) self.address_edit.setObjectName('address_edit') self.server_settings_layout.addRow(self.address_label, self.address_edit) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index bcc87c19e..c4aa92702 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -415,7 +415,7 @@ def expand_chords(text): chords_on_prev_line = True # Matches a chord, a tail, a remainder and a line end. See expand_and_align_chords_in_line() for more info. new_line += re.sub(r'\[(.*?)\]([\u0080-\uFFFF,\w]*)' - '([\u0080-\uFFFF,\w,\s,\.,\,,\!,\?,\;,\:,\|,\",\',\-,\_]*)(\Z)?', + r'([\u0080-\uFFFF,\w,\s,\.,\,,\!,\?,\;,\:,\|,\",\',\-,\_]*)(\Z)?', expand_and_align_chords_in_line, line) new_line += '' expanded_text_lines.append(new_line) diff --git a/openlp/core/projectors/pjlink.py b/openlp/core/projectors/pjlink.py index b2b23a188..3ea1bb414 100644 --- a/openlp/core/projectors/pjlink.py +++ b/openlp/core/projectors/pjlink.py @@ -338,7 +338,7 @@ class PJLinkCommands(object): # Due to stupid projectors not following standards (Optoma, BenQ comes to mind), # AND the different responses that can be received, the semi-permanent way to # fix the class reply is to just remove all non-digit characters. - chk = re.findall('\d', data) + chk = re.findall(r'\d', data) if len(chk) < 1: log.error('({ip}) No numbers found in class version reply "{data}" - ' 'defaulting to class "1"'.format(ip=self.entry.name, data=data)) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index da80aee5f..976e0b744 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -80,7 +80,7 @@ def get_media_players(): """ log.debug('get_media_players') saved_players = Settings().value('media/players') - reg_ex = QtCore.QRegExp(".*\[(.*)\].*") + reg_ex = QtCore.QRegExp(r'.*\[(.*)\].*') if Settings().value('media/override player') == QtCore.Qt.Checked: if reg_ex.exactMatch(saved_players): overridden_player = '{text}'.format(text=reg_ex.cap(1)) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index bc89827d2..086a65ceb 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -183,7 +183,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): """ Validate a book. """ - book_regex = re.compile('[\d]*[^\d]+$') + book_regex = re.compile(r'[\d]*[^\d]+$') if not new_book_name: self.book_name_edit[abbreviation].setFocus() critical_error_message_box( diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 73c1ca68d..da6913647 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -217,7 +217,7 @@ def update_reference_separators(): # add various Unicode alternatives source_string = source_string.replace('-', '(?:[-\u00AD\u2010\u2011\u2012\u2014\u2014\u2212\uFE63\uFF0D])') source_string = source_string.replace(',', '(?:[,\u201A])') - REFERENCE_SEPARATORS['sep_{role}'.format(role=role)] = '\s*(?:{source})\s*'.format(source=source_string) + REFERENCE_SEPARATORS['sep_{role}'.format(role=role)] = r'\s*(?:{source})\s*'.format(source=source_string) REFERENCE_SEPARATORS['sep_{role}_default'.format(role=role)] = default_separators[index] # verse range match: (:)?(-((:)?|end)?)? range_regex = '(?:(?P[0-9]+){sep_v})?' \ diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c2cbec7ae..2f42a05ac 100755 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -41,7 +41,7 @@ from openlp.plugins.bibles.lib import DisplayStyle, LayoutStyle, VerseReferenceL log = logging.getLogger(__name__) -VALID_TEXT_SEARCH = re.compile('\w\w\w') +VALID_TEXT_SEARCH = re.compile(r'\w\w\w') def get_reference_separators(): diff --git a/openlp/plugins/media/forms/mediaclipselectorform.py b/openlp/plugins/media/forms/mediaclipselectorform.py index 7c0db8db7..462aebd08 100644 --- a/openlp/plugins/media/forms/mediaclipselectorform.py +++ b/openlp/plugins/media/forms/mediaclipselectorform.py @@ -210,7 +210,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro # detect if we're dealing with a DVD or CD, so we use different loading approaches depending on the OS. if is_win(): # If the given path is in the format "D:\" or "D:", prefix it with "/" to make VLC happy - pattern = re.compile('^\w:\\\\*$') + pattern = re.compile(r'^\w:\\\\*$') if pattern.match(path): path = '/' + path self.vlc_media = self.vlc_instance.media_new_location('dvd://' + path) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 36b144aef..53aa443bb 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -105,7 +105,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): self.topics_list_view.setSortingEnabled(False) self.topics_list_view.setAlternatingRowColors(True) self.audio_list_widget.setAlternatingRowColors(True) - self.find_verse_split = re.compile('---\[\]---\n') + self.find_verse_split = re.compile(r'---\[\]---\n') self.whitespace = re.compile(r'\W+') self.find_tags = re.compile(r'\{/?\w+\}') @@ -316,7 +316,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): multiple.append(verse_tag) self.song.lyrics = str(sxml.extract_xml(), 'utf-8') for verse in multiple: - self.song.verse_order = re.sub('([' + verse.upper() + verse.lower() + '])(\W|$)', + self.song.verse_order = re.sub(r'([' + verse.upper() + verse.lower() + r'])(\W|$)', r'\g<1>1\2', self.song.verse_order) except: log.exception('Problem processing song Lyrics \n{xml}'.format(xml=sxml.dump_xml())) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 2578d0f92..c86d822fd 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -557,7 +557,7 @@ def transpose_lyrics(lyrics, transpose_value): :return: The transposed lyrics """ # Split text by verse delimiter - both normal and optional - verse_list = re.split('(---\[.+?:.+?\]---|\[---\])', lyrics) + verse_list = re.split(r'(---\[.+?:.+?\]---|\[---\])', lyrics) transposed_lyrics = '' notation = Settings().value('songs/chord notation') for verse in verse_list: @@ -580,7 +580,7 @@ def transpose_verse(verse_text, transpose_value, notation): if '[' not in verse_text: return verse_text # Split the lyrics based on chord tags - lyric_list = re.split('(\[|\]|/)', verse_text) + lyric_list = re.split(r'(\[|\]|/)', verse_text) transposed_lyrics = '' in_tag = False for word in lyric_list: diff --git a/openlp/plugins/songs/lib/importers/easyslides.py b/openlp/plugins/songs/lib/importers/easyslides.py index 8f847c5f3..4a6fc5bf8 100644 --- a/openlp/plugins/songs/lib/importers/easyslides.py +++ b/openlp/plugins/songs/lib/importers/easyslides.py @@ -37,7 +37,7 @@ class EasySlidesImport(SongImport): Import songs exported from EasySlides The format example is here: - http://wiki.openlp.org/Development:EasySlides\_-_Song_Data_Format + http://wiki.openlp.org/Development:EasySlides_-_Song_Data_Format """ def __init__(self, manager, **kwargs): """ @@ -210,7 +210,7 @@ class EasySlidesImport(SongImport): vn = '1' # have we got any digits? # If so, versenumber is everything from the digits to the end - match = re.match('(.*)(\d+.*)', marker) + match = re.match(r'(.*)(\d+.*)', marker) if match: marker = match.group(1).strip() vn = match.group(2) diff --git a/openlp/plugins/songs/lib/importers/foilpresenter.py b/openlp/plugins/songs/lib/importers/foilpresenter.py index 82601f18b..5458b1fad 100644 --- a/openlp/plugins/songs/lib/importers/foilpresenter.py +++ b/openlp/plugins/songs/lib/importers/foilpresenter.py @@ -273,15 +273,15 @@ class FoilPresenter(object): elif copyright.find('C,)') != -1: temp = copyright.partition('C,)') copyright = temp[0] - copyright = re.compile('\\n').sub(' ', copyright) - copyright = re.compile('\(.*\)').sub('', copyright) + copyright = re.compile(r'\\n').sub(' ', copyright) + copyright = re.compile(r'\(.*\)').sub('', copyright) if copyright.find('Rechte') != -1: temp = copyright.partition('Rechte') copyright = temp[0] - markers = ['Text +u\.?n?d? +Melodie[\w\,\. ]*:', - 'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz', - 'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz', - 'Weise', '[dD]eutsch', '[dD]t[\.\:]', 'Englisch', + markers = [r'Text +u\.?n?d? +Melodie[\w\,\. ]*:', + r'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz', + r'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz', + 'Weise', '[dD]eutsch', r'[dD]t[\.\:]', 'Englisch', '[oO]riginal', 'Bearbeitung', '[R|r]efrain'] for marker in markers: copyright = re.compile(marker).sub('', copyright, re.U) @@ -301,17 +301,17 @@ class FoilPresenter(object): break author_temp = [] for author in strings: - temp = re.split(',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author) + temp = re.split(r',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author) for tempx in temp: author_temp.append(tempx) for author in author_temp: - regex = '^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$' + regex = r'^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$' author = re.compile(regex).sub('', author) - author = re.compile('[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', author) - author = re.compile('[N|n]ach.*$').sub('', author) + author = re.compile(r'[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', author) + author = re.compile(r'[N|n]ach.*$').sub('', author) author = author.strip() - if re.search('\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U): - temp = re.split('\s[a|u]nd\s|\s&\s', author) + if re.search(r'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U): + temp = re.split(r'\s[a|u]nd\s|\s&\s', author) for tempx in temp: tempx = tempx.strip() authors.append(tempx) diff --git a/openlp/plugins/songs/lib/importers/lyrix.py b/openlp/plugins/songs/lib/importers/lyrix.py index 386fe43e2..e987b2502 100644 --- a/openlp/plugins/songs/lib/importers/lyrix.py +++ b/openlp/plugins/songs/lib/importers/lyrix.py @@ -80,7 +80,7 @@ class LyrixImport(SongImport): continue # Detect and get CCLI number if line.lower().startswith('ccli'): - ccli = re.findall('\d+', line)[0] + ccli = re.findall(r'\d+', line)[0] try: # If the CCLI was found, we are near the end # Find author diff --git a/openlp/plugins/songs/lib/importers/opensong.py b/openlp/plugins/songs/lib/importers/opensong.py index 25e52777a..470330b3b 100644 --- a/openlp/plugins/songs/lib/importers/opensong.py +++ b/openlp/plugins/songs/lib/importers/opensong.py @@ -156,7 +156,7 @@ class OpenSongImport(SongImport): ustring = str(root.__getattr__(attr)) if isinstance(fn_or_string, str): if attr in ['ccli']: - ustring = ''.join(re.findall('\d+', ustring)) + ustring = ''.join(re.findall(r'\d+', ustring)) if ustring: setattr(self, fn_or_string, int(ustring)) else: @@ -231,7 +231,7 @@ class OpenSongImport(SongImport): content = this_line[1:right_bracket].lower() # have we got any digits? If so, verse number is everything from the digits to the end (openlp does not # have concept of part verses, so just ignore any non integers on the end (including floats)) - match = re.match('(\D*)(\d+)', content) + match = re.match(r'(\D*)(\d+)', content) if match is not None: verse_tag = match.group(1) verse_num = match.group(2) @@ -303,7 +303,7 @@ class OpenSongImport(SongImport): # whitespace. order = order.lower().split() for verse_def in order: - match = re.match('(\D*)(\d+.*)', verse_def) + match = re.match(r'(\D*)(\d+.*)', verse_def) if match is not None: verse_tag = match.group(1) verse_num = match.group(2) diff --git a/openlp/plugins/songs/lib/importers/opspro.py b/openlp/plugins/songs/lib/importers/opspro.py index 5edcfdd39..c21bab2d2 100644 --- a/openlp/plugins/songs/lib/importers/opspro.py +++ b/openlp/plugins/songs/lib/importers/opspro.py @@ -122,7 +122,7 @@ class OPSProImport(SongImport): # Try to split lyrics based on various rules if lyrics: lyrics_text = lyrics.Lyrics - verses = re.split('\r\n\s*?\r\n', lyrics_text) + verses = re.split(r'\r\n\s*?\r\n', lyrics_text) verse_tag_defs = {} verse_tag_texts = {} for verse_text in verses: @@ -130,13 +130,13 @@ class OPSProImport(SongImport): continue verse_def = 'v' # Detect verse number - verse_number = re.match('^(\d+)\r\n', verse_text) + verse_number = re.match(r'^(\d+)\r\n', verse_text) if verse_number: - verse_text = re.sub('^\d+\r\n', '', verse_text) + verse_text = re.sub(r'^\d+\r\n', '', verse_text) verse_def = 'v' + verse_number.group(1) # Detect verse tags - elif re.match('^.+?\:\r\n', verse_text): - tag_match = re.match('^(.+?)\:\r\n(.*)', verse_text, flags=re.DOTALL) + elif re.match(r'^.+?\:\r\n', verse_text): + tag_match = re.match(r'^(.+?)\:\r\n(.*)', verse_text, flags=re.DOTALL) tag = tag_match.group(1).lower() tag = tag.split(' ')[0] verse_text = tag_match.group(2) @@ -147,25 +147,25 @@ class OPSProImport(SongImport): verse_tag_defs[tag] = verse_def verse_tag_texts[tag] = verse_text # Detect tag reference - elif re.match('^\(.*?\)$', verse_text): - tag_match = re.match('^\((.*?)\)$', verse_text) + elif re.match(r'^\(.*?\)$', verse_text): + tag_match = re.match(r'^\((.*?)\)$', verse_text) tag = tag_match.group(1).lower() if tag in verse_tag_defs: verse_text = verse_tag_texts[tag] verse_def = verse_tag_defs[tag] # Detect end tag - elif re.match('^\[slot\]\r\n', verse_text, re.IGNORECASE): + elif re.match(r'^\[slot\]\r\n', verse_text, re.IGNORECASE): verse_def = 'e' - verse_text = re.sub('^\[slot\]\r\n', '', verse_text, flags=re.IGNORECASE) + verse_text = re.sub(r'^\[slot\]\r\n', '', verse_text, flags=re.IGNORECASE) # Replace the join tag with line breaks verse_text = verse_text.replace('[join]', '') # Replace the split tag with line breaks and an optional split - verse_text = re.sub('\[splits?\]', '\r\n[---]', verse_text) + verse_text = re.sub(r'\[splits?\]', '\r\n[---]', verse_text) # Handle translations if lyrics.IsDualLanguage: verse_text = self.handle_translation(verse_text) # Remove comments - verse_text = re.sub('\(.*?\)\r\n', '', verse_text, flags=re.IGNORECASE) + verse_text = re.sub(r'\(.*?\)\r\n', '', verse_text, flags=re.IGNORECASE) self.add_verse(verse_text, verse_def) self.finish() diff --git a/openlp/plugins/songs/lib/importers/presentationmanager.py b/openlp/plugins/songs/lib/importers/presentationmanager.py index 9b16f24a6..49cd9e220 100644 --- a/openlp/plugins/songs/lib/importers/presentationmanager.py +++ b/openlp/plugins/songs/lib/importers/presentationmanager.py @@ -51,7 +51,7 @@ class PresentationManagerImport(SongImport): encoding = get_file_encoding(file_path)['encoding'] # Open file with detected encoding and remove encoding declaration text = file_path.read_text(encoding=encoding) - text = re.sub('.+\?>\n', '', text) + text = re.sub(r'.+\?>\n', '', text) try: tree = etree.fromstring(text, parser=etree.XMLParser(recover=True)) except ValueError: diff --git a/openlp/plugins/songs/lib/importers/songsoffellowship.py b/openlp/plugins/songs/lib/importers/songsoffellowship.py index d0c0a6720..a5d254252 100644 --- a/openlp/plugins/songs/lib/importers/songsoffellowship.py +++ b/openlp/plugins/songs/lib/importers/songsoffellowship.py @@ -333,7 +333,7 @@ class SongsOfFellowshipImport(OpenOfficeImport): There is a complicated word "One", which is sometimes lower and sometimes upper depending on context. Never mind, keep it lower. """ - text_arr = re.split('(\W+)', text) + text_arr = re.split(r'(\W+)', text) text_arr[0] = text_arr[0].capitalize() for i in range(1, len(text_arr)): # Do not translate these. Fixed strings in SOF song file diff --git a/openlp/plugins/songs/lib/importers/worshipassistant.py b/openlp/plugins/songs/lib/importers/worshipassistant.py index 02df16b4a..6f372876e 100644 --- a/openlp/plugins/songs/lib/importers/worshipassistant.py +++ b/openlp/plugins/songs/lib/importers/worshipassistant.py @@ -142,7 +142,7 @@ class WorshipAssistantImport(SongImport): # drop the square brackets right_bracket = line.find(']') content = line[1:right_bracket].lower() - match = re.match('(\D*)(\d+)', content) + match = re.match(r'(\D*)(\d+)', content) if match is not None: verse_tag = match.group(1) verse_num = match.group(2) diff --git a/scripts/lp-merge.py b/scripts/lp-merge.py index 9bb8ac17a..c10e9e0d2 100755 --- a/scripts/lp-merge.py +++ b/scripts/lp-merge.py @@ -124,7 +124,7 @@ def get_merge_info(url): script_tag = soup.find('script', attrs={"id": "codereview-script"}) content = script_tag.contents[0] start_pos = content.find('source_revid') + 16 - pattern = re.compile('.*\w-\d\d\d\d\d+') + pattern = re.compile(r'.*\w-\d\d\d\d\d+') match = pattern.match(content[start_pos:]) merge_info['author_email'] = match.group()[:-15] # Launchpad doesn't supply the author's true name, so we'll just grab whatever they use for display on LP diff --git a/setup.cfg b/setup.cfg index e2ef020e0..223e5c7c2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,5 +15,10 @@ ignore = E402 [pycodestyle] exclude = resources.py,vlc.py max-line-length = 120 -ignore = E402 +# Ignoring: +# E402... +# E722 do not use bare 'except' +# W503 line break before binary operator +# W504 line break after binary operator +ignore = E402,E722,W503,W504 diff --git a/tests/functional/openlp_core/api/test_tab.py b/tests/functional/openlp_core/api/test_tab.py index cf8b4d0b0..e2c93f32e 100644 --- a/tests/functional/openlp_core/api/test_tab.py +++ b/tests/functional/openlp_core/api/test_tab.py @@ -87,7 +87,7 @@ class TestApiTab(TestCase, TestMixin): ip_address = self.form.get_ip_address(ZERO_URL) # THEN: the default ip address will be returned - assert re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address), \ + assert re.match(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address), \ 'The return value should be a valid ip address' assert ip_address in ip4_list, 'The return address should be in the list of local IP addresses' diff --git a/tests/functional/openlp_core/common/test_init.py b/tests/functional/openlp_core/common/test_init.py index 83f0c1c7c..6256517d0 100644 --- a/tests/functional/openlp_core/common/test_init.py +++ b/tests/functional/openlp_core/common/test_init.py @@ -238,7 +238,7 @@ class TestInit(TestCase, TestMixin): Test the clean_filename() function """ # GIVEN: A invalid file name and the valid file name. - invalid_name = 'A_file_with_invalid_characters_[\\/:\*\?"<>\|\+\[\]%].py' + invalid_name = 'A_file_with_invalid_characters_[\\/:\*\?"<>\|\+\[\]%].py' # nopep8 wanted_name = 'A_file_with_invalid_characters______________________.py' # WHEN: Clean the name. diff --git a/tests/interfaces/openlp_core/ui/test_filerenamedialog.py b/tests/interfaces/openlp_core/ui/test_filerenamedialog.py index e268aef2f..ebff60310 100644 --- a/tests/interfaces/openlp_core/ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core/ui/test_filerenamedialog.py @@ -99,7 +99,7 @@ class TestStartFileRenameForm(TestCase, TestMixin): # GIVEN: QLineEdit with a validator set with illegal file name characters. # WHEN: 'Typing' a string containing invalid file characters. - QtTest.QTest.keyClicks(self.form.file_name_edit, 'I/n\\v?a*l|i \F[i\l]e" :N+a%me') + QtTest.QTest.keyClicks(self.form.file_name_edit, r'I/n\\v?a*l|i \F[i\l]e" :N+a%me') # THEN: The text in the QLineEdit should be the same as the input string with the invalid characters filtered # out.