示例#1
0
    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)
示例#2
0
    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))
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
 def test_untested_file(self):
     other_obj = _SourceTestMap('bar.py')
     self.assertTrue(other_obj.is_untested)
示例#6
0
    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))