[svn r62211] merge 60797:HEAD of pytestplugin branch:

this merge contains:

* a new plugin architecture
* a pluginized pytest core
* many pytest related refactorings
* refactorings/streamlining of pytest's own tests

--HG--
branch : trunk
This commit is contained in:
hpk
2009-02-27 11:18:27 +01:00
parent 1c85d7fe9a
commit c17a09adaf
117 changed files with 6079 additions and 4370 deletions

View File

@@ -0,0 +1,45 @@
"""
example:
pytest_plugins = "pytest_tmpdir"
def test_plugin(tmpdir):
tmpdir.join("hello").write("hello")
"""
import py
class TmpdirPlugin:
""" provide temporary directories to test functions and methods.
"""
def pytest_configure(self, config):
# XXX make ensuretemp live on config
self.basetmp = py.test.ensuretemp("tmpdir")
def pytest_pyfuncarg_tmpdir(self, pyfuncitem):
name = pyfuncitem.name
for i in range(10000):
try:
tmpdir = self.basetmp.mkdir(name + (i and str(i) or ''))
except py.error.EEXIST:
continue
break
return tmpdir
# ===============================================================================
#
# plugin tests
#
# ===============================================================================
#
def test_generic(plugintester):
plugintester.apicheck(TmpdirPlugin)
def test_pyfuncarg(testdir):
item = testdir.getitem("def test_func(tmpdir): pass")
plugin = TmpdirPlugin()
plugin.pytest_configure(item._config)
p = plugin.pytest_pyfuncarg_tmpdir(item)
assert p.check()
assert p.basename.endswith("test_func")