allow pdbcls without implying usepdb
This commit is contained in:
parent
dc16fe2bb9
commit
0ac85218d1
|
@ -20,15 +20,15 @@ def pytest_namespace():
|
||||||
return {'set_trace': pytestPDB().set_trace}
|
return {'set_trace': pytestPDB().set_trace}
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
if config.getvalue("usepdb") or config.getvalue("usepdb_cls"):
|
if config.getvalue("usepdb_cls"):
|
||||||
|
modname, classname = config.getvalue("usepdb_cls").split(":")
|
||||||
|
__import__(modname)
|
||||||
|
pdb_cls = getattr(sys.modules[modname], classname)
|
||||||
|
else:
|
||||||
|
pdb_cls = pdb.Pdb
|
||||||
|
|
||||||
|
if config.getvalue("usepdb"):
|
||||||
config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
|
config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
|
||||||
if config.getvalue("usepdb_cls"):
|
|
||||||
modname, classname = config.getvalue("usepdb_cls").split(":")
|
|
||||||
__import__(modname)
|
|
||||||
pdb_cls = getattr(sys.modules[modname], classname)
|
|
||||||
else:
|
|
||||||
pdb_cls = pdb.Pdb
|
|
||||||
pytestPDB._pdb_cls = pdb_cls
|
|
||||||
|
|
||||||
old = (pdb.set_trace, pytestPDB._pluginmanager)
|
old = (pdb.set_trace, pytestPDB._pluginmanager)
|
||||||
def fin():
|
def fin():
|
||||||
|
@ -38,6 +38,7 @@ def pytest_configure(config):
|
||||||
pdb.set_trace = pytest.set_trace
|
pdb.set_trace = pytest.set_trace
|
||||||
pytestPDB._pluginmanager = config.pluginmanager
|
pytestPDB._pluginmanager = config.pluginmanager
|
||||||
pytestPDB._config = config
|
pytestPDB._config = config
|
||||||
|
pytestPDB._pdb_cls = pdb_cls
|
||||||
config._cleanup.append(fin)
|
config._cleanup.append(fin)
|
||||||
|
|
||||||
class pytestPDB:
|
class pytestPDB:
|
||||||
|
|
Loading…
Reference in New Issue