def test_load_nonexistent_file(self): self.data = CoverageData('/path/to/nonexistent/coverage.xml') self.data.load() self.assertTrue(self.data.is_loaded()) self.assertEquals(self.data.elements, []) self.assertEquals(self.data.files, {})
class CoverageDataTest(unittest.TestCase): def setUp(self): file = os.path.join(os.path.dirname(__file__), 'data', 'test.xml') self.data = CoverageData(file) def test_is_loaded(self): self.assertFalse(self.data.is_loaded()) self.data.elements = [] self.assertTrue(self.data.is_loaded()) def test_load(self): self.data.load() self.assertTrue(self.data.is_loaded()) self.assertEquals(self.data.files, {}) def test_load_nonexistent_file(self): self.data = CoverageData('/path/to/nonexistent/coverage.xml') self.data.load() self.assertTrue(self.data.is_loaded()) self.assertEquals(self.data.elements, []) self.assertEquals(self.data.files, {}) def test_normalise(self): out = self.data.normalise('/path/to/../the/../../file') self.assertEquals(out, '/file') def test_get_file(self): self.data.load() coverage = self.data.get_file('/path/to/file.php') self.assertIsInstance(coverage, FileCoverage) def test_get_file_implicit_load(self): coverage = self.data.get_file('/path/to/file.php') self.assertIsInstance(coverage, FileCoverage) def test_get_file_invalid(self): self.data.load() coverage = self.data.get_file('/path/to/nonexistent/file.php') self.assertIs(coverage, None)
def setUp(self): file = os.path.join(os.path.dirname(__file__), 'data', 'test.xml') self.data = CoverageData(file)