def test_build_coverage_report_two_module(self, coverage, render_report): execution_name = "mock coverage" execution_prefix = "mock_coverage" project = Mock() modules = [ Mock(__name__='module_a', __file__='module_a.py'), Mock(__name__='module_b', __file__='module_b.py') ] project.get_property.side_effect = [70, 70, 70, False, False, False] module_a_coverage = Mock() module_a_coverage.statements = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] module_a_coverage.excluded = [] module_a_coverage.missing = [1, 2, 3, 4, 5] n = module_a_coverage.numbers n.n_statements = 10 n.n_excluded = 0 n.n_missing = 5 n.n_branches = 8 n.n_partial_branches = 5 n.n_missing_branches = 5 module_b_coverage = Mock() module_b_coverage.statements = [1, 2, 3, 4, 5] module_b_coverage.excluded = [] module_b_coverage.missing = [1, 2] n = module_b_coverage.numbers n.n_statements = 4 n.n_excluded = 0 n.n_missing = 2 n.n_branches = 8 n.n_partial_branches = 3 n.n_missing_branches = 3 coverage._analyze.side_effect = [module_a_coverage, module_b_coverage] self.assertTrue( _build_coverage_report(project, MagicMock(Logger), execution_name, execution_prefix, coverage, modules) is None ) report = render_report.call_args[0][0] self.assertEqual(report['overall_coverage'], 50) self.assertEqual(report['overall_branch_coverage'], 50) self.assertEqual(report['overall_branch_partial_coverage'], 50)
def test_build_coverage_report_two_module(self, coverage, render_report): execution_name = "mock" execution_description = "mock coverage" config_prefix = "mock_coverage" project = Mock() source_path = "" module_names = ["module_a", "module_b"] module_files = ["module_a.py", "module_b.py"] project.get_property.side_effect = [70, 70, 70, False, False, False] module_a_coverage = Mock() module_a_coverage.statements = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] module_a_coverage.excluded = [] module_a_coverage.missing = [1, 2, 3, 4, 5] n = module_a_coverage.numbers n.n_statements = 10 n.n_excluded = 0 n.n_missing = 5 n.n_branches = 8 n.n_partial_branches = 5 n.n_missing_branches = 5 module_b_coverage = Mock() module_b_coverage.statements = [1, 2, 3, 4, 5] module_b_coverage.excluded = [] module_b_coverage.missing = [1, 2] n = module_b_coverage.numbers n.n_statements = 4 n.n_excluded = 0 n.n_missing = 2 n.n_branches = 8 n.n_partial_branches = 3 n.n_missing_branches = 3 coverage._analyze.side_effect = [module_a_coverage, module_b_coverage] self.assertTrue(_build_coverage_report(project, MagicMock(Logger), execution_description, execution_name, config_prefix, coverage, source_path, module_names, module_files) is None) report = render_report.call_args[0][0] self.assertEqual(report["overall_coverage"], 50) self.assertEqual(report["overall_branch_coverage"], 50) self.assertEqual(report["overall_branch_partial_coverage"], 50)
def test_build_coverage_report_two_module(self, coverage, render_report): execution_name = "mock coverage" execution_prefix = "mock_coverage" project = Mock() modules = [Mock(__name__='module_a', __file__='module_a.py'), Mock(__name__='module_b', __file__='module_b.py') ] project.get_property.side_effect = [70, 70, 70, False, False, False] module_a_coverage = Mock() module_a_coverage.statements = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] module_a_coverage.excluded = [] module_a_coverage.missing = [1, 2, 3, 4, 5] n = module_a_coverage.numbers n.n_statements = 10 n.n_excluded = 0 n.n_missing = 5 n.n_branches = 8 n.n_partial_branches = 5 n.n_missing_branches = 5 module_b_coverage = Mock() module_b_coverage.statements = [1, 2, 3, 4, 5] module_b_coverage.excluded = [] module_b_coverage.missing = [1, 2] n = module_b_coverage.numbers n.n_statements = 4 n.n_excluded = 0 n.n_missing = 2 n.n_branches = 8 n.n_partial_branches = 3 n.n_missing_branches = 3 coverage._analyze.side_effect = [module_a_coverage, module_b_coverage] self.assertTrue(_build_coverage_report(project, MagicMock(Logger), execution_name, execution_prefix, coverage, modules) is None) report = render_report.call_args[0][0] self.assertEquals(report['overall_coverage'], 50) self.assertEquals(report['overall_branch_coverage'], 50) self.assertEquals(report['overall_branch_partial_coverage'], 50)