Fix PEP-8.
This commit is contained in:
parent
b650c3c118
commit
6438895a23
|
@ -1,12 +1,14 @@
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
group = parser.getgroup("debugconfig")
|
group = parser.getgroup("debugconfig")
|
||||||
group.addoption('--setuponly', '--setup-only', action="store_true",
|
group.addoption('--setuponly', '--setup-only', action="store_true",
|
||||||
help="only setup fixtures, don't execute the tests.")
|
help="only setup fixtures, don't execute the tests.")
|
||||||
group.addoption('--setupshow', '--setup-show', action="store_true",
|
group.addoption('--setupshow', '--setup-show', action="store_true",
|
||||||
help="show setup fixtures while executing the tests.")
|
help="show setup fixtures while executing the tests.")
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(hookwrapper=True)
|
@pytest.hookimpl(hookwrapper=True)
|
||||||
def pytest_fixture_setup(fixturedef, request):
|
def pytest_fixture_setup(fixturedef, request):
|
||||||
|
@ -20,11 +22,13 @@ def pytest_fixture_setup(fixturedef, request):
|
||||||
if callable(fixturedef.ids):
|
if callable(fixturedef.ids):
|
||||||
fixturedef.cached_param = fixturedef.ids(request.param)
|
fixturedef.cached_param = fixturedef.ids(request.param)
|
||||||
else:
|
else:
|
||||||
fixturedef.cached_param = fixturedef.ids[request.param_index]
|
fixturedef.cached_param = fixturedef.ids[
|
||||||
|
request.param_index]
|
||||||
else:
|
else:
|
||||||
fixturedef.cached_param = request.param
|
fixturedef.cached_param = request.param
|
||||||
_show_fixture_action(fixturedef, 'SETUP')
|
_show_fixture_action(fixturedef, 'SETUP')
|
||||||
|
|
||||||
|
|
||||||
def pytest_fixture_post_finalizer(fixturedef):
|
def pytest_fixture_post_finalizer(fixturedef):
|
||||||
if hasattr(fixturedef, "cached_result"):
|
if hasattr(fixturedef, "cached_result"):
|
||||||
config = fixturedef._fixturemanager.config
|
config = fixturedef._fixturemanager.config
|
||||||
|
@ -33,6 +37,7 @@ def pytest_fixture_post_finalizer(fixturedef):
|
||||||
if hasattr(fixturedef, "cached_param"):
|
if hasattr(fixturedef, "cached_param"):
|
||||||
del fixturedef.cached_param
|
del fixturedef.cached_param
|
||||||
|
|
||||||
|
|
||||||
def _show_fixture_action(fixturedef, msg):
|
def _show_fixture_action(fixturedef, msg):
|
||||||
config = fixturedef._fixturemanager.config
|
config = fixturedef._fixturemanager.config
|
||||||
capman = config.pluginmanager.getplugin('capturemanager')
|
capman = config.pluginmanager.getplugin('capturemanager')
|
||||||
|
@ -60,6 +65,7 @@ def _show_fixture_action(fixturedef, msg):
|
||||||
sys.stdout.write(out)
|
sys.stdout.write(out)
|
||||||
sys.stderr.write(err)
|
sys.stderr.write(err)
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(tryfirst=True)
|
@pytest.hookimpl(tryfirst=True)
|
||||||
def pytest_cmdline_main(config):
|
def pytest_cmdline_main(config):
|
||||||
if config.option.setuponly:
|
if config.option.setuponly:
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
group = parser.getgroup("debugconfig")
|
group = parser.getgroup("debugconfig")
|
||||||
group.addoption('--setupplan', '--setup-plan', action="store_true",
|
group.addoption('--setupplan', '--setup-plan', action="store_true",
|
||||||
help="show what fixtures and tests would be executed but don't"
|
help="show what fixtures and tests would be executed but "
|
||||||
" execute anything.")
|
"don't execute anything.")
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(tryfirst=True)
|
@pytest.hookimpl(tryfirst=True)
|
||||||
def pytest_fixture_setup(fixturedef, request):
|
def pytest_fixture_setup(fixturedef, request):
|
||||||
|
@ -13,6 +15,7 @@ def pytest_fixture_setup(fixturedef, request):
|
||||||
fixturedef.cached_result = (None, None, None)
|
fixturedef.cached_result = (None, None, None)
|
||||||
return fixturedef.cached_result
|
return fixturedef.cached_result
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(tryfirst=True)
|
@pytest.hookimpl(tryfirst=True)
|
||||||
def pytest_cmdline_main(config):
|
def pytest_cmdline_main(config):
|
||||||
if config.option.setupplan:
|
if config.option.setupplan:
|
||||||
|
|
Loading…
Reference in New Issue