improved run test documentation

This commit is contained in:
David Halter
2013-03-01 00:31:51 +04:30
parent c808bcef70
commit 68a9cecb27

View File

@@ -66,8 +66,19 @@ sys.path.pop(0) # pop again, because it might affect the completion
def run_completion_test(script, correct, line_nr): def run_completion_test(script, correct, line_nr):
""" """
Runs tests for completions. Uses comments to specify a test in the next line. The comment says, which
Return if the test was a fail or not, with 1 for fail and 0 for success. results are expected. The comment always begins with `#?`. The last row
symbolizes the cursor.
For example:
>>> #? ['real']
>>> a = 3; a.rea
Because it follows ``a.rea`` and a is an ``int``, which has a ``real``
property.
Returns 1 for fail and 0 for success.
""" """
completions = script.complete() completions = script.complete()
#import cProfile; cProfile.run('script.complete()') #import cProfile; cProfile.run('script.complete()')
@@ -82,8 +93,13 @@ def run_completion_test(script, correct, line_nr):
def run_definition_test(script, should_str, line_nr): def run_definition_test(script, should_str, line_nr):
""" """
Runs tests for definitions. Definition tests use the same symbols like completion tests. This is
Return if the test was a fail or not, with 1 for fail and 0 for success. possible because the completion tests are defined with a list.
>>> #? int()
>>> ab = 3; ab
Returns 1 for fail and 0 for success.
""" """
result = script.definition() result = script.definition()
is_str = set(r.desc_with_module for r in result) is_str = set(r.desc_with_module for r in result)
@@ -96,21 +112,19 @@ def run_definition_test(script, should_str, line_nr):
def run_goto_test(script, correct, line_nr): def run_goto_test(script, correct, line_nr):
""" """
Runs tests for gotos. Tests look like this: Tests look like this:
>>> abc = 1 >>> abc = 1
>>> #! ['abc=1'] >>> #! ['abc=1']
>>> abc >>> abc
Additionally it is possible to add a number which describes to position of Additionally it is possible to add a number which describes to position of
the test (otherwise it's just end of line. the test (otherwise it's just end of line).
>>> #! 2 ['abc=1'] >>> #! 2 ['abc=1']
>>> abc >>> abc
For the tests the important things in the end are the positions. Returns 1 for fail and 0 for success.
Return if the test was a fail or not, with 1 for fail and 0 for success.
""" """
result = script.goto() result = script.goto()
comp_str = str(sorted(str(r.description) for r in result)) comp_str = str(sorted(str(r.description) for r in result))
@@ -123,13 +137,13 @@ def run_goto_test(script, correct, line_nr):
def run_related_name_test(script, correct, line_nr): def run_related_name_test(script, correct, line_nr):
""" """
Runs tests for gotos. Tests look like this: Tests look like this:
>>> abc = 1 >>> abc = 1
>>> #< abc@1,0 abc@3,0 >>> #< abc@1,0 abc@3,0
>>> abc >>> abc
Return if the test was a fail or not, with 1 for fail and 0 for success. Returns 1 for fail and 0 for success.
""" """
result = script.related_names() result = script.related_names()
correct = correct.strip() correct = correct.strip()
@@ -159,17 +173,6 @@ def run_test(source, f_name, lines_to_execute):
""" """
This is the completion test for some cases. The tests are not unit test This is the completion test for some cases. The tests are not unit test
like, they are rather integration tests. like, they are rather integration tests.
It uses comments to specify a test in the next line. The comment also says,
which results are expected. The comment always begins with `#?`. The last
row symbolizes the cursor.
For example:
>>> #? ['ab']
>>> ab = 3; a
>>> #? int()
>>> ab = 3; ab
""" """
def definition(correct, correct_start, path): def definition(correct, correct_start, path):
def defs(line_nr, indent): def defs(line_nr, indent):