[py-svn] r60994 - in py/branch/pytestplugin/py/test/plugin: . testing
hpk at codespeak.net
hpk at codespeak.net
Thu Jan 15 14:30:42 CET 2009
Author: hpk
Date: Thu Jan 15 14:30:41 2009
New Revision: 60994
Added:
py/branch/pytestplugin/py/test/plugin/pytest_eventlog.py (contents, props changed)
py/branch/pytestplugin/py/test/plugin/testing/test_eventlog.py (contents, props changed)
Log:
forgot to checkin the eventlog plugin with 60993
Added: py/branch/pytestplugin/py/test/plugin/pytest_eventlog.py
==============================================================================
--- (empty file)
+++ py/branch/pytestplugin/py/test/plugin/pytest_eventlog.py Thu Jan 15 14:30:41 2009
@@ -0,0 +1,37 @@
+"""
+pytest "eventlog" plugin for logging pytest events to a file.
+"""
+plugin_name = "pytest_eventlog"
+plugin_version = "0.1"
+plugin_author = "holger krekel"
+
+import py
+
+def pytest_initplugin(config):
+ config.register_plugin(EventLogPlugin())
+
+class EventLogPlugin:
+ __doc__ = __doc__
+
+ def pytest_addoptions(self, config):
+ config.addoptions("eventlog options",
+ Option('', '--eventlog',
+ action="store", dest="eventlog", default=None,
+ help="write all pytest events to specific file."),
+ )
+
+ def pytest_configure(self, config):
+ eventlog = self.config.option.eventlog
+ if eventlog:
+ self.eventlogfile = py.path.local(eventlog).open("w")
+
+ def pytest_unconfigure(self):
+ if hasattr(self, 'eventlogfile'):
+ self.eventlogfile.close()
+ del self.eventlogfile
+
+ def pytest_event(self, event):
+ if hasattr(self, 'eventlogfile'):
+ f = self.eventlogfile
+ print >>f, event
+ f.flush()
Added: py/branch/pytestplugin/py/test/plugin/testing/test_eventlog.py
==============================================================================
--- (empty file)
+++ py/branch/pytestplugin/py/test/plugin/testing/test_eventlog.py Thu Jan 15 14:30:41 2009
@@ -0,0 +1,18 @@
+import py
+from py.__.test.testing import suptest
+import pytest_eventlog
+
+def test_basic():
+ py.test.skip("implement plugin regirstation and support for generic testing of plugins")
+ py.test.support.plugin_test_generic(pytest_eventlog)
+
+class TestEventlogPlugin(suptest.FileCreation):
+ def test_session_eventlog(self):
+ py.test.skip("requires plugin registration")
+ eventlog = self.tmpdir.join("test_session_eventlog")
+ config = py.test.config._reparse([self.tmpdir,
+ '--eventlog=%s' % eventlog])
+ session = config.initsession()
+ session.bus.notify(event.TestrunStart())
+ s = eventlog.read()
+ assert s.find("TestrunStart") != -1
More information about the pytest-commit
mailing list