1
0
forked from VimPlug/jedi

documentation and clean up, #181

This commit is contained in:
David Halter
2013-08-07 18:26:41 +04:30
parent 04e454269c
commit 45432c6cb0
10 changed files with 65 additions and 27 deletions

View File

@@ -1,3 +1,8 @@
"""
A helper module for testing, improves compatibility for testing (as
``jedi._compatibility``) as well as introducing helper functions.
"""
import sys
if sys.hexversion < 0x02070000:
import unittest2 as unittest

View File

@@ -1,3 +1,7 @@
"""
Test all things related to the ``jedi.api`` module.
"""
import jedi
from jedi import common

View File

@@ -1,3 +1,6 @@
""" Test all things related to the ``jedi.api_classes`` module.
"""
import textwrap
import pytest
@@ -5,6 +8,7 @@ import pytest
from jedi import api
import jedi
def test_is_keyword():
results = jedi.Script('import ', 1, 1, None).goto_definitions()
assert len(results) == 1 and results[0].is_keyword == True
@@ -57,3 +61,21 @@ def make_definitions():
def test_basedefinition_type(definition):
assert definition.type in ('module', 'class', 'instance', 'function',
'generator', 'statement', 'import', 'param')
def test_function_call_signature_in_doc():
defs = jedi.Script("""
def f(x, y=1, z='a'):
pass
f""").goto_definitions()
doc = defs[0].doc
assert "f(x, y = 1, z = 'a')" in doc
def test_class_call_signature():
defs = jedi.Script("""
class Foo:
def __init__(self, x, y=1, z='a'):
pass
Foo""").goto_definitions()
doc = defs[0].doc
assert "Foo(self, x, y = 1, z = 'a')" in doc

View File

@@ -1,3 +1,7 @@
"""
Test all things related to the ``jedi.cache`` module.
"""
import time
import pytest

View File

@@ -1,3 +1,7 @@
"""
Testing of docstring related issues and especially ``jedi.docstrings``.
"""
import jedi
from .base import unittest

View File

@@ -1,8 +1,12 @@
from .base import cwd_at
"""
Tests of various import related things that could not be tested with "Black Box
Tests".
"""
import itertools
from jedi import Script
from .base import cwd_at
def test_goto_definition_on_import():

View File

@@ -1,3 +1,6 @@
"""
Test of keywords and ``jedi.keywords``
"""
import jedi
from jedi import Script, common

View File

@@ -1,9 +1,13 @@
from .base import unittest
"""
Tests of ``jedi.api.Interpreter``.
"""
from .base import TestCase
import jedi
from jedi._compatibility import is_py33
class TestInterpreterAPI(unittest.TestCase):
class TestInterpreterAPI(TestCase):
def check_interpreter_complete(self, source, namespace, completions,
**kwds):
script = jedi.Interpreter(source, [namespace], **kwds)

View File

@@ -1,23 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Unit tests to avoid errors of the past. Makes use of Python's ``unittest``
module.
Unit tests to avoid errors of the past. These are also all tests that didn't
found a good place in any other testing module.
"""
import os
import textwrap
from .base import unittest, cwd_at
from .base import TestCase, cwd_at
import jedi
from jedi import Script
from jedi import api, parsing, common
from jedi import api, parsing
#jedi.set_debug_function(jedi.debug.print_to_stdout)
class TestRegression(unittest.TestCase):
class TestRegression(TestCase):
def test_goto_definition_cursor(self):
s = ("class A():\n"
@@ -59,23 +59,6 @@ class TestRegression(unittest.TestCase):
assert len(r) == 1
assert len(r[0].doc) > 100
def test_function_call_signature(self):
defs = Script("""
def f(x, y=1, z='a'):
pass
f""").goto_definitions()
doc = defs[0].doc
assert "f(x, y = 1, z = 'a')" in doc
def test_class_call_signature(self):
defs = Script("""
class Foo:
def __init__(self, x, y=1, z='a'):
pass
Foo""").goto_definitions()
doc = defs[0].doc
assert "Foo(self, x, y = 1, z = 'a')" in doc
def test_goto_definition_at_zero(self):
assert Script("a", 1, 1).goto_definitions() == []
s = Script("str", 1, 1).goto_definitions()

View File

@@ -1,10 +1,15 @@
"""
Speed tests of Jedi. To prove that certain things don't take longer than they
should.
"""
import time
import functools
from .base import unittest
from .base import TestCase
import jedi
class TestSpeed(unittest.TestCase):
class TestSpeed(TestCase):
def _check_speed(time_per_run, number=4, run_warm=True):
""" Speed checks should typically be very tolerant. Some machines are
faster than others, but the tests should still pass. These tests are