diff options
| author | jvoisin | 2012-12-13 22:22:02 +0100 |
|---|---|---|
| committer | jvoisin | 2012-12-13 22:22:02 +0100 |
| commit | dae41c8e7d2cfce4e7f6a6a2bd27e0c018cd6a60 (patch) | |
| tree | 8292b39da20da1666b726b71928dd115dfeda1ca /test/clitest.py | |
| parent | d937b7e865490a80c2bff0ca161288f323313c1b (diff) | |
Improve style and pylint's note
Diffstat (limited to 'test/clitest.py')
| -rw-r--r-- | test/clitest.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/test/clitest.py b/test/clitest.py index da2fc08..0b041b9 100644 --- a/test/clitest.py +++ b/test/clitest.py | |||
| @@ -43,8 +43,8 @@ class TestListcli(test.MATTest): | |||
| 43 | proc = subprocess.Popen(['../mat', '-d', clean], | 43 | proc = subprocess.Popen(['../mat', '-d', clean], |
| 44 | stdout=subprocess.PIPE) | 44 | stdout=subprocess.PIPE) |
| 45 | stdout, _ = proc.communicate() | 45 | stdout, _ = proc.communicate() |
| 46 | self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful \ | 46 | self.assertEqual(str(stdout).strip('\n'), "[+] File %s \ |
| 47 | metadata found" % clean) | 47 | :\nNo harmful metadata found" % clean) |
| 48 | 48 | ||
| 49 | def test_list_dirty(self): | 49 | def test_list_dirty(self): |
| 50 | '''check if get_meta returns all the expected meta''' | 50 | '''check if get_meta returns all the expected meta''' |
| @@ -52,7 +52,7 @@ metadata found" % clean) | |||
| 52 | proc = subprocess.Popen(['../mat', '-d', dirty], | 52 | proc = subprocess.Popen(['../mat', '-d', dirty], |
| 53 | stdout=subprocess.PIPE) | 53 | stdout=subprocess.PIPE) |
| 54 | stdout, _ = proc.communicate() | 54 | stdout, _ = proc.communicate() |
| 55 | self.assertNotEqual(stdout, "[+] File %s" % dirty) | 55 | self.assertNotEqual(str(stdout), "[+] File %s" % dirty) |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | class TestisCleancli(test.MATTest): | 58 | class TestisCleancli(test.MATTest): |
| @@ -65,7 +65,7 @@ class TestisCleancli(test.MATTest): | |||
| 65 | proc = subprocess.Popen(['../mat', '-c', clean], | 65 | proc = subprocess.Popen(['../mat', '-c', clean], |
| 66 | stdout=subprocess.PIPE) | 66 | stdout=subprocess.PIPE) |
| 67 | stdout, _ = proc.communicate() | 67 | stdout, _ = proc.communicate() |
| 68 | self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean) | 68 | self.assertEqual(str(stdout).strip('\n'), '[+] %s is clean' % clean) |
| 69 | 69 | ||
| 70 | def test_dirty(self): | 70 | def test_dirty(self): |
| 71 | '''test is_clean on dirty files''' | 71 | '''test is_clean on dirty files''' |
| @@ -73,7 +73,7 @@ class TestisCleancli(test.MATTest): | |||
| 73 | proc = subprocess.Popen(['../mat', '-c', dirty], | 73 | proc = subprocess.Popen(['../mat', '-c', dirty], |
| 74 | stdout=subprocess.PIPE) | 74 | stdout=subprocess.PIPE) |
| 75 | stdout, _ = proc.communicate() | 75 | stdout, _ = proc.communicate() |
| 76 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) | 76 | self.assertEqual(str(stdout).strip('\n'), '[+] %s is not clean' % dirty) |
| 77 | 77 | ||
| 78 | 78 | ||
| 79 | class TestFileAttributes(unittest.TestCase): | 79 | class TestFileAttributes(unittest.TestCase): |
| @@ -81,24 +81,27 @@ class TestFileAttributes(unittest.TestCase): | |||
| 81 | test various stuffs about files (readable, writable, exist, ...) | 81 | test various stuffs about files (readable, writable, exist, ...) |
| 82 | ''' | 82 | ''' |
| 83 | def test_not_writtable(self): | 83 | def test_not_writtable(self): |
| 84 | ''' test MAT's behaviour on non-writable file''' | ||
| 84 | proc = subprocess.Popen(['../mat', 'not_writtable'], | 85 | proc = subprocess.Popen(['../mat', 'not_writtable'], |
| 85 | stdout=subprocess.PIPE) | 86 | stdout=subprocess.PIPE) |
| 86 | stdout, _ = proc.communicate() | 87 | stdout, _ = proc.communicate() |
| 87 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_writtable') | 88 | self.assertEqual(str(stdout).strip('\n'), 'Unable to process %s' % 'not_writtable') |
| 88 | 89 | ||
| 89 | def test_not_exist(self): | 90 | def test_not_exist(self): |
| 91 | ''' test MAT's behaviour on non-existent file''' | ||
| 90 | proc = subprocess.Popen(['../mat', 'ilikecookies'], | 92 | proc = subprocess.Popen(['../mat', 'ilikecookies'], |
| 91 | stdout=subprocess.PIPE) | 93 | stdout=subprocess.PIPE) |
| 92 | stdout, _ = proc.communicate() | 94 | stdout, _ = proc.communicate() |
| 93 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'ilikecookies') | 95 | self.assertEqual(str(stdout).strip('\n'), 'Unable to process %s' % 'ilikecookies') |
| 94 | 96 | ||
| 95 | 97 | ||
| 96 | def get_tests(): | 98 | def get_tests(): |
| 97 | Suite = unittest.TestSuite() | 99 | ''' Return every clitests''' |
| 98 | Suite.addTest(unittest.makeSuite(TestRemovecli)) | 100 | suite = unittest.TestSuite() |
| 99 | Suite.addTest(unittest.makeSuite(TestListcli)) | 101 | suite.addTest(unittest.makeSuite(TestRemovecli)) |
| 100 | Suite.addTest(unittest.makeSuite(TestisCleancli)) | 102 | suite.addTest(unittest.makeSuite(TestListcli)) |
| 101 | return Suite | 103 | suite.addTest(unittest.makeSuite(TestisCleancli)) |
| 104 | return suite | ||
| 102 | 105 | ||
| 103 | 106 | ||
| 104 | if __name__ == '__main__': | 107 | if __name__ == '__main__': |
