Files
pytest2/testing/pytest/plugin/conftest.py
holger krekel 5791c06bf2 rewrote the initpkg mechanism and moved py lib implementation files to
_py/...  with py/__init__.py containing pointers into them

The new apipkg is only around 70 lines of code and allows
us to get rid of the infamous "py.__." by regular non-magical
"_py." imports. It is also available as a separately installable
package, see http://bitbucket.org/hpk42/apipkg

--HG--
branch : trunk
2009-10-03 01:47:39 +02:00

37 lines
1.3 KiB
Python

import py
pytest_plugins = "pytester"
plugindir = py.path.local(py._py.__file__).dirpath('test', 'plugin')
from _py.test.defaultconftest import pytest_plugins as default_plugins
def pytest_collect_file(path, parent):
if path.basename.startswith("pytest_") and path.ext == ".py":
mod = parent.Module(path, parent=parent)
return mod
# for plugin test we try to automatically make sure that
# the according plugin is loaded
def pytest_funcarg__testdir(request):
testdir = request.getfuncargvalue("testdir")
#for obj in (request.cls, request.module):
# if hasattr(obj, 'testplugin'):
# testdir.plugins.append(obj.testplugin)
# break
#else:
modname = request.module.__name__.split(".")[-1]
if modname.startswith("test_pytest_"):
modname = modname[5:]
if plugindir.join("%s.py" % modname).check():
if modname[7:] not in default_plugins:
testdir.plugins.append(vars(request.module))
testdir.plugins.append(modname)
#elif modname.startswith("test_pytest"):
# pname = modname[5:]
# assert pname not in testdir.plugins
# testdir.plugins.append(pname)
# #testdir.plugins.append(vars(request.module))
else:
pass # raise ValueError("need better support code")
return testdir