mirror of
https://github.com/python/cpython.git
synced 2025-09-13 12:17:24 +00:00
doctest assumed that a package's __loader__.get_data() method used universal
newlines; it doesn't. To rectify this the string returned replaces all instances of os.linesep with '\n' to fake universal newline support. Backport candidate.
This commit is contained in:
parent
901071bde5
commit
43e53f85b6
3 changed files with 24 additions and 1 deletions
|
@ -1908,6 +1908,23 @@ def test_DocFileSuite():
|
|||
>>> suite.run(unittest.TestResult())
|
||||
<unittest.TestResult run=3 errors=0 failures=3>
|
||||
|
||||
Support for using a package's __loader__.get_data() is also
|
||||
provided.
|
||||
|
||||
>>> import unittest, pkgutil, test
|
||||
>>> if not hasattr(test, '__loader__'):
|
||||
... test.__loader__ = pkgutil.get_loader(test)
|
||||
... added_loader = True
|
||||
>>> try:
|
||||
... suite = doctest.DocFileSuite('test_doctest.txt',
|
||||
... 'test_doctest2.txt',
|
||||
... 'test_doctest4.txt',
|
||||
... package='test')
|
||||
... suite.run(unittest.TestResult())
|
||||
... finally:
|
||||
... del test.__loader__
|
||||
<unittest.TestResult run=3 errors=0 failures=3>
|
||||
|
||||
'/' should be used as a path separator. It will be converted
|
||||
to a native separator at run time:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue