Back to index

python-biopython  1.60
Classes | Functions | Variables
test_Tutorial Namespace Reference

Classes

class  TutorialDocTestHolder
class  TutorialTestCase

Functions

def _extract
def extract_doctests
def funct

Variables

tuple rt = refactor.RefactoringTool(refactor.get_fixers_from_package("lib2to3.fixes"))
tuple tutorial = os.path.join(os.path.dirname(sys.argv[0]), "../Doc/Tutorial.tex")
tuple tutorial_base = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../Doc/"))
tuple original_path = os.path.abspath(".")
tuple example = rt.refactor_docstring(example, name)
tuple tests = doctest.testmod()

Class Documentation

class test_Tutorial::TutorialDocTestHolder
Python doctests extracted from the Biopython Tutorial.

Definition at line 72 of file test_Tutorial.py.


Function Documentation

def test_Tutorial._extract (   handle) [private]

Definition at line 16 of file test_Tutorial.py.

00016 
00017 def _extract(handle):
00018     line = handle.readline()
00019     if line != "\\begin{verbatim}\n":
00020         raise ValueError("Any '%doctest' or '%cont-doctest' line should be followed by '\\begin{verbatim}'")
00021     lines = []
00022     while True:
00023         line = handle.readline()
00024         if not line:
00025             if lines:
00026                 print "".join(lines[:30])
00027                 raise ValueError("Didn't find end of test starting: %r", lines[0])
00028             else:
00029                 raise ValueError("Didn't find end of test!")
00030         elif line.startswith("\end{verbatim}"):
00031             break
00032         else:
00033             lines.append(line)
00034     return lines
    

Here is the caller graph for this function:

def test_Tutorial.extract_doctests (   latex_filename)
Scans LaTeX file and pulls out marked doctests as strings.

Definition at line 35 of file test_Tutorial.py.

00035 
00036 def extract_doctests(latex_filename):
00037     """Scans LaTeX file and pulls out marked doctests as strings."""
00038     handle = open(latex_filename, "rU")
00039     line_number = 0
00040     in_test = False
00041     lines = []
00042     while True:
00043         line = handle.readline()
00044         line_number += 1
00045         if not line:
00046             #End of file
00047             break
00048         elif line.startswith("%cont-doctest"):
00049             x = _extract(handle)
00050             lines.extend(x)
00051             line_number += len(x) + 2
00052         elif line.startswith("%doctest"):
00053             if lines:
00054                 if not lines[0].startswith(">>> "):
00055                     raise ValueError("Should start '>>> ' not %r" % lines[0])
00056                 yield name, "".join(lines), folder
00057                 lines = []
00058             try:
00059                 folder = line.split(None,1)[1].strip()
00060             except:
00061                 folder = ""
00062             name = "test_from_line_%05i" % line_number
00063             x = _extract(handle)
00064             lines.extend(x)
00065             line_number += len(x) + 2
00066     handle.close()
00067     if lines:
00068         if not lines[0].startswith(">>> "):
00069             raise ValueError("Should start '>>> ' not %r" % lines[0])
00070         yield name, "".join(lines), folder
00071     #yield "dummy", ">>> 2 + 2\n5\n"

Here is the call graph for this function:

def test_Tutorial.funct (   n,
  d,
  f 
)

Definition at line 81 of file test_Tutorial.py.

00081 
00082     def funct(n, d, f):
00083         global tutorial_base
00084         method = lambda x : None
00085         if f:
00086             p = os.path.join(tutorial_base, f)
00087             method.__doc__ = "%s\n\n>>> import os\n>>> os.chdir(%r)\n%s\n" \
00088                            % (n, p, d)
00089         else:
00090             method.__doc__ = "%s\n\n%s\n" % (n, d)
00091         method._folder = f
        return method

Variable Documentation

tuple test_Tutorial.example = rt.refactor_docstring(example, name)

Definition at line 80 of file test_Tutorial.py.

tuple test_Tutorial.original_path = os.path.abspath(".")

Definition at line 14 of file test_Tutorial.py.

tuple test_Tutorial.rt = refactor.RefactoringTool(refactor.get_fixers_from_package("lib2to3.fixes"))

Definition at line 8 of file test_Tutorial.py.

tuple test_Tutorial.tests = doctest.testmod()

Definition at line 126 of file test_Tutorial.py.

tuple test_Tutorial.tutorial = os.path.join(os.path.dirname(sys.argv[0]), "../Doc/Tutorial.tex")

Definition at line 12 of file test_Tutorial.py.

tuple test_Tutorial.tutorial_base = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../Doc/"))

Definition at line 13 of file test_Tutorial.py.