From 3696b59badfef2438a3df1755868b2aeeb443b87 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 30 Dec 2015 17:15:23 +0100 Subject: Fix some pep8-related issues --- test/clitest.py | 4 +++- test/test.py | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/clitest.py b/test/clitest.py index e186531..884655f 100644 --- a/test/clitest.py +++ b/test/clitest.py @@ -136,10 +136,11 @@ class TestUnsupported(test.MATTest): tar.close() proc = subprocess.Popen(['mat', tarpath], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertTrue('It contains unsupported filetypes:' \ + self.assertTrue('It contains unsupported filetypes:' '\n- libtest.py\n- test.py\n- clitest.py\n' in str(stdout)) + class TestHelp(test.MATTest): """ Test the different ways to trigger help """ def test_dash_h(self): @@ -164,6 +165,7 @@ class TestHelp(test.MATTest): _, stderr = proc.communicate() self.assertTrue(('usage: mat [-h]' and ' error: unrecognized arguments:') in stderr) + def get_tests(): """ Return every clitests""" suite = unittest.TestSuite() diff --git a/test/test.py b/test/test.py index fbbdcf4..6886c1f 100644 --- a/test/test.py +++ b/test/test.py @@ -14,6 +14,7 @@ import glob import sys import tempfile import unittest +import subprocess VERBOSITY = 15 @@ -27,6 +28,7 @@ FILE_LIST = zip(clean, dirty) try: # PDF render processing import cairo import gi + gi.require_version('Poppler', '0.18') from gi.repository import Poppler import pdfrw @@ -42,9 +44,10 @@ except ImportError: try: # exiftool subprocess.check_output(['exiftool', '-ver']) -except: +except OSError: FILE_LIST.remove(('clean é.tif', 'dirty é.tif')) + class MATTest(unittest.TestCase): """ Parent class of all test-functions @@ -84,26 +87,28 @@ def run_all_tests(): """ import clitest import libtest - SUITE = unittest.TestSuite() - SUITE.addTests(clitest.get_tests()) - SUITE.addTests(libtest.get_tests()) + suite = unittest.TestSuite() + suite.addTests(clitest.get_tests()) + suite.addTests(libtest.get_tests()) + + return unittest.TextTestRunner(verbosity=VERBOSITY).run(suite).wasSuccessful() - return unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful() def set_local(): - ''' Monkey patch pathes to run the testsuite on the _local_ + """ Monkey patch pathes to run the testsuite on the _local_ version of MAT. See `run_all_tests` for more information about what pathes we're changing and why. - ''' + """ os.environ['PATH'] = '..:' + os.environ['PATH'] sys.path.append('..') + if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description='MAT testsuite') parser.add_argument('-s', '--system', action='store_true', - help='Test the system-wide version of mat') + help='Test the system-wide version of mat') if parser.parse_args().system is False: set_local() -- cgit v1.3