def test_no_duplicate_lines(self): covdata = CoverageData() covdata.set_context("context1") covdata.add_lines(LINES_1) covdata.set_context("context2") covdata.add_lines(LINES_1) self.assertEqual(covdata.lines('a.py'), A_PY_LINES_1)
def test_no_duplicate_arcs(self): covdata = CoverageData() covdata.set_context("context1") covdata.add_arcs(ARCS_3) covdata.set_context("context2") covdata.add_arcs(ARCS_3) self.assertEqual(covdata.arcs('x.py'), X_PY_ARCS_3)
def test_lines_with_contexts(self): covdata = CoverageData() covdata.set_context('test_a') covdata.add_lines(LINES_1) self.assertEqual(covdata.lines('a.py'), [1, 2]) self.assertEqual(covdata.lines('a.py', contexts=['test*']), [1, 2]) self.assertEqual(covdata.lines('a.py', contexts=['other*']), [])
def test_contexts_by_lineno_with_lines(self): covdata = CoverageData() covdata.set_context('test_a') covdata.add_lines(LINES_1) self.assertDictEqual(covdata.contexts_by_lineno('a.py'), { 1: ['test_a'], 2: ['test_a'] })
def test_set_query_contexts(self): covdata = CoverageData() covdata.set_context('test_a') covdata.add_lines(LINES_1) covdata.set_query_contexts(['test_*']) self.assertEqual(covdata.lines('a.py'), [1, 2]) covdata.set_query_contexts(['other*']) self.assertEqual(covdata.lines('a.py'), [])
def test_contexts_by_lineno_with_lines(self): covdata = CoverageData() covdata.set_context('test_a') covdata.add_lines(LINES_1) assert covdata.contexts_by_lineno('a.py') == { 1: ['test_a'], 2: ['test_a'] }
def test_set_query_contexts(self): covdata = CoverageData() covdata.set_context('test_a') covdata.add_lines(LINES_1) covdata.set_query_contexts(['test_*']) assert covdata.lines('a.py') == [1, 2] covdata.set_query_contexts(['other*']) assert covdata.lines('a.py') == []
def test_lines_with_contexts(self): self.skip_unless_data_storage_is("sql") covdata = CoverageData() covdata.set_context('test_a') covdata.add_lines(LINES_1) self.assertEqual(covdata.lines('a.py'), [1, 2]) self.assertEqual(covdata.lines('a.py', contexts=['test*']), [1, 2]) self.assertEqual(covdata.lines('a.py', contexts=['other*']), [])
def test_contexts_by_lineno_with_lines(self): self.skip_unless_data_storage_is("sql") covdata = CoverageData() covdata.set_context('test_a') covdata.add_lines(LINES_1) self.assertDictEqual(covdata.contexts_by_lineno('a.py'), { 1: ['test_a'], 2: ['test_a'] })
def test_arcs_with_contexts(self): covdata = CoverageData() covdata.set_context('test_x') covdata.add_arcs(ARCS_3) assert covdata.arcs('x.py') == [(-1, 1), (1, 2), (2, 3), (3, -1)] covdata.set_query_contexts(['test*']) assert covdata.arcs('x.py') == [(-1, 1), (1, 2), (2, 3), (3, -1)] covdata.set_query_contexts(['other*']) assert covdata.arcs('x.py') == []
def test_contexts_by_lineno_with_arcs(self): covdata = CoverageData() covdata.set_context('test_x') covdata.add_arcs(ARCS_3) self.assertDictEqual(covdata.contexts_by_lineno('x.py'), { -1: ['test_x'], 1: ['test_x'], 2: ['test_x'], 3: ['test_x'] })
def test_arcs_with_contexts(self): covdata = CoverageData() covdata.set_context('test_x') covdata.add_arcs(ARCS_3) self.assertEqual(covdata.arcs('x.py'), [(-1, 1), (1, 2), (2, 3), (3, -1)]) self.assertEqual(covdata.arcs('x.py', contexts=['test*']), [(-1, 1), (1, 2), (2, 3), (3, -1)]) self.assertEqual(covdata.arcs('x.py', contexts=['other*']), [])
def test_interleaved_erasing_bug716(self): # pytest-cov could produce this scenario. #716 covdata1 = CoverageData() covdata2 = CoverageData() # this used to create the .coverage database file.. covdata2.set_context("") # then this would erase it all.. covdata1.erase() # then this would try to use tables that no longer exist. # "no such table: meta" covdata2.add_lines(LINES_1)
def test_contexts_by_lineno_with_arcs(self): self.skip_unless_data_storage_is("sql") covdata = CoverageData() covdata.set_context('test_x') covdata.add_arcs(ARCS_3) self.assertDictEqual(covdata.contexts_by_lineno('x.py'), { -1: ['test_x'], 1: ['test_x'], 2: ['test_x'], 3: ['test_x'] })
def test_contexts_by_lineno_with_arcs(self): covdata = CoverageData() covdata.set_context('test_x') covdata.add_arcs(ARCS_3) expected = { -1: ['test_x'], 1: ['test_x'], 2: ['test_x'], 3: ['test_x'] } assert expected == covdata.contexts_by_lineno('x.py')