From 189b2dd400105a94b531ab321d7bac76dd27dd95 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 1 Aug 2016 19:42:29 +0200 Subject: [PATCH 1/5] Improve pylint testing, fixed a few issues. --- openlp/plugins/songs/lib/openlyricsxml.py | 4 ++-- tests/utils/test_pylint.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsxml.py b/openlp/plugins/songs/lib/openlyricsxml.py index 5adffb300..e2964661d 100644 --- a/openlp/plugins/songs/lib/openlyricsxml.py +++ b/openlp/plugins/songs/lib/openlyricsxml.py @@ -458,7 +458,7 @@ class OpenLyrics(object): self._add_tag_to_formatting(tag, tags_element) # Replace end tags. for tag in end_tags: - text = text.replace('{/{tag}}}'.format(tag=tag), '') + text = text.replace('{{{tag}}}'.format(tag=tag), '') # Replace \n with
. text = text.replace('\n', '
') element = etree.XML('{text}'.format(text=text)) @@ -643,7 +643,7 @@ class OpenLyrics(object): # Append text from tail and add formatting end tag. # TODO: Verify format() with template variables if element.tag == NSMAP % 'tag' and use_endtag: - text += '{/{name}}}'.format(name=element.get('name')) + text += '{{{name}}}'.format(name=element.get('name')) # Append text from tail. if element.tail: text += element.tail diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index dc6c83909..1675a41ee 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -48,7 +48,7 @@ class TestPylint(TestCase): """ # GIVEN: Some checks to disable and enable, and the pylint script disabled_checks = 'import-error,no-member' - enabled_checks = 'missing-format-argument-key,unused-format-string-argument' + enabled_checks = 'missing-format-argument-key,unused-format-string-argument,bad-format-string' if is_win() or 'arch' in platform.dist()[0].lower(): pylint_script = 'pylint' else: From 76be31fee1f71221b4c38885404b61d354ec855f Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 1 Aug 2016 20:00:58 +0200 Subject: [PATCH 2/5] Only run pylint tests if specified. --- tests/utils/test_pylint.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index 1675a41ee..3d1333967 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -23,8 +23,8 @@ Package to test for proper bzr tags. """ import os -import logging import platform +import sys from unittest import TestCase, SkipTest try: @@ -35,6 +35,14 @@ except ImportError: from openlp.core.common import is_win +in_argv = False +for arg in sys.argv: + if arg.endswith('test_pylint.py'): + in_argv = True + break +if not in_argv: + raise SkipTest('test_pylint.py not specified in arguments - skipping tests using pylint.') + TOLERATED_ERRORS = {'registryproperties.py': ['access-member-before-definition'], 'opensong.py': ['no-name-in-module'], 'maindisplay.py': ['no-name-in-module']} From 7ca7ae9c074a596c9ab2143f342f031253181a30 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 1 Aug 2016 20:49:01 +0200 Subject: [PATCH 3/5] Ignore distutils errors --- tests/utils/test_pylint.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index 3d1333967..6b60fcf79 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -92,6 +92,9 @@ class TestPylint(TestCase): # Filter out PyQt related errors elif ('no-name-in-module' in line or 'no-member' in line) and 'PyQt5' in line: continue + # Filter out distutils related errors + elif 'distutils' in line: + continue elif self._is_line_tolerated(line): continue else: From c47321210770c4fec2edf9aada7cf401fc76c0db Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 2 Aug 2016 20:57:10 +0200 Subject: [PATCH 4/5] Added pylint test to jenkins script, and fixed a format error. --- openlp/core/lib/screen.py | 2 +- scripts/jenkins_script.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index e7b4c0b97..31ff3d725 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -167,7 +167,7 @@ class ScreenList(object): :param number: The screen number (int). """ - log.info('remove_screen {number:d}'.forma(number=number)) + log.info('remove_screen {number:d}'.format(number=number)) for screen in self.screen_list: if screen['number'] == number: self.screen_list.remove(screen) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 61f74986a..0711d1257 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -63,9 +63,10 @@ class OpenLPJobs(object): Branch_Windows_Interface = 'Branch-04b-Windows_Interface_Tests' Branch_PEP = 'Branch-05a-Code_Analysis' Branch_Coverage = 'Branch-05b-Test_Coverage' + Branch_Pylint = 'Branch-05c-Code_Analysis2' Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, - Branch_PEP, Branch_Coverage] + Branch_PEP, Branch_Coverage, Branch_Pylint] class Colour(object): From 82faa1da5e5e73fe81723d908038f23dc3d181ea Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 2 Aug 2016 21:32:36 +0200 Subject: [PATCH 5/5] Change pylint test so it works with nose2 --- tests/utils/test_pylint.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index 6b60fcf79..48c9e1393 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -35,14 +35,6 @@ except ImportError: from openlp.core.common import is_win -in_argv = False -for arg in sys.argv: - if arg.endswith('test_pylint.py'): - in_argv = True - break -if not in_argv: - raise SkipTest('test_pylint.py not specified in arguments - skipping tests using pylint.') - TOLERATED_ERRORS = {'registryproperties.py': ['access-member-before-definition'], 'opensong.py': ['no-name-in-module'], 'maindisplay.py': ['no-name-in-module']} @@ -54,6 +46,15 @@ class TestPylint(TestCase): """ Test for pylint errors """ + # Test if this file is specified in the arguments, if not skip the test. + in_argv = False + for arg in sys.argv: + if arg.endswith('test_pylint.py') or arg.endswith('test_pylint'): + in_argv = True + break + if not in_argv: + raise SkipTest('test_pylint.py not specified in arguments - skipping tests using pylint.') + # GIVEN: Some checks to disable and enable, and the pylint script disabled_checks = 'import-error,no-member' enabled_checks = 'missing-format-argument-key,unused-format-string-argument,bad-format-string'