[svn r38142] Fixed problem with indentation in the results of a doctest.

--HG--
branch : trunk
This commit is contained in:
guido
2007-02-08 14:47:23 +01:00
parent fd0cbdb95a
commit 5ea9a43dce
2 changed files with 46 additions and 4 deletions

View File

@@ -52,6 +52,15 @@ def test_doctest_basic():
l2 = session.getitemoutcomepairs(Skipped)
assert len(l+l2) == 2
def test_deindent():
from py.__.doc.conftest import deindent
assert deindent('foo') == 'foo'
assert deindent('foo\n bar') == 'foo\n bar'
assert deindent(' foo\n bar\n') == 'foo\nbar\n'
assert deindent(' foo\n\n bar\n') == 'foo\n\nbar\n'
assert deindent(' foo\n bar\n') == 'foo\n bar\n'
assert deindent(' foo\n bar\n') == ' foo\nbar\n'
def test_doctest_eol():
# XXX get rid of the next line:
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
@@ -67,6 +76,21 @@ def test_doctest_eol():
l2 = session.getitemoutcomepairs(Skipped)
assert len(l+l2) == 2
def test_doctest_indentation():
# XXX get rid of the next line:
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
txt = tmpdir.join('foo.txt')
txt.write('..\n >>> print "foo\\n bar"\n foo\n bar\n')
config = py.test.config._reparse([txt])
session = config.initsession()
session.main()
l = session.getitemoutcomepairs(Failed)
assert len(l) == 0
l = session.getitemoutcomepairs(Passed)
l2 = session.getitemoutcomepairs(Skipped)
assert len(l+l2) == 2
def test_js_ignore():
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
tmpdir.ensure('__init__.py')