[py-svn] r61753 - in py/branch/pytestplugin/py: doc test test/testing
hpk at codespeak.net
hpk at codespeak.net
Wed Feb 11 20:22:54 CET 2009
Author: hpk
Date: Wed Feb 11 20:22:53 2009
New Revision: 61753
Modified:
py/branch/pytestplugin/py/doc/impl-test.txt
py/branch/pytestplugin/py/test/pmanage.py
py/branch/pytestplugin/py/test/testing/test_pmanage.py
Log:
consider PYTEST_PLUGINS environment setting
Modified: py/branch/pytestplugin/py/doc/impl-test.txt
==============================================================================
--- py/branch/pytestplugin/py/doc/impl-test.txt (original)
+++ py/branch/pytestplugin/py/doc/impl-test.txt Wed Feb 11 20:22:53 2009
@@ -279,9 +279,11 @@
specifying plugins for directories or test modules
---------------------------------------------------------
-py.test loads plugins at tool startup and when first
-importing a test module. It looks at the ``pytest_plugins``
-variable in the conftest or the test module.
+py.test loads and configures plugins at tool startup and whenever
+it encounters new confest or test modules which
+contain a ``pytest_plugins`` definition. At tool
+startup the ``PYTEST_PLUGINS`` environment variable
+is considered as well.
Example
++++++++++
Modified: py/branch/pytestplugin/py/test/pmanage.py
==============================================================================
--- py/branch/pytestplugin/py/test/pmanage.py (original)
+++ py/branch/pytestplugin/py/test/pmanage.py Wed Feb 11 20:22:53 2009
@@ -65,6 +65,14 @@
# API for interacting with registered and instantiated plugin objects
#
def add_cmdlineoptions(self, config):
+ #for mod in self.config._conftest.getconftestmodules(None):
+ # self.consider_module(mod)
+ envspec = py.std.os.environ.get("PYTEST_PLUGINS", None)
+ if envspec:
+ for spec in map(str.strip, envspec.split(",")):
+ if spec:
+ self.import_plugin(spec)
+
# XXX think about sorting/grouping of options from user-perspective
opts = []
for name, options in self.listattr("pytest_cmdlineoptions"):
Modified: py/branch/pytestplugin/py/test/testing/test_pmanage.py
==============================================================================
--- py/branch/pytestplugin/py/test/testing/test_pmanage.py (original)
+++ py/branch/pytestplugin/py/test/testing/test_pmanage.py Wed Feb 11 20:22:53 2009
@@ -1,4 +1,4 @@
-import sys
+import os, sys
import py
from py.__.test.pmanage import PluginManager
from py.__.test.event import NOP
@@ -187,3 +187,15 @@
assert opt
assert opt.default == 242
+ def test_addcmdlineoptions_considers_ENV(self):
+ pm = PluginManager()
+ SPEC = "PYTEST_PLUGINS"
+ old = os.environ.get(SPEC, None)
+ try:
+ os.environ[SPEC] = "test_addcmdlineoptions_considers_ENV"
+ py.test.raises(ImportError, "pm.add_cmdlineoptions(pytestConfig())")
+ finally:
+ if old is None:
+ del os.environ[SPEC]
+ else:
+ os.environ[SPEC] = old
More information about the pytest-commit
mailing list