Commit 1bb50a33a716418506e6f5953e9829e86cfe0bf5
1 parent
318d3b71
unittest: finish olevba-json validity tests
Showing
1 changed file
with
7 additions
and
6 deletions
tests/json/test_output.py
| @@ -56,6 +56,7 @@ class TestValidJson(unittest.TestCase): | @@ -56,6 +56,7 @@ class TestValidJson(unittest.TestCase): | ||
| 56 | except ValueError: | 56 | except ValueError: |
| 57 | self.fail('Invalid json:\n' + capturer.buffer.getvalue()) | 57 | self.fail('Invalid json:\n' + capturer.buffer.getvalue()) |
| 58 | self.assertNotEqual(len(json_data), 0, msg='Output was empty') | 58 | self.assertNotEqual(len(json_data), 0, msg='Output was empty') |
| 59 | + return json_data | ||
| 59 | 60 | ||
| 60 | def run_all_files(self, program, args_without_filename, print_output=False): | 61 | def run_all_files(self, program, args_without_filename, print_output=False): |
| 61 | """ run test for a single program over all test files """ | 62 | """ run test for a single program over all test files """ |
| @@ -71,20 +72,20 @@ class TestValidJson(unittest.TestCase): | @@ -71,20 +72,20 @@ class TestValidJson(unittest.TestCase): | ||
| 71 | """ Test msodde.py """ | 72 | """ Test msodde.py """ |
| 72 | self.run_all_files(msodde.main, ['-j', ]) | 73 | self.run_all_files(msodde.main, ['-j', ]) |
| 73 | 74 | ||
| 74 | - @unittest.skip('olevba needs patching to accept custom cmd line args') | ||
| 75 | def test_olevba(self): | 75 | def test_olevba(self): |
| 76 | """ Test olevba.py with default args """ | 76 | """ Test olevba.py with default args """ |
| 77 | self.run_all_files(olevba.main, ['-j', ]) | 77 | self.run_all_files(olevba.main, ['-j', ]) |
| 78 | 78 | ||
| 79 | - @unittest.skip('olevba needs patching to accept custom cmd line args') | ||
| 80 | def test_olevba_analysis(self): | 79 | def test_olevba_analysis(self): |
| 81 | - """ Test olevba.py with default args """ | 80 | + """ Test olevba.py with -a """ |
| 82 | self.run_all_files(olevba.main, ['-j', '-a', ]) | 81 | self.run_all_files(olevba.main, ['-j', '-a', ]) |
| 83 | 82 | ||
| 84 | - @unittest.skip('olevba needs patching to accept custom cmd line args') | ||
| 85 | def test_olevba_recurse(self): | 83 | def test_olevba_recurse(self): |
| 86 | - """ Test olevba.py with default args """ | ||
| 87 | - self.run_and_parse(olevba.main, ['-j', '-r', DATA_DIR], True) | 84 | + """ Test olevba.py with -r """ |
| 85 | + json_data = self.run_and_parse(olevba.main, | ||
| 86 | + ['-j', '-r', join(DATA_BASE_DIR, '*')]) | ||
| 87 | + self.assertNotEqual(json_data[-1]['n_processed'], 0, | ||
| 88 | + msg='self-test fail: No test files found!') | ||
| 88 | 89 | ||
| 89 | 90 | ||
| 90 | # just in case somebody calls this file as a script | 91 | # just in case somebody calls this file as a script |