def setUp(self): self.filename = 'foo.py' self.obj = _SourceTestMap(filename=self.filename) self.lookup = { 'test_foo': 0, 'test_bar': 1, 'test_foo_again': 2 } self.reverse_lookup = { 0: 'test_foo', 1: 'test_bar', 2: 'test_foo_again' } self.obj[1].add('test_foo') self.obj[1].add('test_bar') self.obj[5].add('test_foo_again') self.expected_dict = { 1: [0, 1], 5: [2] } self.expected_serialized_data = (self.filename, self.expected_dict)
def test_touch(self): other_obj = SourceMap() self.assertEqual(len(other_obj), 0) other_file = 'other_file.py' other_obj.touch(other_file) self.assertEqual(len(other_obj), 1) self.assertEqual(other_obj[other_file], _SourceTestMap(other_file))
def test_eq(self): other_obj = _SourceTestMap(filename=self.filename) other_obj[1].add('test_bar') other_obj[5].add('test_foo_again') other_obj[1].add('test_foo') self.assertEqual(other_obj, self.obj)
def test_getitem(self): expected = _SourceTestMap(self.filenames[1]) for line_num in self.covered_lines: expected.add(line_num, self.tests[2]) self.assertEqual(self.obj[self.filenames[1]], expected)
def test_untested_file(self): other_obj = _SourceTestMap('bar.py') self.assertTrue(other_obj.is_untested)
def test_get(self): self.assertEqual(self.obj.get(self.filenames[0]), _SourceTestMap(self.filenames[0])) self.assertIsNone(self.obj.get('no_such_file.py', None))