def test_with_tests(self): "If tests are found, the right tree is created" project = Project() project.refresh([ 'tests.FunkyTestCase.test_something_unnecessary', 'more_tests.FunkyTestCase.test_this_does_make_sense', 'more_tests.FunkyTestCase.test_this_doesnt_make_sense', 'more_tests.JankyTestCase.test_things', 'deep_tests.package.DeepTestCase.test_doo_hickey', ]) self.assertEqual(project.errors, []) self.assertEqual(sorted(self._full_tree(project)), sorted({ (TestModule, 'tests'): { (TestCase, 'FunkyTestCase'): [ 'test_something_unnecessary' ] }, (TestModule, 'more_tests'): { (TestCase, 'FunkyTestCase'): [ 'test_this_doesnt_make_sense', 'test_this_doesnt_make_sense' ], (TestCase, 'JankyTestCase'): [ 'test_things' ] }, (TestModule, 'deep_tests'): { (TestModule, 'package'): { (TestCase, 'DeepTestCase'): [ 'test_doo_hickey' ] } } }))
def setUp(self): super(FindLabelTests, self).setUp() self.project = Project() self.project.refresh([ 'app1.TestCase.test_method', 'app2.TestCase1.test_method', 'app2.TestCase2.test_method1', 'app2.TestCase2.test_method2', 'app3.tests.TestCase.test_method', 'app4.tests1.TestCase.test_method', 'app4.tests2.TestCase1.test_method', 'app4.tests2.TestCase2.test_method1', 'app4.tests2.TestCase2.test_method2', 'app5.package.tests.TestCase.test_method', 'app6.package1.tests.TestCase.test_method', 'app6.package2.tests1.TestCase.test_method', 'app6.package2.tests2.TestCase1.test_method', 'app6.package2.tests2.TestCase2.test_method1', 'app6.package2.tests2.TestCase2.test_method2', 'app7.package.subpackage.tests.TestCase.test_method', 'app8.package1.subpackage.tests.TestCase.test_method', 'app8.package2.subpackage1.tests.TestCase.test_method', 'app8.package2.subpackage2.tests1.TestCase.test_method', 'app8.package2.subpackage2.tests2.TestCase1.test_method', 'app8.package2.subpackage2.tests2.TestCase2.test_method1', 'app8.package2.subpackage2.tests2.TestCase2.test_method2', ])
def test_single_test_project(self): "If the project only contains a single test, the reduction is always the full suite" self.project = Project() self.project.refresh([ 'app.package.tests.TestCase.test_method', ]) self.assertEquals(self.project.find_tests(labels=[ 'app.package.tests.TestCase.test_method' ]), (1, [])) self.assertEquals(self.project.find_tests(labels=[ 'app.package.tests.TestCase' ]), (1, [])) self.assertEquals(self.project.find_tests(labels=[ 'app.package.tests' ]), (1, [])) self.assertEquals(self.project.find_tests(labels=[ 'app.package' ]), (1, [])) self.assertEquals(self.project.find_tests(labels=[ 'app' ]), (1, []))
def test_finds_test_modules_without_errors(self, sub_mock): io_mock = mock.MagicMock() io_mock.stdout = self.test_list io_mock.stderr = [] sub_mock.return_value = io_mock project = Project() self.assertEquals(project.errors, []) self.assertItemsEqual(project.keys(), ['tests', 'more_tests'])
def test_project_has_error_list_from_stderr(self, sub_mock): io_mock = mock.MagicMock() io_mock.stdout = self.test_list io_mock.stderr = self.error_list sub_mock.return_value = io_mock project = Project() self.assertEquals(project.errors, self.error_list) self.assertItemsEqual(project.keys(), ['tests', 'more_tests'])
def test_with_tests_and_errors(self): "If tests *and* errors are found, the tree is still created." project = Project() project.refresh([ 'tests.FunkyTestCase.test_something_unnecessary', ], errors=[ 'ERROR: you broke it, fool!', ] ) self.assertEqual(project.errors, [ 'ERROR: you broke it, fool!', ]) self.assertEqual(sorted(self._full_tree(project)), sorted({ (TestModule, 'tests'): { (TestCase, 'FunkyTestCase'): [ 'test_something_unnecessary' ] } }))
def test_no_tests(self): "If there are no tests, an empty tree is generated" project = Project() project.refresh(test_list=[]) self.assertEqual(project.errors, []) self.assertEqual(sorted(self._full_tree(project)), sorted({}))