[py-svn] r37009 - in py/branch/config/py/test: . testing
hpk at codespeak.net
hpk at codespeak.net
Fri Jan 19 16:50:36 CET 2007
Author: hpk
Date: Fri Jan 19 16:50:32 2007
New Revision: 37009
Modified:
py/branch/config/py/test/config.py
py/branch/config/py/test/defaultconftest.py
py/branch/config/py/test/testing/test_config.py
Log:
adding a config method to determine the session name
Modified: py/branch/config/py/test/config.py
==============================================================================
--- py/branch/config/py/test/config.py (original)
+++ py/branch/config/py/test/config.py Fri Jan 19 16:50:32 2007
@@ -90,6 +90,19 @@
mod = __import__(importpath, None, None, ['__doc__'])
return getattr(mod, sessionname)
+ def _getsessionname(self):
+ """ return session name as determined from options. """
+ name = 'Session'
+ if self.option.dist:
+ name = 'RSession'
+ else:
+ optnames = 'startserver runbrowser apigen restreport'.split()
+ for opt in optnames:
+ if getattr(self.option, opt, False):
+ name = 'LSession'
+ break
+ return name
+
def _reparse(self, args):
""" this is used from tests that want to re-invoke parse(). """
global config
Modified: py/branch/config/py/test/defaultconftest.py
==============================================================================
--- py/branch/config/py/test/defaultconftest.py (original)
+++ py/branch/config/py/test/defaultconftest.py Fri Jan 19 16:50:32 2007
@@ -78,6 +78,9 @@
Option('', '--tkinter',
action="store_true", dest="tkinter", default=False,
help="use tkinter test session frontend."),
+ Option('', '--dist',
+ action="store_true", dest="dist", default=False,
+ help="use ad-hoc distributed testing (requires conftest settings)"),
Option('', '--looponfailing',
action="store_true", dest="looponfailing", default=False,
help="loop on failing test set."),
Modified: py/branch/config/py/test/testing/test_config.py
==============================================================================
--- py/branch/config/py/test/testing/test_config.py (original)
+++ py/branch/config/py/test/testing/test_config.py Fri Jan 19 16:50:32 2007
@@ -127,3 +127,39 @@
config.merge_repr(repr)
assert config.option.gdest == 11
+class TestSessionAndOptions:
+ def setup_class(cls):
+ cls.tmproot = py.test.ensuretemp(cls.__name__)
+
+ def setup_method(self, method):
+ self.tmpdir = self.tmproot.mkdir(method.__name__)
+
+ def XXXtest_sessionclass_conftest_override(self):
+ self.tmpdir.join("conftest.py").write(py.code.Source("""
+ from py.__.test.session import Session as orig
+ class Session(orig):
+ x = 42
+ """))
+ config = py.test.config._reparse([self.tmpdir])
+ cls = config._getsessionclass()
+ assert cls.x == 42
+ config.option.dist = True
+ config.option.startserver = True
+ cls = config._getsessionclass()
+ assert cls.x == 42
+
+ def test_sessionname_default(self):
+ config = py.test.config._reparse([])
+ assert config._getsessionname() == 'Session'
+
+ def test_sessionname_dist(self):
+ config = py.test.config._reparse(['--dist'])
+ assert config._getsessionname() == 'RSession'
+
+ def test_implied_lsession(self):
+ optnames = 'startserver runbrowser apigen=x rest'.split()
+ for x in optnames:
+ config = py.test.config._reparse(['--%s' % x])
+ assert config._getsessionname() == 'LSession'
+ config = py.test.config._reparse(['--dist', '--%s' % x])
+ assert config._getsessionname() == 'RSession' # XXX is this right?
More information about the pytest-commit
mailing list