[Checkins] SVN: manuel/branches/benji-python3/ tests pass, some buildout parts are disabled
Benji York
cvs-admin at zope.org
Mon Apr 16 18:27:54 UTC 2012
Log message for revision 125146:
tests pass, some buildout parts are disabled
Changed:
U manuel/branches/benji-python3/buildout.cfg
U manuel/branches/benji-python3/setup.py
U manuel/branches/benji-python3/src/index.txt
U manuel/branches/benji-python3/src/manuel/README.txt
U manuel/branches/benji-python3/src/manuel/__init__.py
U manuel/branches/benji-python3/src/manuel/bugs.txt
U manuel/branches/benji-python3/src/manuel/codeblock.py
U manuel/branches/benji-python3/src/manuel/doctest.py
U manuel/branches/benji-python3/src/manuel/table-example.txt
U manuel/branches/benji-python3/src/manuel/testing.py
U manuel/branches/benji-python3/src/manuel/tests.py
-=-
Modified: manuel/branches/benji-python3/buildout.cfg
===================================================================
--- manuel/branches/benji-python3/buildout.cfg 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/buildout.cfg 2012-04-16 18:27:51 UTC (rev 125146)
@@ -1,26 +1,16 @@
[buildout]
develop = .
-parts = test interpreter sphinx-docs-html build-docs nosetests releaser
-allow-picked-versions = false
+parts = test interpreter
+#allow-picked-versions = false
use-dependency-links = false
-versions = versions
+#versions = versions
-[releaser]
-recipe = zc.recipe.egg
-eggs = zest.releaser
-
[test]
recipe = zc.recipe.testrunner
eggs = manuel [tests]
defaults = '--tests-pattern tests --exit-with-status -1 --auto-color'.split()
working-directory = .
-# XXX doesn't work yet, either fix or rip out
-[nosetests]
-recipe = pbp.recipe.noserunner
-eggs = manuel
-working-directory = ${buildout:directory}
-
[interpreter]
recipe = zc.recipe.egg
eggs = manuel
Modified: manuel/branches/benji-python3/setup.py
===================================================================
--- manuel/branches/benji-python3/setup.py 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/setup.py 2012-04-16 18:27:51 UTC (rev 125146)
@@ -41,6 +41,7 @@
test_suite = 'manuel.tests.test_suite',
install_requires=[
'setuptools',
+ 'six',
],
include_package_data=True,
long_description = long_description,
Modified: manuel/branches/benji-python3/src/index.txt
===================================================================
--- manuel/branches/benji-python3/src/index.txt 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/index.txt 2012-04-16 18:27:51 UTC (rev 125146)
@@ -298,7 +298,7 @@
>>> import manuel.doctest
>>> m += manuel.doctest.Manuel()
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> print(document.formatted())
This uses the syntax implemented in :mod:`manuel.capture` to capture a block of
text into a variable (the one named after "->").
@@ -358,7 +358,7 @@
.. code-block:: python
- print 'hello'
+ print('hello')
.. Let's create a reST document with a code block.
@@ -372,7 +372,7 @@
...
... A little prose to separate the examples.
...
- ... >>> print x
+ ... >>> print(x)
... hello
...
... """)
@@ -393,7 +393,7 @@
We can see that none of the tests in the document failed:
- >>> print document.formatted(),
+ >>> print(document.formatted())
If the code-block generates some sort of error...
@@ -401,7 +401,7 @@
.. code-block:: python
- print does_not_exist
+ print(does_not_exist)
.. -> source
@@ -412,7 +412,7 @@
>>> document.source.startswith('.. code-block')
True
- >>> document.source.endswith('print does_not_exist\n')
+ >>> document.source.endswith('print(does_not_exist)\n')
True
...that error will be reported:
@@ -459,7 +459,7 @@
>>> import manuel
>>> document = manuel.Document(source)
>>> document.process_with(m, globs={})
- >>> print document.formatted()
+ >>> print(document.formatted())
.. note:: The "invisible-code-block" directive will work with either one or two
colons. The reason is that reST processers (like docutils and Sphinx) will
@@ -531,7 +531,7 @@
>>> import manuel
>>> document = manuel.Document(source)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> print(document.formatted())
.. The order of examples in footnotes is preserved. If not, the document below
would generate an error because "a" won't be defined when "b = a + 1" is
@@ -553,7 +553,7 @@
...
... """)
>>> document.process_with(m, globs={})
- >>> print document.formatted()
+ >>> print(document.formatted())
It is also possible to reference more than one footnote on a single line.
@@ -584,7 +584,7 @@
>>> document = manuel.Document(source)
>>> document.process_with(m, globs={})
- >>> print document.formatted()
+ >>> print(document.formatted())
.. reset-globs
@@ -660,7 +660,7 @@
...the error goes away.
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> print(document.formatted())
Ignoring Literal Blocks
@@ -674,14 +674,14 @@
::
- >>> lambda: print 'hi'
+ >>> lambda: x=1
.. -> source
>>> document = manuel.Document(source)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> print(document.formatted())
.. we want to be very sure that the above example without the ignore actually
generates an error:
@@ -689,16 +689,11 @@
>>> document = manuel.Document(document.source.replace(
... '.. ignore-next-block', ''))
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> print(document.formatted())
File "<memory>"...
- Failed example:
- lambda: print 'hi'
Exception raised:
...
- File "<doctest <memory>[0]>", line 1
- lambda: print 'hi'
- ^
- SyntaxError: invalid syntax
+ SyntaxError: ...
.. reset-globs
@@ -725,7 +720,7 @@
It is still defined.
- >>> print x
+ >>> print(x)
hello
Now we can reset the globals...
@@ -734,7 +729,7 @@
...and the name binding will be gone:
- >>> print x
+ >>> print(x)
Traceback (most recent call last):
...
NameError: name 'x' is not defined
@@ -748,7 +743,7 @@
>>> m = manuel.isolation.Manuel()
>>> m += manuel.doctest.Manuel()
-We can see that after the globals have been reset, the second "print x" line
+We can see that after the globals have been reset, the second "print(x)" line
raises an error.
Of course, resetting to an empty set of global variables isn't always what's
@@ -763,7 +758,7 @@
It is still defined.
- >>> print x
+ >>> print(x)
hello
We can capture the currently defined globals:
@@ -772,27 +767,27 @@
Of course capturing the globals doesn't disturb them.
- >>> print x
+ >>> print(x)
hello
Now if we define a new global...
>>> y = 'goodbye'
- >>> print y
+ >>> print(y)
goodbye
.. reset-globs
...it will disappear after a reset.
- >>> print y
+ >>> print(y)
Traceback (most recent call last):
...
NameError: name 'y' is not defined
But the captured globals will still be defined.
- >>> print x
+ >>> print(x)
hello
.. -> source
@@ -800,7 +795,7 @@
>>> import manuel
>>> document = manuel.Document(source)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> print(document.formatted())
.. reset-globs
@@ -829,18 +824,18 @@
Some prose.
- >>> print 'first test case'
+ >>> print('first test case')
Some more prose.
- >>> print 'still in the first test case'
+ >>> print('still in the first test case')
Second Section
==============
Even more prose.
- >>> print 'second test case'
+ >>> print('second test case')
.. -> source
@@ -850,22 +845,22 @@
>>> m = manuel.testcase.SectionManuel()
>>> m += manuel.doctest.Manuel()
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> print(document.formatted())
File "<memory>"...
Failed example:
- print 'first test case'
+ print('first test case')
Expected nothing
Got:
first test case
File "<memory>"...
Failed example:
- print 'still in the first test case'
+ print('still in the first test case')
Expected nothing
Got:
still in the first test case
File "<memory>"...
Failed example:
- print 'second test case'
+ print('second test case')
Expected nothing
Got:
second test case
@@ -874,7 +869,7 @@
>>> import manuel.testing
>>> for regions in manuel.testing.group_regions_by_test_case(document):
- ... print (regions.location, regions.id)
+ ... print((regions.location, regions.id))
('<memory>', None)
('<memory>', 'First Section')
('<memory>', 'Second Section')
@@ -900,13 +895,13 @@
The following test will be in a test case that is not individually
identifiable.
- >>> print 'first test case (unidentified)'
+ >>> print('first test case (unidentified)')
Some more prose.
.. test-case: first-named-test-case
- >>> print 'first identified test case'
+ >>> print('first identified test case')
Second Section
@@ -918,7 +913,7 @@
Even more prose.
- >>> print 'second identified test case'
+ >>> print('second identified test case')
.. -> source
@@ -926,8 +921,9 @@
>>> m = manuel.testcase.MarkerManuel()
>>> m += manuel.doctest.Manuel()
>>> document.parse_with(m)
+ >>> import six
>>> for regions in manuel.testing.group_regions_by_test_case(document):
- ... print regions.location, regions.id
+ ... six.print_(regions.location, regions.id)
<memory> None
<memory> first-named-test-case
<memory> second-named-test-case
@@ -976,8 +972,9 @@
.. make sure above finds all the test cases appropriately
>>> document.parse_with(m)
+ >>> import six
>>> for regions in manuel.testing.group_regions_by_test_case(document):
- ... print regions.location, regions.id
+ ... six.print_(regions.location, regions.id)
<memory> None
<memory> First Section
<memory> first-named-test-case
Modified: manuel/branches/benji-python3/src/manuel/README.txt
===================================================================
--- manuel/branches/benji-python3/src/manuel/README.txt 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/README.txt 2012-04-16 18:27:51 UTC (rev 125146)
@@ -72,7 +72,7 @@
... )[0]
>>> region.lineno
2
- >>> print region.source
+ >>> six.print_(region.source)
one: 1, 2, 3
two: 4, 5, 7
three: 3, 5, 1
@@ -109,8 +109,8 @@
>>> def parse(document):
... for region in document.find_regions(numbers_test_finder):
... description = region.start_match.group('description')
- ... numbers = map(
- ... int, region.start_match.group('numbers').split(','))
+ ... numbers = list(map(
+ ... int, region.start_match.group('numbers').split(',')))
... test = NumbersTest(description, numbers)
... document.claim_region(region)
... region.parsed = test
@@ -221,17 +221,17 @@
>>> m = manuel.doctest.Manuel()
>>> document.parse_with(m)
>>> for region in document:
- ... print (region.lineno, region.parsed or region.source)
+ ... print((region.lineno, region.parsed or region.source))
(1, 'This is my\ndoctest.\n\n')
- (4, <doctest.Example instance at 0x...>)
+ (4, <doctest.Example ...>)
Now we can evaluate the examples.
>>> document.evaluate_with(m, globs={})
>>> for region in document:
- ... print (region.lineno, region.evaluated or region.source)
+ ... print((region.lineno, region.evaluated or region.source))
(1, 'This is my\ndoctest.\n\n')
- (4, <manuel.doctest.DocTestResult instance at 0x...>)
+ (4, <manuel.doctest.DocTestResult ...>)
And format the results.
@@ -250,7 +250,7 @@
... 42
... """)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
File "<memory>", line 4, in <memory>
Failed example:
1 + 1
@@ -287,7 +287,7 @@
... 42
... """)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
File "<memory>", line 4, in <memory>
Failed example:
1 + 1
@@ -319,7 +319,7 @@
...
... """)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
Globals
-------
@@ -338,7 +338,7 @@
... 1
... """)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
Imported modules are added to the global namespace as well.
@@ -352,7 +352,7 @@
...
... """)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
Combining Test Types
@@ -393,19 +393,19 @@
number tests.
>>> for region in document:
- ... print (region.lineno, region.parsed or region.source)
+ ... print((region.lineno, region.parsed or region.source))
(1, '\nWe can have a list of numbers...\n\n')
(4, <NumbersTest object at 0x...>)
(5, '\n... and we can test Python.\n\n')
- (8, <doctest.Example instance at 0x...>)
+ (8, <doctest.Example ...>)
(10, '\n')
We can look at the formatted output to see that each of the two tests failed.
>>> for region in document:
... if region.formatted:
- ... print '-'*70
- ... print region.formatted,
+ ... six.print_('-'*70)
+ ... six.print_(region.formatted, end='')
----------------------------------------------------------------------
the numbers aren't in sorted order: 3, 6, 2
----------------------------------------------------------------------
@@ -438,7 +438,7 @@
... if region.parsed:
... continue
... if region.source.strip().endswith('my clone:'):
- ... to_be_cloned = document_iter.next().copy()
+ ... to_be_cloned = six.advance_iterator(document_iter).copy()
... break
... # if we found the region to cloned, do so
... if to_be_cloned:
@@ -529,7 +529,7 @@
information.
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
File "<memory>", line 10, in <memory>
Failed example:
a + b
@@ -560,7 +560,7 @@
... """)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
File "<memory>", line 10, in <memory>
Failed example:
a + b # doesn't mention "c"
@@ -576,7 +576,7 @@
Instead of a text-based apprach, let's use the built-in tokenize module to more
robustly identify referenced variables.
- >>> import StringIO
+ >>> from six import StringIO
>>> import token
>>> import tokenize
@@ -586,7 +586,7 @@
...
... if region.evaluated.getvalue():
... vars = set()
- ... reader = StringIO.StringIO(region.source).readline
+ ... reader = StringIO(region.source).readline
... for ttype, tval, _, _, _ in tokenize.generate_tokens(reader):
... if ttype == token.NAME:
... vars.add(tval)
@@ -608,7 +608,7 @@
>>> document = manuel.Document(document.source)
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
File "<memory>", line 10, in <memory>
Failed example:
a + b # doesn't mention "c"
Modified: manuel/branches/benji-python3/src/manuel/__init__.py
===================================================================
--- manuel/branches/benji-python3/src/manuel/__init__.py 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/__init__.py 2012-04-16 18:27:51 UTC (rev 125146)
@@ -25,7 +25,7 @@
module_path = normalize_module_path(imp.find_module(name)[1])
# don't create a new module object if there's already one that we can reuse
- for module in sys.modules.values():
+ for module in list(sys.modules.values()):
if module is None or not hasattr(module, '__file__'):
continue
if module_path == normalize_module_path(module.__file__):
@@ -179,7 +179,7 @@
"""
return iter(self.regions)
- def __nonzero__(self):
+ def __bool__(self):
return bool(self.regions)
@@ -198,7 +198,7 @@
def find_regions(self, start, end=None):
def compile(regex):
- if regex is not None and isinstance(regex, basestring):
+ if regex is not None and isinstance(regex, str):
regex = re.compile(regex)
return regex
@@ -314,6 +314,10 @@
self.insert_region('after', marker_region, new_region)
+def call(func):
+ return func()
+
+
class Manuel(object):
_debug = False
@@ -354,7 +358,7 @@
self.formatters.extend(other.formatters)
# the testing integration (manuel.testing) sets this flag when needed
- @apply
+ @call
def debug():
def getter(self):
debug = self._debug
Modified: manuel/branches/benji-python3/src/manuel/bugs.txt
===================================================================
--- manuel/branches/benji-python3/src/manuel/bugs.txt 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/bugs.txt 2012-04-16 18:27:51 UTC (rev 125146)
@@ -83,7 +83,7 @@
The doctest in the `source` variable ran with no errors.
- >>> print document.formatted()
+ >>> six.print_(document.formatted())
And now the globs dictionary reflects the changes made when the doctest ran.
@@ -142,7 +142,7 @@
The doctest in the `source` variable ran with no errors.
- >>> print document.formatted()
+ >>> six.print_(document.formatted())
We should clean up now.
@@ -192,5 +192,5 @@
>>> from manuel.testing import TestCase
>>> m = manuel.Manuel()
- >>> print TestCase(m, manuel.RegionContainer(), None).id()
+ >>> six.print_(TestCase(m, manuel.RegionContainer(), None).id())
<memory>
Modified: manuel/branches/benji-python3/src/manuel/codeblock.py
===================================================================
--- manuel/branches/benji-python3/src/manuel/codeblock.py 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/codeblock.py 2012-04-16 18:27:51 UTC (rev 125146)
@@ -27,7 +27,7 @@
if not isinstance(region.parsed, CodeBlock):
return
- exec region.parsed.code in globs
+ exec(region.parsed.code, globs)
del globs['__builtins__'] # exec adds __builtins__, we don't want it
Modified: manuel/branches/benji-python3/src/manuel/doctest.py
===================================================================
--- manuel/branches/benji-python3/src/manuel/doctest.py 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/doctest.py 2012-04-16 18:27:51 UTC (rev 125146)
@@ -1,11 +1,11 @@
-import StringIO
+import six
import manuel
import os.path
doctest = manuel.absolute_import('doctest')
-class DocTestResult(StringIO.StringIO):
+class DocTestResult(six.StringIO):
pass
@@ -17,7 +17,7 @@
region_end = region.lineno + region.source.count('\n')
for chunk in parser.parse(region.source):
# If the chunk contains prose (as opposed to and example), skip it.
- if isinstance(chunk, basestring):
+ if isinstance(chunk, str):
continue
chunk._manual = m
Modified: manuel/branches/benji-python3/src/manuel/table-example.txt
===================================================================
--- manuel/branches/benji-python3/src/manuel/table-example.txt 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/table-example.txt 2012-04-16 18:27:51 UTC (rev 125146)
@@ -104,6 +104,7 @@
.. code-block:: python
import re
+ import six
table_start = re.compile(r'(?<=\n\n)=[= ]+\n(?=[ \t]*?\S)', re.DOTALL)
table_end = re.compile(r'\n=[= ]+\n(?=\Z|\n)', re.DOTALL)
@@ -111,17 +112,17 @@
def parse_tables(document):
for region in document.find_regions(table_start, table_end):
lines = enumerate(iter(region.source.splitlines()))
- lines.next() # skip the first line
+ six.advance_iterator(lines) # skip the first line
# grab the expression to be evaluated
- expression = lines.next()[1]
+ expression = six.advance_iterator(lines)[1]
if expression.startswith('\\'):
expression = expression[1:]
- lines.next() # skip the divider line
- variables = [v.strip() for v in lines.next()[1].split()][:-1]
+ six.advance_iterator(lines) # skip the divider line
+ variables = [v.strip() for v in six.advance_iterator(lines)[1].split()][:-1]
- lines.next() # skip the divider line
+ six.advance_iterator(lines) # skip the divider line
examples = []
for lineno_offset, line in lines:
@@ -142,7 +143,8 @@
>>> parse_tables(document)
>>> region = list(document)[1]
- >>> print region.source,
+ >>> import six
+ >>> six.print_(region.source, end='')
===== ===== ======
\ A or B
--------------------
@@ -278,7 +280,7 @@
We can see how the results are formatted.
>>> format_table_errors(document)
- >>> print region.formatted,
+ >>> six.print_(region.formatted, end='')
when evaluating table at fake.txt, line 6
fake.txt, line 11: expected True, got False instead.
fake.txt, line 13: expected False, got True instead.
@@ -303,7 +305,7 @@
>>> m = Manuel()
>>> document = manuel.Document(source_with_errors, location='fake.txt')
>>> document.process_with(m, globs={})
- >>> print document.formatted(),
+ >>> six.print_(document.formatted(), end='')
when evaluating table at fake.txt, line 6
fake.txt, line 11: expected True, got False instead.
fake.txt, line 13: expected False, got True instead.
@@ -312,7 +314,7 @@
>>> document = manuel.Document(source, location='fake.txt')
>>> document.process_with(m, globs={})
- >>> print document.formatted()
+ >>> six.print_(document.formatted())
If we wanted to use instances of our Manuel object in a test, we would follow
the directions in :ref:`getting-started`, importing Manuel from the module
Modified: manuel/branches/benji-python3/src/manuel/testing.py
===================================================================
--- manuel/branches/benji-python3/src/manuel/testing.py 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/testing.py 2012-04-16 18:27:51 UTC (rev 125146)
@@ -1,4 +1,4 @@
-import doctest
+from . import doctest
import inspect
import itertools
import manuel
@@ -70,7 +70,7 @@
while True:
region = None # being defensive
try:
- region = document_iter.next()
+ region = next(document_iter)
except StopIteration:
if not accumulated_regions:
break
@@ -94,7 +94,7 @@
# if there are no more regions, stop
try:
- region = document_iter.next()
+ region = next(document_iter)
except StopIteration:
break
Modified: manuel/branches/benji-python3/src/manuel/tests.py
===================================================================
--- manuel/branches/benji-python3/src/manuel/tests.py 2012-04-16 18:21:23 UTC (rev 125145)
+++ manuel/branches/benji-python3/src/manuel/tests.py 2012-04-16 18:27:51 UTC (rev 125146)
@@ -1,4 +1,4 @@
-import doctest
+from . import doctest
import manuel
import manuel.capture
import manuel.codeblock
@@ -32,7 +32,7 @@
... 5
... ''')
>>> document.process_with(manuel.doctest.Manuel(), globs={})
- >>> print document.formatted()
+ >>> print(document.formatted())
File "<memory>", line 3, in <memory>
Failed example:
2 + 2
More information about the checkins
mailing list