Comment #7 on issue 1641 by asmeurer: doctests require newline only when
run for single file
http://code.google.com/p/sympy/issues/detail?id=1641
Here are perhaps some clues:
>>> doctest('sympy/simplify/simplify.py')
============================= test process starts
==============================
executable:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
(2.6.2-final-0)
sympy/simplify/simplify.py[12] ............
[OK]
================== tests finished: 12 passed in 0.45 seconds
===================
doc_file sympy/simplify/simplify.py
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "./sympy/utilities/runtests.py", line 169, in doctest
pdoctest.NORMALIZE_WHITESPACE)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1954, in testfile
test = parser.get_doctest(text, globs, name, filename, 0)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 597, in
get_doctest
return DocTest(self.get_examples(string, name), globs,
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 611, in
get_examples
return [x for x in self.parse(string, name)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 573, in parse
self._parse_example(m, name, lineno)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 643, in
_parse_example
lineno + len(source_lines))
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 729, in
_check_prefix
(lineno+i+1, name, line))
ValueError: line 799 of the docstring for simplify.py has inconsistent
leading whitespace: ' """'
>>> doctest('sympy/solvers/solvers.py')
============================= test process starts
==============================
executable:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
(2.6.2-final-0)
sympy/solvers/solvers.py[6] ......
[OK]
=================== tests finished: 6 passed in 0.12 seconds
===================
doc_file sympy/solvers/solvers.py
**********************************************************************
File "sympy/solvers/solvers.py", line 60, in solvers.py
Failed example:
guess_solve_strategy(x**2 + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[2]>", line 1, in <module>
guess_solve_strategy(x**2 + 1, x)
NameError: name 'guess_solve_strategy' is not defined
**********************************************************************
File "sympy/solvers/solvers.py", line 62, in solvers.py
Failed example:
guess_solve_strategy(x**Rational(1,2) + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[3]>", line 1, in <module>
guess_solve_strategy(x**Rational(1,2) + 1, x)
NameError: name 'guess_solve_strategy' is not defined
**********************************************************************
1 items had failures:
2 of 31 in solvers.py
***Test Failed*** 2 failures.
Testing sympy/solvers/solvers.py
Failed 2, tested 31
DO *NOT* COMMIT!
False
>>> doctest('sympy/solvers/solvers.py', 'sympy/simplify/simplify.py')
============================= test process starts
==============================
executable:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
(2.6.2-final-0)
sympy/solvers/solvers.py[6] ......
[OK]
sympy/simplify/simplify.py[12] ............
[OK]
================== tests finished: 18 passed in 0.45 seconds
===================
doc_file sympy/solvers/solvers.py
**********************************************************************
File "sympy/solvers/solvers.py", line 60, in solvers.py
Failed example:
guess_solve_strategy(x**2 + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[2]>", line 1, in <module>
guess_solve_strategy(x**2 + 1, x)
NameError: name 'guess_solve_strategy' is not defined
**********************************************************************
File "sympy/solvers/solvers.py", line 62, in solvers.py
Failed example:
guess_solve_strategy(x**Rational(1,2) + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[3]>", line 1, in <module>
guess_solve_strategy(x**Rational(1,2) + 1, x)
NameError: name 'guess_solve_strategy' is not defined
**********************************************************************
1 items had failures:
2 of 31 in solvers.py
***Test Failed*** 2 failures.
Testing sympy/solvers/solvers.py
Failed 2, tested 31
doc_file sympy/simplify/simplify.py
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "./sympy/utilities/runtests.py", line 169, in doctest
pdoctest.NORMALIZE_WHITESPACE)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1954, in testfile
test = parser.get_doctest(text, globs, name, filename, 0)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 597, in
get_doctest
return DocTest(self.get_examples(string, name), globs,
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 611, in
get_examples
return [x for x in self.parse(string, name)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 573, in parse
self._parse_example(m, name, lineno)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 643, in
_parse_example
lineno + len(source_lines))
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 729, in
_check_prefix
(lineno+i+1, name, line))
ValueError: line 799 of the docstring for simplify.py has inconsistent
leading whitespace: ' """'
>>> doctest('sympy/simplify/simplify.py', 'sympy/solvers/solvers.py')
============================= test process starts
==============================
executable:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
(2.6.2-final-0)
sympy/simplify/simplify.py[12] ............
[OK]
sympy/solvers/solvers.py[6] ......
[OK]
================== tests finished: 18 passed in 0.43 seconds
===================
doc_file sympy/simplify/simplify.py
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "./sympy/utilities/runtests.py", line 169, in doctest
pdoctest.NORMALIZE_WHITESPACE)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1954, in testfile
test = parser.get_doctest(text, globs, name, filename, 0)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 597, in
get_doctest
return DocTest(self.get_examples(string, name), globs,
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 611, in
get_examples
return [x for x in self.parse(string, name)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 573, in parse
self._parse_example(m, name, lineno)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 643, in
_parse_example
lineno + len(source_lines))
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 729, in
_check_prefix
(lineno+i+1, name, line))
ValueError: line 799 of the docstring for simplify.py has inconsistent
leading whitespace: ' """'
Notice how testing simplify before solvers prevents the solvers errors from
being reported.
Now, here is a more important clue. This is what is being run internally:
>>> doc_file1='sympy/solvers/solvers.py'
>>> doc_file2='sympy/simplify/simplify.py'
>>> import doctest as pdoctest
>>> pdoctest.testfile(doc_file2, module_relative=False,
>>> optionflags=pdoctest.ELLIPSIS |
pdoctest.NORMALIZE_WHITESPACE)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1954, in testfile
test = parser.get_doctest(text, globs, name, filename, 0)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 597, in
get_doctest
return DocTest(self.get_examples(string, name), globs,
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 611, in
get_examples
return [x for x in self.parse(string, name)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 573, in parse
self._parse_example(m, name, lineno)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 643, in
_parse_example
lineno + len(source_lines))
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 729, in
_check_prefix
(lineno+i+1, name, line))
ValueError: line 799 of the docstring for simplify.py has inconsistent
leading whitespace: ' """'
>>> pdoctest.testfile(doc_file1, module_relative=False,
>>> optionflags=pdoctest.ELLIPSIS |
pdoctest.NORMALIZE_WHITESPACE)
**********************************************************************
File "sympy/solvers/solvers.py", line 60, in solvers.py
Failed example:
guess_solve_strategy(x**2 + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[2]>", line 1, in <module>
guess_solve_strategy(x**2 + 1, x)
NameError: name 'guess_solve_strategy' is not defined
**********************************************************************
File "sympy/solvers/solvers.py", line 62, in solvers.py
Failed example:
guess_solve_strategy(x**Rational(1,2) + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[3]>", line 1, in <module>
guess_solve_strategy(x**Rational(1,2) + 1, x)
NameError: name 'guess_solve_strategy' is not defined
Traceback (most recent call last):
File "<console>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1955, in testfile
runner.run(test)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1374, in run
return self.__run(test, compileflags, out)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1290, in __run
self.report_failure(out, test, example, got)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1154, in
report_failure
self._checker.output_difference(example, got, self.optionflags))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2148' in
position 212: ordinal not in range(128)
>>> u'\u2148'
ⅈ
>>> try:
... pdoctest.testfile(doc_file1, module_relative=False,
optionflags=pdoctest.ELLIPSIS |
pdoctest.NORMALIZE_WHITESPACE)
... except UnicodeEncodeError:
... print 'Error raised'
...
**********************************************************************
File "sympy/solvers/solvers.py", line 60, in solvers.py
Failed example:
guess_solve_strategy(x**2 + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[2]>", line 1, in <module>
guess_solve_strategy(x**2 + 1, x)
NameError: name 'guess_solve_strategy' is not defined
**********************************************************************
File "sympy/solvers/solvers.py", line 62, in solvers.py
Failed example:
guess_solve_strategy(x**Rational(1,2) + 1, x)
Exception raised:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py",
line 1241, in __run
compileflags, 1) in test.globs
File "<doctest solvers.py[3]>", line 1, in <module>
guess_solve_strategy(x**Rational(1,2) + 1, x)
NameError: name 'guess_solve_strategy' is not defined
Error raised
As the last line shows, the runner raises UnicodeEncodeError with
solvers.py for some reason. This happens
in line 167 of runtests.py.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---