fix some standalone-script running issues:

* standalone can run standalone tests
* exception handling is more careful with assuming valid filenames
* bits here and there

--HG--
branch : trunk
This commit is contained in:
holger krekel
2009-12-30 18:11:00 +01:00
parent 6495007aba
commit a42d9eb9f6
5 changed files with 22 additions and 16 deletions

View File

@@ -1,5 +1,7 @@
from py.plugin.pytest_doctest import DoctestModule, DoctestTextfile
pytest_plugins = ["pytest_doctest"]
class TestDoctests:
def test_collect_testtextfile(self, testdir):
@@ -12,14 +14,15 @@ class TestDoctests:
""")
for x in (testdir.tmpdir, checkfile):
#print "checking that %s returns custom items" % (x,)
items, reprec = testdir.inline_genitems(x)
items, reprec = testdir.inline_genitems(x, '-p', 'doctest')
assert len(items) == 1
assert isinstance(items[0], DoctestTextfile)
def test_collect_module(self, testdir):
path = testdir.makepyfile(whatever="#")
for p in (path, testdir.tmpdir):
items, reprec = testdir.inline_genitems(p, '--doctest-modules')
items, reprec = testdir.inline_genitems(p, '-p', 'doctest',
'--doctest-modules')
assert len(items) == 1
assert isinstance(items[0], DoctestModule)
@@ -29,7 +32,7 @@ class TestDoctests:
>>> x == 1
False
""")
reprec = testdir.inline_run(p)
reprec = testdir.inline_run(p, '-p', 'doctest')
reprec.assertoutcome(failed=1)
def test_doctest_unexpected_exception(self, testdir):
@@ -41,7 +44,7 @@ class TestDoctests:
>>> x
2
""")
reprec = testdir.inline_run(p)
reprec = testdir.inline_run(p, '-p', 'doctest')
call = reprec.getcall("pytest_runtest_logreport")
assert call.report.failed
assert call.report.longrepr
@@ -60,7 +63,7 @@ class TestDoctests:
'''
""")
reprec = testdir.inline_run(p, "--doctest-modules")
reprec = testdir.inline_run(p, '-p', 'doctest', "--doctest-modules")
reprec.assertoutcome(failed=1)
def test_doctestmodule_external(self, testdir):
@@ -73,7 +76,7 @@ class TestDoctests:
2
'''
""")
result = testdir.runpytest(p, "--doctest-modules")
result = testdir.runpytest(p, '-p', 'doctest', "--doctest-modules")
result.stdout.fnmatch_lines([
'004 *>>> i = 0',
'005 *>>> i + 1',
@@ -91,7 +94,7 @@ class TestDoctests:
>>> i + 1
2
""")
result = testdir.runpytest(p)
result = testdir.runpytest(p, '-p', 'doctest')
result.stdout.fnmatch_lines([
'001 >>> i = 0',
'002 >>> i + 1',

View File

@@ -5,9 +5,9 @@ def test_version(testdir):
assert py.version == py.__version__
result = testdir.runpytest("--version")
assert result.ret == 0
p = py.path.local(py.__file__).dirpath()
#p = py.path.local(py.__file__).dirpath()
assert result.stderr.fnmatch_lines([
'*py.test*%s*imported from*%s*' % (py.version, p)
'*py.test*%s*imported from*' % (py.version, )
])
def test_helpconfig(testdir):