From 1e1a25c2037b6e7f9b4685887f51a2fce37bf88d Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 28 Jan 2016 18:48:03 +0100 Subject: [PATCH] Pylint compliance --- patacrep/tools/convert/__main__.py | 2 +- test/test_patatools/test_convert.py | 47 +++++++++++++++-------------- test/test_song/test_parser.py | 3 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/patacrep/tools/convert/__main__.py b/patacrep/tools/convert/__main__.py index 683e8535..eae1f691 100644 --- a/patacrep/tools/convert/__main__.py +++ b/patacrep/tools/convert/__main__.py @@ -67,7 +67,7 @@ def main(args=None): with open(destname, "w") as destfile: destfile.write(song.render()) - except ContentError as error: + except ContentError: LOGGER.error("Cannot parse file '%s'.", file) sys.exit(1) except NotImplementedError: diff --git a/test/test_patatools/test_convert.py b/test/test_patatools/test_convert.py index 30c1dc24..5fa479b3 100644 --- a/test/test_patatools/test_convert.py +++ b/test/test_patatools/test_convert.py @@ -2,33 +2,33 @@ # pylint: disable=too-few-public-methods -from pkg_resources import resource_filename import contextlib import glob import os -import shutil import unittest +from pkg_resources import resource_filename + from patacrep import files from patacrep.tools.__main__ import main as tools_main from patacrep.encoding import open_read from patacrep.tools.convert.__main__ import main as convert_main -from patacrep.songbook.__main__ import main as songbook_main -from .. import dynamic +from .. import dynamic # pylint: disable=unused-import from .. import logging_reduced class TestConvert(unittest.TestCase, metaclass=dynamic.DynamicTest): """Test of the "patatools convert" subcommand""" - def _system(self, main, args): + @staticmethod + def _system(main, args): try: main(args) except SystemExit as systemexit: return systemexit.code return 0 - def assertConvert(self, basename, in_format, out_format): + def assertConvert(self, basename, in_format, out_format): # pylint: disable=invalid-name """Test of the "patatools convert" subcommand""" sourcename = "{}.{}".format(basename, in_format) destname = "{}.{}".format(basename, out_format) @@ -57,32 +57,29 @@ class TestConvert(unittest.TestCase, metaclass=dynamic.DynamicTest): expected, ) - def assertFailConvert(self, basename, in_format, out_format): + def assertFailConvert(self, basename, in_format, out_format): # pylint: disable=invalid-name """Test of the "patatools convert" subcommand""" sourcename = "{}.{}".format(basename, in_format) destname = "{}.{}".format(basename, out_format) - controlname = "{}.{}.control".format(sourcename, out_format) for main, args in [ (tools_main, ["patatools", "convert"]), (convert_main, ["patatools-convert"]), ]: with self.subTest(main=main, args=args): with self.chdir("test_convert_failure"): - with open_read(controlname) as controlfile: - with logging_reduced(): - if os.path.exists(destname): - os.remove(destname) - self.assertEqual( - self._system(main, args + [in_format, out_format, sourcename]), - 1, - ) + with logging_reduced(): + if os.path.exists(destname): + os.remove(destname) + self.assertEqual( + self._system(main, args + [in_format, out_format, sourcename]), + 1, + ) @staticmethod @contextlib.contextmanager - def chdir(*path): - """Context to temporarry change current directory, relative to this file directory - """ - with files.chdir(resource_filename(__name__, ""), *path): + def chdir(*pathlist): + """Temporary change current directory, relative to this file directory""" + with files.chdir(resource_filename(__name__, ""), *pathlist): yield @classmethod @@ -103,7 +100,11 @@ class TestConvert(unittest.TestCase, metaclass=dynamic.DynamicTest): @classmethod def _create_test_success(cls, base, in_format, out_format): - """Return a function testing that `base` compilation from `in_format` to `out_format` format. + """Return a function testing conversion. + + :param str base: Base name of the file to convert. + :param str in_format: Source format. + :param str out_format: Destination format. """ test_parse_render = lambda self: self.assertConvert(base, in_format, out_format) test_parse_render.__doc__ = ( @@ -113,10 +114,10 @@ class TestConvert(unittest.TestCase, metaclass=dynamic.DynamicTest): @classmethod def _create_test_failure(cls, base, in_format, out_format): - """Return a function testing that `base` compilation from `in_format` to `out_format` format. + """Return a function testing failing conversions """ test_parse_render = lambda self: self.assertFailConvert(base, in_format, out_format) test_parse_render.__doc__ = ( - "Test that '{base}.{in_format}' raises an error when trying to convert it to '{out_format}'." + "Test that '{base}.{in_format}' raises an error when trying to convert it to '{out_format}'." # pylint: disable=line-too-long ).format(base=os.path.basename(base), in_format=in_format, out_format=out_format) return test_parse_render diff --git a/test/test_song/test_parser.py b/test/test_song/test_parser.py index 298f0017..e660351a 100644 --- a/test/test_song/test_parser.py +++ b/test/test_song/test_parser.py @@ -48,8 +48,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @staticmethod @contextlib.contextmanager def chdir(*path): - """Context to temporarry change current directory, relative to this file directory - """ + """Temporary change current directory, relative to this file directory""" with files.chdir(resource_filename(__name__, ""), *path): yield