OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for instrumentation_test_instance.""" | 6 """Unit tests for instrumentation_test_instance.""" |
7 | 7 |
8 # pylint: disable=protected-access | 8 # pylint: disable=protected-access |
9 | 9 |
10 import os | |
11 import sys | |
10 import unittest | 12 import unittest |
11 | 13 |
14 sys.path.append(os.path.abspath( | |
15 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))) | |
jbudorick
2016/08/24 20:33:07
nit: You shouldn't need to add this.
the real yoland
2016/08/26 19:53:12
Done
| |
12 from pylib.base import base_test_result | 16 from pylib.base import base_test_result |
13 from pylib.constants import host_paths | 17 from pylib.constants import host_paths |
14 from pylib.instrumentation import instrumentation_test_instance | 18 from pylib.instrumentation import instrumentation_test_instance |
15 | 19 |
16 with host_paths.SysPath(host_paths.PYMOCK_PATH): | 20 with host_paths.SysPath(host_paths.PYMOCK_PATH): |
17 import mock # pylint: disable=import-error | 21 import mock # pylint: disable=import-error |
18 | 22 |
19 _INSTRUMENTATION_TEST_INSTANCE_PATH = ( | 23 _INSTRUMENTATION_TEST_INSTANCE_PATH = ( |
20 'pylib.instrumentation.instrumentation_test_instance.%s') | 24 'pylib.instrumentation.instrumentation_test_instance.%s') |
21 | 25 |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 'test': 'testMethod', | 596 'test': 'testMethod', |
593 'stack': stacktrace, | 597 'stack': stacktrace, |
594 }), | 598 }), |
595 ] | 599 ] |
596 results = instrumentation_test_instance.GenerateTestResults( | 600 results = instrumentation_test_instance.GenerateTestResults( |
597 None, None, statuses, 0, 1000) | 601 None, None, statuses, 0, 1000) |
598 self.assertEqual(1, len(results)) | 602 self.assertEqual(1, len(results)) |
599 self.assertEqual(base_test_result.ResultType.FAIL, results[0].GetType()) | 603 self.assertEqual(base_test_result.ResultType.FAIL, results[0].GetType()) |
600 self.assertEqual(stacktrace, results[0].GetLog()) | 604 self.assertEqual(stacktrace, results[0].GetLog()) |
601 | 605 |
606 def testGenerateJUnitTestResults_testSkipped_true(self): | |
607 statuses = [ | |
608 (1, { | |
609 'class': 'test.package.TestClass', | |
610 'test': 'testMethod', | |
611 }), | |
612 (-3, { | |
613 'class': 'test.package.TestClass', | |
614 'test': 'testMethod', | |
615 }), | |
616 ] | |
617 results = instrumentation_test_instance.GenerateTestResults( | |
618 None, None, statuses, 0, 1000) | |
619 self.assertEqual(1, len(results)) | |
620 self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType()) | |
621 | |
622 | |
602 | 623 |
603 if __name__ == '__main__': | 624 if __name__ == '__main__': |
604 unittest.main(verbosity=2) | 625 unittest.main(verbosity=2) |
OLD | NEW |