summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjvoisin2016-03-28 22:48:00 +0200
committerjvoisin2016-03-28 22:48:00 +0200
commit2c0249b1e833108cc13c0589f3018851f2311d0b (patch)
tree5beeecfa4da4b79194451b0ba302ef15aa4e407e /test
parent98fb7fe1f0edec16ecd405707cc903d2b4a7dc40 (diff)
Even more python3 portability
Diffstat (limited to 'test')
-rw-r--r--test/test_cli.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/test/test_cli.py b/test/test_cli.py
index 9f682b9..5060a66 100644
--- a/test/test_cli.py
+++ b/test/test_cli.py
@@ -55,8 +55,7 @@ class TestListcli(test.MATTest):
55 proc = subprocess.Popen(['mat', '-d', clean], 55 proc = subprocess.Popen(['mat', '-d', clean],
56 stdout=subprocess.PIPE) 56 stdout=subprocess.PIPE)
57 stdout, _ = proc.communicate() 57 stdout, _ = proc.communicate()
58 self.assertEqual(str(stdout).strip('\n'), "[+] File %s \ 58 self.assertIn('No harmful metadata found', str(stdout))
59:\nNo harmful metadata found" % clean)
60 59
61 def test_list_dirty(self): 60 def test_list_dirty(self):
62 """check if get_meta returns all the expected meta""" 61 """check if get_meta returns all the expected meta"""
@@ -64,8 +63,7 @@ class TestListcli(test.MATTest):
64 proc = subprocess.Popen(['mat', '-d', dirty], 63 proc = subprocess.Popen(['mat', '-d', dirty],
65 stdout=subprocess.PIPE) 64 stdout=subprocess.PIPE)
66 stdout, _ = proc.communicate() 65 stdout, _ = proc.communicate()
67 self.assertNotEqual(str(stdout), "[+] File %s :\n No\ 66 self.assertNotIn('No harmful metadata found', str(stdout))
68harmul metadata found" % dirty)
69 67
70 68
71class TestisCleancli(test.MATTest): 69class TestisCleancli(test.MATTest):
@@ -79,7 +77,7 @@ class TestisCleancli(test.MATTest):
79 proc = subprocess.Popen(['mat', '-c', clean], 77 proc = subprocess.Popen(['mat', '-c', clean],
80 stdout=subprocess.PIPE) 78 stdout=subprocess.PIPE)
81 stdout, _ = proc.communicate() 79 stdout, _ = proc.communicate()
82 self.assertEqual(str(stdout).strip('\n'), '[+] %s is clean' % clean) 80 self.assertIn('is clean', str(stdout))
83 81
84 def test_dirty(self): 82 def test_dirty(self):
85 """test is_clean on dirty files""" 83 """test is_clean on dirty files"""
@@ -87,7 +85,7 @@ class TestisCleancli(test.MATTest):
87 proc = subprocess.Popen(['mat', '-c', dirty], 85 proc = subprocess.Popen(['mat', '-c', dirty],
88 stdout=subprocess.PIPE) 86 stdout=subprocess.PIPE)
89 stdout, _ = proc.communicate() 87 stdout, _ = proc.communicate()
90 self.assertEqual(str(stdout).strip('\n'), '[+] %s is not clean' % dirty) 88 self.assertIn('is not clean', str(stdout))
91 89
92 90
93class TestFileAttributes(unittest.TestCase): 91class TestFileAttributes(unittest.TestCase):
@@ -100,20 +98,20 @@ class TestFileAttributes(unittest.TestCase):
100 proc = subprocess.Popen(['mat', 'not_writtable'], 98 proc = subprocess.Popen(['mat', 'not_writtable'],
101 stdout=subprocess.PIPE) 99 stdout=subprocess.PIPE)
102 stdout, _ = proc.communicate() 100 stdout, _ = proc.communicate()
103 self.assertEqual(str(stdout).strip('\n'), '[-] Unable to process not_writtable') 101 self.assertIn('[-] Unable to process not_writtable', str(stdout))
104 102
105 def test_not_exist(self): 103 def test_not_exist(self):
106 """ test MAT's behaviour on non-existent file""" 104 """ test MAT's behaviour on non-existent file"""
107 proc = subprocess.Popen(['mat', 'ilikecookies'], 105 proc = subprocess.Popen(['mat', 'ilikecookies'],
108 stdout=subprocess.PIPE) 106 stdout=subprocess.PIPE)
109 stdout, _ = proc.communicate() 107 stdout, _ = proc.communicate()
110 self.assertEqual(str(stdout).strip('\n'), '[-] Unable to process ilikecookies') 108 self.assertIn('[-] Unable to process ilikecookies', str(stdout))
111 109
112 def test_empty(self): 110 def test_empty(self):
113 """ test MAT's behaviour on empty file""" 111 """ test MAT's behaviour on empty file"""
114 proc = subprocess.Popen(['mat', 'empty_file'], stdout=subprocess.PIPE) 112 proc = subprocess.Popen(['mat', 'empty_file'], stdout=subprocess.PIPE)
115 stdout, _ = proc.communicate() 113 stdout, _ = proc.communicate()
116 self.assertEqual(str(stdout).strip('\n'), '[-] Unable to process empty_file') 114 self.assertIn('[-] Unable to process empty_file', str(stdout) )
117 115
118 def test_not_readable(self): 116 def test_not_readable(self):
119 """ test MAT's behaviour on non-writable file""" 117 """ test MAT's behaviour on non-writable file"""
@@ -147,23 +145,23 @@ class TestHelp(test.MATTest):
147 """ test help invocation with `-h` and `--help` """ 145 """ test help invocation with `-h` and `--help` """
148 proc = subprocess.Popen(['mat', '-h'], stdout=subprocess.PIPE) 146 proc = subprocess.Popen(['mat', '-h'], stdout=subprocess.PIPE)
149 stdout, _ = proc.communicate() 147 stdout, _ = proc.communicate()
150 self.assertTrue('show this help message and exit' in stdout) 148 self.assertIn('show this help message and exit', str(stdout))
151 149
152 proc = subprocess.Popen(['mat', '--help'], stdout=subprocess.PIPE) 150 proc = subprocess.Popen(['mat', '--help'], stdout=subprocess.PIPE)
153 stdout, _ = proc.communicate() 151 stdout, _ = proc.communicate()
154 self.assertTrue('show this help message and exit' in stdout) 152 self.assertIn('show this help message and exit', str(stdout))
155 153
156 def test_no_argument(self): 154 def test_no_argument(self):
157 """ test help invocation when no argument is provided """ 155 """ test help invocation when no argument is provided """
158 proc = subprocess.Popen(['mat'], stdout=subprocess.PIPE) 156 proc = subprocess.Popen(['mat'], stdout=subprocess.PIPE)
159 stdout, _ = proc.communicate() 157 stdout, _ = proc.communicate()
160 self.assertTrue('show this help message and exit' in stdout) 158 self.assertIn('show this help message and exit', str(stdout))
161 159
162 def test_wrong_argument(self): 160 def test_wrong_argument(self):
163 """ Test MAT's behaviour on wrong argument """ 161 """ Test MAT's behaviour on wrong argument """
164 proc = subprocess.Popen(['mat', '--obviously-wrong-argument'], stderr=subprocess.PIPE) 162 proc = subprocess.Popen(['mat', '--obviously-wrong-argument'], stderr=subprocess.PIPE)
165 _, stderr = proc.communicate() 163 _, stderr = proc.communicate()
166 self.assertTrue(('usage: mat [-h]' and ' error: unrecognized arguments:') in stderr) 164 self.assertIn(('usage: mat [-h]' and ' error: unrecognized arguments:'), str(stderr))
167 165
168 166
169def get_tests(): 167def get_tests():