diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/clitest.py | 4 | ||||
| -rw-r--r-- | test/test.py | 21 |
2 files changed, 16 insertions, 9 deletions
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): | |||
| 136 | tar.close() | 136 | tar.close() |
| 137 | proc = subprocess.Popen(['mat', tarpath], stdout=subprocess.PIPE) | 137 | proc = subprocess.Popen(['mat', tarpath], stdout=subprocess.PIPE) |
| 138 | stdout, _ = proc.communicate() | 138 | stdout, _ = proc.communicate() |
| 139 | self.assertTrue('It contains unsupported filetypes:' \ | 139 | self.assertTrue('It contains unsupported filetypes:' |
| 140 | '\n- libtest.py\n- test.py\n- clitest.py\n' | 140 | '\n- libtest.py\n- test.py\n- clitest.py\n' |
| 141 | in str(stdout)) | 141 | in str(stdout)) |
| 142 | 142 | ||
| 143 | |||
| 143 | class TestHelp(test.MATTest): | 144 | class TestHelp(test.MATTest): |
| 144 | """ Test the different ways to trigger help """ | 145 | """ Test the different ways to trigger help """ |
| 145 | def test_dash_h(self): | 146 | def test_dash_h(self): |
| @@ -164,6 +165,7 @@ class TestHelp(test.MATTest): | |||
| 164 | _, stderr = proc.communicate() | 165 | _, stderr = proc.communicate() |
| 165 | self.assertTrue(('usage: mat [-h]' and ' error: unrecognized arguments:') in stderr) | 166 | self.assertTrue(('usage: mat [-h]' and ' error: unrecognized arguments:') in stderr) |
| 166 | 167 | ||
| 168 | |||
| 167 | def get_tests(): | 169 | def get_tests(): |
| 168 | """ Return every clitests""" | 170 | """ Return every clitests""" |
| 169 | suite = unittest.TestSuite() | 171 | 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 | |||
| 14 | import sys | 14 | import sys |
| 15 | import tempfile | 15 | import tempfile |
| 16 | import unittest | 16 | import unittest |
| 17 | import subprocess | ||
| 17 | 18 | ||
| 18 | VERBOSITY = 15 | 19 | VERBOSITY = 15 |
| 19 | 20 | ||
| @@ -27,6 +28,7 @@ FILE_LIST = zip(clean, dirty) | |||
| 27 | try: # PDF render processing | 28 | try: # PDF render processing |
| 28 | import cairo | 29 | import cairo |
| 29 | import gi | 30 | import gi |
| 31 | |||
| 30 | gi.require_version('Poppler', '0.18') | 32 | gi.require_version('Poppler', '0.18') |
| 31 | from gi.repository import Poppler | 33 | from gi.repository import Poppler |
| 32 | import pdfrw | 34 | import pdfrw |
| @@ -42,9 +44,10 @@ except ImportError: | |||
| 42 | 44 | ||
| 43 | try: # exiftool | 45 | try: # exiftool |
| 44 | subprocess.check_output(['exiftool', '-ver']) | 46 | subprocess.check_output(['exiftool', '-ver']) |
| 45 | except: | 47 | except OSError: |
| 46 | FILE_LIST.remove(('clean é.tif', 'dirty é.tif')) | 48 | FILE_LIST.remove(('clean é.tif', 'dirty é.tif')) |
| 47 | 49 | ||
| 50 | |||
| 48 | class MATTest(unittest.TestCase): | 51 | class MATTest(unittest.TestCase): |
| 49 | """ | 52 | """ |
| 50 | Parent class of all test-functions | 53 | Parent class of all test-functions |
| @@ -84,26 +87,28 @@ def run_all_tests(): | |||
| 84 | """ | 87 | """ |
| 85 | import clitest | 88 | import clitest |
| 86 | import libtest | 89 | import libtest |
| 87 | SUITE = unittest.TestSuite() | 90 | suite = unittest.TestSuite() |
| 88 | SUITE.addTests(clitest.get_tests()) | 91 | suite.addTests(clitest.get_tests()) |
| 89 | SUITE.addTests(libtest.get_tests()) | 92 | suite.addTests(libtest.get_tests()) |
| 93 | |||
| 94 | return unittest.TextTestRunner(verbosity=VERBOSITY).run(suite).wasSuccessful() | ||
| 90 | 95 | ||
| 91 | return unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful() | ||
| 92 | 96 | ||
| 93 | def set_local(): | 97 | def set_local(): |
| 94 | ''' Monkey patch pathes to run the testsuite on the _local_ | 98 | """ Monkey patch pathes to run the testsuite on the _local_ |
| 95 | version of MAT. See `run_all_tests` for more information about | 99 | version of MAT. See `run_all_tests` for more information about |
| 96 | what pathes we're changing and why. | 100 | what pathes we're changing and why. |
| 97 | ''' | 101 | """ |
| 98 | os.environ['PATH'] = '..:' + os.environ['PATH'] | 102 | os.environ['PATH'] = '..:' + os.environ['PATH'] |
| 99 | sys.path.append('..') | 103 | sys.path.append('..') |
| 100 | 104 | ||
| 105 | |||
| 101 | if __name__ == '__main__': | 106 | if __name__ == '__main__': |
| 102 | import argparse | 107 | import argparse |
| 103 | 108 | ||
| 104 | parser = argparse.ArgumentParser(description='MAT testsuite') | 109 | parser = argparse.ArgumentParser(description='MAT testsuite') |
| 105 | parser.add_argument('-s', '--system', action='store_true', | 110 | parser.add_argument('-s', '--system', action='store_true', |
| 106 | help='Test the system-wide version of mat') | 111 | help='Test the system-wide version of mat') |
| 107 | 112 | ||
| 108 | if parser.parse_args().system is False: | 113 | if parser.parse_args().system is False: |
| 109 | set_local() | 114 | set_local() |
