mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-17 05:49:37 +08:00
Document test_full_name.py
This commit is contained in:
@@ -1,3 +1,19 @@
|
|||||||
|
"""
|
||||||
|
Tests for :attr:`.BaseDefinition.full_name`.
|
||||||
|
|
||||||
|
There are three kinds of test:
|
||||||
|
|
||||||
|
#. Test classes derived from :class:`MixinTestFullName`.
|
||||||
|
Child class defines :meth:`.get_definitions` to alter how
|
||||||
|
the api definition instance is created.
|
||||||
|
|
||||||
|
#. :class:`TestFullDefinedName` is to test combination of
|
||||||
|
:attr:`.full_name` and :func:`.defined_names`.
|
||||||
|
|
||||||
|
#. Misc single-function tests.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import jedi
|
import jedi
|
||||||
@@ -7,6 +23,12 @@ from .base import TestBase
|
|||||||
|
|
||||||
class MixinTestFullName(object):
|
class MixinTestFullName(object):
|
||||||
|
|
||||||
|
def get_definitions(self, source):
|
||||||
|
"""
|
||||||
|
Get definition objects of the variable at the end of `source`.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def check(self, source, desired):
|
def check(self, source, desired):
|
||||||
definitions = self.get_definitions(textwrap.dedent(source))
|
definitions = self.get_definitions(textwrap.dedent(source))
|
||||||
self.assertEqual(definitions[0].full_name, desired)
|
self.assertEqual(definitions[0].full_name, desired)
|
||||||
@@ -38,6 +60,10 @@ class TestFullNameWithCompletions(MixinTestFullName, TestBase):
|
|||||||
|
|
||||||
class TestFullDefinedName(TestBase):
|
class TestFullDefinedName(TestBase):
|
||||||
|
|
||||||
|
"""
|
||||||
|
Test combination of :attr:`.full_name` and :func:`.defined_names`.
|
||||||
|
"""
|
||||||
|
|
||||||
def check(self, source, desired):
|
def check(self, source, desired):
|
||||||
definitions = jedi.defined_names(textwrap.dedent(source))
|
definitions = jedi.defined_names(textwrap.dedent(source))
|
||||||
full_names = [d.full_name for d in definitions]
|
full_names = [d.full_name for d in definitions]
|
||||||
|
|||||||
Reference in New Issue
Block a user