From 9dc7fbbd37426a8a8d0b7e93f268cf91b213edbd Mon Sep 17 00:00:00 2001 From: fijal Date: Wed, 24 Jan 2007 22:05:33 +0100 Subject: [PATCH] [svn r37300] Make clean complaints about lack of disthosts and call fixoptions if present. --HG-- branch : trunk --- py/test/config.py | 4 +++- py/test/rsession/rsession.py | 16 ++++++++++++++++ py/test/rsession/testing/test_rsession.py | 5 +++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/py/test/config.py b/py/test/config.py index 1359ad1d5..5664e318f 100644 --- a/py/test/config.py +++ b/py/test/config.py @@ -123,7 +123,9 @@ class Config(object): """ return an initialized session object. """ cls = self._getsessionclass() session = cls(self) - #session.fixoptions() + # XXX: all sessions should have one + if hasattr(session, 'fixoptions'): + session.fixoptions() return session def _getsessionclass(self): diff --git a/py/test/rsession/rsession.py b/py/test/rsession/rsession.py index ec2750504..f9e6a88b7 100644 --- a/py/test/rsession/rsession.py +++ b/py/test/rsession/rsession.py @@ -138,6 +138,22 @@ def parse_directories(sshhosts): class RSession(AbstractSession): """ Remote version of session """ + def fixoptions(self): + config = self.config + try: + config.getvalue('disthosts') + except KeyError: + print "You're trying to run RSession without disthosts specified" + print "you need to specify it in your conftest.py (ie. ~/conftest.py)" + print "for example:" + print " disthosts = ['localhost'] * 4 # for 3 processors" + print " - or -" + print " disthosts = ['you@some.remote.com'] # for remote testing" + print " # with your remote ssh account" + print "http://codespeak.net/py/current/doc/test.html#automated-distributed-testing" + print " for more info..." + raise SystemExit + def main(self, reporter=None): """ main loop for running tests. """ args = self.config.args diff --git a/py/test/rsession/testing/test_rsession.py b/py/test/rsession/testing/test_rsession.py index 416a4c14d..c33ed1249 100644 --- a/py/test/rsession/testing/test_rsession.py +++ b/py/test/rsession/testing/test_rsession.py @@ -322,3 +322,8 @@ class TestInithosts(object): assert events[3].host.hostname == 'h2' assert events[3].host.relpath == 'home-h2' +def test_rsession_no_disthost(): + tmpdir = py.test.ensuretemp("rsession_no_disthost") + tmpdir.ensure("conftest.py") + config = py.test.config._reparse([str(tmpdir), '-d']) + py.test.raises(SystemExit, "config.initsession()")