Exemplo n.º 1
0
 def test_ancestors(self):
     definitions = analyze.find_definitions('tests/files/example.py')
     found_class = analyze.find_class('start', definitions)
     ancestors = found_class.calls[0].calls[0].ancestors()
     self.assertEqual(ancestors[0], funct('start'))
     self.assertEqual(ancestors[1], cls('Example', funct('somethingelse')))
     self.assertEqual(ancestors[2], cls("ThingTwo", funct("two")))
Exemplo n.º 2
0
    def test_find_definitions_calls(self):
        definitions = analyze.find_definitions('tests/files/example.py')
        e_def = definitions[1]

        self.assertEqual(e_def.functs[1].name, 'somethingelse')
        self.assertIn('two', e_def.functs[1].calls)
        self.assertIn('three', e_def.functs[1].calls)
        self.assertIn('bar', e_def.functs[1].calls)
Exemplo n.º 3
0
    def test_find_definitions(self):
        definitions = analyze.find_definitions('tests/files/example.py')

        self.assertIn(funct('start'), definitions)
        self.assertIn(cls('ThingTwo', funct('two')), definitions)
        self.assertIn(
            cls('Example', funct('something'), funct('somethingelse')),
            definitions)
Exemplo n.º 4
0
    def test_find_class_follows_function_class_calls(self):
        definitions = analyze.find_definitions('tests/files/example.py')
        found_funct = analyze.find_class('start', definitions)

        self.assertEqual(found_funct.name, 'start')
        self.assertEqual(len(found_funct.calls), 1)
        self.assertEqual(found_funct.calls[0],
                         cls('Example', funct('somethingelse')))
Exemplo n.º 5
0
 def test_cycles_short_circit(self):
     definitions = analyze.find_definitions('tests/files/more_examples.py')
     found_class = analyze.find_class('zed', definitions)
     self.assertEqual(len(found_class.calls), 1)
     self.assertEqual(cls('ThingThree', funct('call_cycle')),
                      found_class.calls[0])
     self.assertTrue(found_class.calls[0].calls[0].cycle)
     self.assertEqual(cls("ContainsCycle", funct('zed')),
                      found_class.calls[0].calls[0])
Exemplo n.º 6
0
 def test_find_class(self):
     definitions = analyze.find_definitions('tests/files/example.py')
     self.assertEqual(cls('Example', funct('somethingelse')),
                      analyze.find_class('somethingelse', definitions))
Exemplo n.º 7
0
 def test_calls_link_to_their_parent(self):
     definitions = analyze.find_definitions('tests/files/example.py')
     found_class = analyze.find_class('somethingelse', definitions)
     self.assertEqual(cls('Example', funct('somethingelse')),
                      found_class.calls[0].parent)
Exemplo n.º 8
0
 def test_find_class_is_recursive(self):
     definitions = analyze.find_definitions('tests/files/example.py')
     found_class = analyze.find_class('somethingelse', definitions)
     self.assertEqual(len(found_class.calls), 1)
     self.assertEqual(cls('ThingTwo', funct('two')), found_class.calls[0])
Exemplo n.º 9
0
 def test_find_class_returns_functions(self):
     definitions = analyze.find_definitions('tests/files/example.py')
     self.assertEqual(funct('start'),
                      analyze.find_class('start', definitions))
Exemplo n.º 10
0
 def test_find_class_return_none_when_no_match(self):
     definitions = analyze.find_definitions('tests/files/example.py')
     self.assertEqual(None, analyze.find_class('notafunction', definitions))