fixed examples according to new plugin and setup mechanisms

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-05-21 14:36:52 +02:00
parent 1b48cbb3c6
commit b8c3f866b5
4 changed files with 16 additions and 24 deletions

View File

@ -1,16 +1,10 @@
class ConftestPlugin:
def pytest_configure(self, config):
self._setup = None
def pytest_funcarg__setup(self, request):
if self._setup is None:
self._setup = CostlySetup()
return self._setup
def pytest_unconfigure(self, config):
if self._setup is not None:
self._setup.finalize()
def pytest_funcarg__setup(request):
return request.cached_setup(
setup=lambda: CostlySetup(),
teardown=lambda costlysetup: costlysetup.finalize(),
scope="session",
)
class CostlySetup:
def __init__(self):

View File

@ -1,9 +1,8 @@
from myapp import MyApp
class ConftestPlugin:
def pytest_funcarg__mysetup(self, request):
return MySetup()
def pytest_funcarg__mysetup(request):
return MySetup()
class MySetup:
def myapp(self):

View File

@ -1,13 +1,12 @@
import py
from myapp import MyApp
class ConftestPlugin:
def pytest_funcarg__mysetup(self, request):
return MySetup(request)
def pytest_funcarg__mysetup(request):
return MySetup(request)
def pytest_addoption(self, parser):
parser.addoption("--ssh", action="store", default=None,
help="specify ssh host to run tests with")
def pytest_addoption(parser):
parser.addoption("--ssh", action="store", default=None,
help="specify ssh host to run tests with")
class MySetup:

View File

@ -5,10 +5,10 @@ failure_demo = py.magic.autopath().dirpath('failure_demo.py')
pytest_plugins = "pytest_pytester"
def test_failure_demo_fails_properly(testdir):
sorter = testdir.inline_run(failure_demo)
passed, skipped, failed = sorter.countoutcomes()
reprec = testdir.inline_run(failure_demo)
passed, skipped, failed = reprec.countoutcomes()
assert passed == 0
assert failed == 20, failed
colreports = sorter.getnamed("collectionreport")
colreports = reprec.getnamed("collectionreport")
failed = len([x.failed for x in colreports])
assert failed == 5