Commit dae41c8e authored by jvoisin's avatar jvoisin
Browse files

Improve style and pylint's note

parent d937b7e8
......@@ -43,8 +43,8 @@ class TestListcli(test.MATTest):
proc = subprocess.Popen(['../mat', '-d', clean],
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful \
metadata found" % clean)
self.assertEqual(str(stdout).strip('\n'), "[+] File %s \
:\nNo harmful metadata found" % clean)
def test_list_dirty(self):
'''check if get_meta returns all the expected meta'''
......@@ -52,7 +52,7 @@ metadata found" % clean)
proc = subprocess.Popen(['../mat', '-d', dirty],
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertNotEqual(stdout, "[+] File %s" % dirty)
self.assertNotEqual(str(stdout), "[+] File %s" % dirty)
class TestisCleancli(test.MATTest):
......@@ -65,7 +65,7 @@ class TestisCleancli(test.MATTest):
proc = subprocess.Popen(['../mat', '-c', clean],
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean)
self.assertEqual(str(stdout).strip('\n'), '[+] %s is clean' % clean)
def test_dirty(self):
'''test is_clean on dirty files'''
......@@ -73,7 +73,7 @@ class TestisCleancli(test.MATTest):
proc = subprocess.Popen(['../mat', '-c', dirty],
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty)
self.assertEqual(str(stdout).strip('\n'), '[+] %s is not clean' % dirty)
class TestFileAttributes(unittest.TestCase):
......@@ -81,24 +81,27 @@ class TestFileAttributes(unittest.TestCase):
test various stuffs about files (readable, writable, exist, ...)
'''
def test_not_writtable(self):
''' test MAT's behaviour on non-writable file'''
proc = subprocess.Popen(['../mat', 'not_writtable'],
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_writtable')
self.assertEqual(str(stdout).strip('\n'), 'Unable to process %s' % 'not_writtable')
def test_not_exist(self):
''' test MAT's behaviour on non-existent file'''
proc = subprocess.Popen(['../mat', 'ilikecookies'],
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'ilikecookies')
self.assertEqual(str(stdout).strip('\n'), 'Unable to process %s' % 'ilikecookies')
def get_tests():
Suite = unittest.TestSuite()
Suite.addTest(unittest.makeSuite(TestRemovecli))
Suite.addTest(unittest.makeSuite(TestListcli))
Suite.addTest(unittest.makeSuite(TestisCleancli))
return Suite
''' Return every clitests'''
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestRemovecli))
suite.addTest(unittest.makeSuite(TestListcli))
suite.addTest(unittest.makeSuite(TestisCleancli))
return suite
if __name__ == '__main__':
......
......@@ -79,12 +79,13 @@ class TestFileAttributes(unittest.TestCase):
def get_tests():
Suite = unittest.TestSuite()
Suite.addTest(unittest.makeSuite(TestRemovelib))
Suite.addTest(unittest.makeSuite(TestListlib))
Suite.addTest(unittest.makeSuite(TestisCleanlib))
Suite.addTest(unittest.makeSuite(TestFileAttributes))
return Suite
''' Return every libtests'''
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestRemovelib))
suite.addTest(unittest.makeSuite(TestListlib))
suite.addTest(unittest.makeSuite(TestisCleanlib))
suite.addTest(unittest.makeSuite(TestFileAttributes))
return suite
if __name__ == '__main__':
......
......@@ -14,7 +14,6 @@ import glob
import tempfile
import unittest
import subprocess
import sys
VERBOSITY = 3
......@@ -68,16 +67,12 @@ class MATTest(unittest.TestCase):
shutil.rmtree(self.tmpdir)
def main():
if __name__ == '__main__':
import clitest
import libtest
suite = unittest.TestSuite()
suite.addTests(clitest.get_tests())
suite.addTests(libtest.get_tests())
unittest.TextTestRunner(verbosity=VERBOSITY).run(suite)
SUITE = unittest.TestSuite()
SUITE.addTests(clitest.get_tests())
SUITE.addTests(libtest.get_tests())
if __name__ == '__main__':
sys.exit(main())
unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment