diff options
| author | jvoisin | 2018-05-18 23:52:40 +0200 |
|---|---|---|
| committer | jvoisin | 2018-05-18 23:52:40 +0200 |
| commit | 38fae60b8beaf9c7b37c65325d2d285e62b6cb85 (patch) | |
| tree | e6bd4f699d6190dfada7618ebd04455eb7de9660 /tests | |
| parent | 57d5cd04284276c49899034a9ad321b680624d8f (diff) | |
Rename some files to simplify packaging
- the `src` folder is now `libmat2`
- the `main.py` script is now `mat2.py`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_climat2.py | 44 | ||||
| -rw-r--r-- | tests/test_libmat2.py | 2 |
2 files changed, 23 insertions, 23 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 864ee0d..36973bf 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py | |||
| @@ -6,43 +6,43 @@ import unittest | |||
| 6 | 6 | ||
| 7 | class TestHelp(unittest.TestCase): | 7 | class TestHelp(unittest.TestCase): |
| 8 | def test_help(self): | 8 | def test_help(self): |
| 9 | proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE) | 9 | proc = subprocess.Popen(['./mat2.py', '--help'], stdout=subprocess.PIPE) |
| 10 | stdout, _ = proc.communicate() | 10 | stdout, _ = proc.communicate() |
| 11 | self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) | 11 | self.assertIn(b'usage: mat2.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) |
| 12 | 12 | ||
| 13 | def test_no_arg(self): | 13 | def test_no_arg(self): |
| 14 | proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE) | 14 | proc = subprocess.Popen(['./mat2.py'], stdout=subprocess.PIPE) |
| 15 | stdout, _ = proc.communicate() | 15 | stdout, _ = proc.communicate() |
| 16 | self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) | 16 | self.assertIn(b'usage: mat2.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | class TestVersion(unittest.TestCase): | 19 | class TestVersion(unittest.TestCase): |
| 20 | def test_version(self): | 20 | def test_version(self): |
| 21 | proc = subprocess.Popen(['./main.py', '--version'], stdout=subprocess.PIPE) | 21 | proc = subprocess.Popen(['./mat2.py', '--version'], stdout=subprocess.PIPE) |
| 22 | stdout, _ = proc.communicate() | 22 | stdout, _ = proc.communicate() |
| 23 | self.assertTrue(stdout.startswith(b'MAT2 ')) | 23 | self.assertTrue(stdout.startswith(b'MAT2 ')) |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | class TestExclusiveArgs(unittest.TestCase): | 26 | class TestExclusiveArgs(unittest.TestCase): |
| 27 | def test_version(self): | 27 | def test_version(self): |
| 28 | proc = subprocess.Popen(['./main.py', '-s', '-c'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 28 | proc = subprocess.Popen(['./mat2.py', '-s', '-c'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 29 | stdout, stderr = proc.communicate() | 29 | stdout, stderr = proc.communicate() |
| 30 | self.assertIn(b'main.py: error: argument -c/--check: not allowed with argument -s/--show', stderr) | 30 | self.assertIn(b'mat2.py: error: argument -c/--check: not allowed with argument -s/--show', stderr) |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | class TestReturnValue(unittest.TestCase): | 33 | class TestReturnValue(unittest.TestCase): |
| 34 | def test_nonzero(self): | 34 | def test_nonzero(self): |
| 35 | ret = subprocess.call(['./main.py', './main.py'], stdout=subprocess.DEVNULL) | 35 | ret = subprocess.call(['./mat2.py', './mat2.py'], stdout=subprocess.DEVNULL) |
| 36 | self.assertEqual(255, ret) | 36 | self.assertEqual(255, ret) |
| 37 | 37 | ||
| 38 | ret = subprocess.call(['./main.py', '--whololo'], stderr=subprocess.DEVNULL) | 38 | ret = subprocess.call(['./mat2.py', '--whololo'], stderr=subprocess.DEVNULL) |
| 39 | self.assertEqual(2, ret) | 39 | self.assertEqual(2, ret) |
| 40 | 40 | ||
| 41 | def test_zero(self): | 41 | def test_zero(self): |
| 42 | ret = subprocess.call(['./main.py'], stdout=subprocess.DEVNULL) | 42 | ret = subprocess.call(['./mat2.py'], stdout=subprocess.DEVNULL) |
| 43 | self.assertEqual(0, ret) | 43 | self.assertEqual(0, ret) |
| 44 | 44 | ||
| 45 | ret = subprocess.call(['./main.py', '--show', './main.py'], stdout=subprocess.DEVNULL) | 45 | ret = subprocess.call(['./mat2.py', '--show', './mat2.py'], stdout=subprocess.DEVNULL) |
| 46 | self.assertEqual(0, ret) | 46 | self.assertEqual(0, ret) |
| 47 | 47 | ||
| 48 | 48 | ||
| @@ -50,16 +50,16 @@ class TestCleanMeta(unittest.TestCase): | |||
| 50 | def test_jpg(self): | 50 | def test_jpg(self): |
| 51 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') | 51 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') |
| 52 | 52 | ||
| 53 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.jpg'], | 53 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/clean.jpg'], |
| 54 | stdout=subprocess.PIPE) | 54 | stdout=subprocess.PIPE) |
| 55 | stdout, _ = proc.communicate() | 55 | stdout, _ = proc.communicate() |
| 56 | self.assertIn(b'Comment: Created with GIMP', stdout) | 56 | self.assertIn(b'Comment: Created with GIMP', stdout) |
| 57 | 57 | ||
| 58 | proc = subprocess.Popen(['./main.py', './tests/data/clean.jpg'], | 58 | proc = subprocess.Popen(['./mat2.py', './tests/data/clean.jpg'], |
| 59 | stdout=subprocess.PIPE) | 59 | stdout=subprocess.PIPE) |
| 60 | stdout, _ = proc.communicate() | 60 | stdout, _ = proc.communicate() |
| 61 | 61 | ||
| 62 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.cleaned.jpg'], | 62 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/clean.cleaned.jpg'], |
| 63 | stdout=subprocess.PIPE) | 63 | stdout=subprocess.PIPE) |
| 64 | stdout, _ = proc.communicate() | 64 | stdout, _ = proc.communicate() |
| 65 | self.assertNotIn(b'Comment: Created with GIMP', stdout) | 65 | self.assertNotIn(b'Comment: Created with GIMP', stdout) |
| @@ -69,25 +69,25 @@ class TestCleanMeta(unittest.TestCase): | |||
| 69 | 69 | ||
| 70 | class TestGetMeta(unittest.TestCase): | 70 | class TestGetMeta(unittest.TestCase): |
| 71 | def test_pdf(self): | 71 | def test_pdf(self): |
| 72 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.pdf'], | 72 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.pdf'], |
| 73 | stdout=subprocess.PIPE) | 73 | stdout=subprocess.PIPE) |
| 74 | stdout, _ = proc.communicate() | 74 | stdout, _ = proc.communicate() |
| 75 | self.assertIn(b'producer: pdfTeX-1.40.14', stdout) | 75 | self.assertIn(b'producer: pdfTeX-1.40.14', stdout) |
| 76 | 76 | ||
| 77 | def test_png(self): | 77 | def test_png(self): |
| 78 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.png'], | 78 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.png'], |
| 79 | stdout=subprocess.PIPE) | 79 | stdout=subprocess.PIPE) |
| 80 | stdout, _ = proc.communicate() | 80 | stdout, _ = proc.communicate() |
| 81 | self.assertIn(b'Comment: This is a comment, be careful!', stdout) | 81 | self.assertIn(b'Comment: This is a comment, be careful!', stdout) |
| 82 | 82 | ||
| 83 | def test_jpg(self): | 83 | def test_jpg(self): |
| 84 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.jpg'], | 84 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.jpg'], |
| 85 | stdout=subprocess.PIPE) | 85 | stdout=subprocess.PIPE) |
| 86 | stdout, _ = proc.communicate() | 86 | stdout, _ = proc.communicate() |
| 87 | self.assertIn(b'Comment: Created with GIMP', stdout) | 87 | self.assertIn(b'Comment: Created with GIMP', stdout) |
| 88 | 88 | ||
| 89 | def test_docx(self): | 89 | def test_docx(self): |
| 90 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.docx'], | 90 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.docx'], |
| 91 | stdout=subprocess.PIPE) | 91 | stdout=subprocess.PIPE) |
| 92 | stdout, _ = proc.communicate() | 92 | stdout, _ = proc.communicate() |
| 93 | self.assertIn(b'Application: LibreOffice/5.4.5.1$Linux_X86_64', stdout) | 93 | self.assertIn(b'Application: LibreOffice/5.4.5.1$Linux_X86_64', stdout) |
| @@ -95,7 +95,7 @@ class TestGetMeta(unittest.TestCase): | |||
| 95 | self.assertIn(b'revision: 1', stdout) | 95 | self.assertIn(b'revision: 1', stdout) |
| 96 | 96 | ||
| 97 | def test_odt(self): | 97 | def test_odt(self): |
| 98 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.odt'], | 98 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.odt'], |
| 99 | stdout=subprocess.PIPE) | 99 | stdout=subprocess.PIPE) |
| 100 | stdout, _ = proc.communicate() | 100 | stdout, _ = proc.communicate() |
| 101 | self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout) | 101 | self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout) |
| @@ -103,14 +103,14 @@ class TestGetMeta(unittest.TestCase): | |||
| 103 | self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout) | 103 | self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout) |
| 104 | 104 | ||
| 105 | def test_mp3(self): | 105 | def test_mp3(self): |
| 106 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.mp3'], | 106 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.mp3'], |
| 107 | stdout=subprocess.PIPE) | 107 | stdout=subprocess.PIPE) |
| 108 | stdout, _ = proc.communicate() | 108 | stdout, _ = proc.communicate() |
| 109 | self.assertIn(b'TALB: harmfull', stdout) | 109 | self.assertIn(b'TALB: harmfull', stdout) |
| 110 | self.assertIn(b'COMM::: Thank you for using MAT !', stdout) | 110 | self.assertIn(b'COMM::: Thank you for using MAT !', stdout) |
| 111 | 111 | ||
| 112 | def test_flac(self): | 112 | def test_flac(self): |
| 113 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.flac'], | 113 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.flac'], |
| 114 | stdout=subprocess.PIPE) | 114 | stdout=subprocess.PIPE) |
| 115 | stdout, _ = proc.communicate() | 115 | stdout, _ = proc.communicate() |
| 116 | self.assertIn(b'comments: Thank you for using MAT !', stdout) | 116 | self.assertIn(b'comments: Thank you for using MAT !', stdout) |
| @@ -118,7 +118,7 @@ class TestGetMeta(unittest.TestCase): | |||
| 118 | self.assertIn(b'title: I am so', stdout) | 118 | self.assertIn(b'title: I am so', stdout) |
| 119 | 119 | ||
| 120 | def test_ogg(self): | 120 | def test_ogg(self): |
| 121 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.ogg'], | 121 | proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.ogg'], |
| 122 | stdout=subprocess.PIPE) | 122 | stdout=subprocess.PIPE) |
| 123 | stdout, _ = proc.communicate() | 123 | stdout, _ = proc.communicate() |
| 124 | self.assertIn(b'comments: Thank you for using MAT !', stdout) | 124 | self.assertIn(b'comments: Thank you for using MAT !', stdout) |
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index f3e11d9..89a5811 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -6,7 +6,7 @@ import os | |||
| 6 | import zipfile | 6 | import zipfile |
| 7 | import tempfile | 7 | import tempfile |
| 8 | 8 | ||
| 9 | from src import pdf, images, audio, office, parser_factory, torrent | 9 | from libmat2 import pdf, images, audio, office, parser_factory, torrent |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | class TestParserFactory(unittest.TestCase): | 12 | class TestParserFactory(unittest.TestCase): |
