| OLD | NEW |
| (Empty) |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import imp | |
| 6 import os.path | |
| 7 import sys | |
| 8 import unittest | |
| 9 | |
| 10 try: | |
| 11 imp.find_module("pylib") | |
| 12 except ImportError: | |
| 13 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| 14 from pylib.apptest_gtest import _gtest_list_tests | |
| 15 | |
| 16 | |
| 17 class GTestListTestsTest(unittest.TestCase): | |
| 18 """Tests |_gtest_list_tests()| handling of --gtest_list_tests output.""" | |
| 19 | |
| 20 def testSingleSuiteAndFixture(self): | |
| 21 """Tests a single suite with a single fixture.""" | |
| 22 gtest_output = "TestSuite.\n TestFixture\n" | |
| 23 expected_test_list = ["TestSuite.TestFixture"] | |
| 24 self.assertEquals(_gtest_list_tests(gtest_output), expected_test_list) | |
| 25 | |
| 26 def testWindowsNewlines(self): | |
| 27 """Tests handling of \r\n newlines.""" | |
| 28 gtest_output = "TestSuite.\r\n TestFixture1\r\n" | |
| 29 expected_test_list = ["TestSuite.TestFixture1"] | |
| 30 self.assertEquals(_gtest_list_tests(gtest_output), expected_test_list) | |
| 31 | |
| 32 def testSingleSuiteAndMultipleFixtures(self): | |
| 33 """Tests a single suite with multiple fixtures.""" | |
| 34 gtest_output = "TestSuite.\n TestFixture1\n TestFixture2\n" | |
| 35 expected_test_list = ["TestSuite.TestFixture1", "TestSuite.TestFixture2"] | |
| 36 self.assertEquals(_gtest_list_tests(gtest_output), expected_test_list) | |
| 37 | |
| 38 def testMultipleSuitesAndFixtures(self): | |
| 39 """Tests multiple suites each with multiple fixtures.""" | |
| 40 gtest_output = ("TestSuite1.\n TestFixture1\n TestFixture2\n" | |
| 41 "TestSuite2.\n TestFixtureA\n TestFixtureB\n") | |
| 42 expected_test_list = ["TestSuite1.TestFixture1", "TestSuite1.TestFixture2", | |
| 43 "TestSuite2.TestFixtureA", "TestSuite2.TestFixtureB"] | |
| 44 self.assertEquals(_gtest_list_tests(gtest_output), expected_test_list) | |
| 45 | |
| 46 def testUnrecognizedFormats(self): | |
| 47 """Tests examples of unrecognized --gtest_list_tests output.""" | |
| 48 self.assertRaises(Exception, _gtest_list_tests, "Foo") | |
| 49 self.assertRaises(Exception, _gtest_list_tests, "Foo\n") | |
| 50 self.assertRaises(Exception, _gtest_list_tests, "Foo.Bar\n") | |
| 51 self.assertRaises(Exception, _gtest_list_tests, "Foo.\nBar\n") | |
| 52 self.assertRaises(Exception, _gtest_list_tests, "Foo.\r\nBar\r\nGaz\r\n") | |
| 53 self.assertRaises(Exception, _gtest_list_tests, "Foo.\nBar.\n Gaz\n") | |
| 54 | |
| 55 | |
| 56 if __name__ == "__main__": | |
| 57 unittest.main() | |
| OLD | NEW |