fixed examples according to new plugin and setup mechanisms
--HG-- branch : trunk
This commit is contained in:
parent
1b48cbb3c6
commit
b8c3f866b5
|
@ -1,16 +1,10 @@
|
||||||
|
|
||||||
class ConftestPlugin:
|
def pytest_funcarg__setup(request):
|
||||||
def pytest_configure(self, config):
|
return request.cached_setup(
|
||||||
self._setup = None
|
setup=lambda: CostlySetup(),
|
||||||
|
teardown=lambda costlysetup: costlysetup.finalize(),
|
||||||
def pytest_funcarg__setup(self, request):
|
scope="session",
|
||||||
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()
|
|
||||||
|
|
||||||
class CostlySetup:
|
class CostlySetup:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
|
||||||
from myapp import MyApp
|
from myapp import MyApp
|
||||||
|
|
||||||
class ConftestPlugin:
|
def pytest_funcarg__mysetup(request):
|
||||||
def pytest_funcarg__mysetup(self, request):
|
return MySetup()
|
||||||
return MySetup()
|
|
||||||
|
|
||||||
class MySetup:
|
class MySetup:
|
||||||
def myapp(self):
|
def myapp(self):
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import py
|
import py
|
||||||
from myapp import MyApp
|
from myapp import MyApp
|
||||||
|
|
||||||
class ConftestPlugin:
|
def pytest_funcarg__mysetup(request):
|
||||||
def pytest_funcarg__mysetup(self, request):
|
return MySetup(request)
|
||||||
return MySetup(request)
|
|
||||||
|
|
||||||
def pytest_addoption(self, parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption("--ssh", action="store", default=None,
|
parser.addoption("--ssh", action="store", default=None,
|
||||||
help="specify ssh host to run tests with")
|
help="specify ssh host to run tests with")
|
||||||
|
|
||||||
|
|
||||||
class MySetup:
|
class MySetup:
|
||||||
|
|
|
@ -5,10 +5,10 @@ failure_demo = py.magic.autopath().dirpath('failure_demo.py')
|
||||||
pytest_plugins = "pytest_pytester"
|
pytest_plugins = "pytest_pytester"
|
||||||
|
|
||||||
def test_failure_demo_fails_properly(testdir):
|
def test_failure_demo_fails_properly(testdir):
|
||||||
sorter = testdir.inline_run(failure_demo)
|
reprec = testdir.inline_run(failure_demo)
|
||||||
passed, skipped, failed = sorter.countoutcomes()
|
passed, skipped, failed = reprec.countoutcomes()
|
||||||
assert passed == 0
|
assert passed == 0
|
||||||
assert failed == 20, failed
|
assert failed == 20, failed
|
||||||
colreports = sorter.getnamed("collectionreport")
|
colreports = reprec.getnamed("collectionreport")
|
||||||
failed = len([x.failed for x in colreports])
|
failed = len([x.failed for x in colreports])
|
||||||
assert failed == 5
|
assert failed == 5
|
||||||
|
|
Loading…
Reference in New Issue