From e3dce2c28829034cc24bb89d92eb4d0b8be2ff9f Mon Sep 17 00:00:00 2001 From: fijal Date: Thu, 8 Feb 2007 17:01:51 +0100 Subject: [PATCH] [svn r38174] Flag instead of new method and a test. --HG-- branch : trunk --- py/execnet/rsync.py | 17 +++++++---------- py/execnet/testing/test_rsync.py | 3 +++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/py/execnet/rsync.py b/py/execnet/rsync.py index c79dffc1a..8827ac660 100644 --- a/py/execnet/rsync.py +++ b/py/execnet/rsync.py @@ -93,19 +93,16 @@ class RSync(object): if self._verbose: print '%s <= %s' % (gateway.remoteaddress, modified_rel_path) - def send_if_targets(self): - """ Sends only if there are targets, otherwise returns + def send(self, raises=True): + """ Sends a sourcedir to all added targets. Flag indicates + whether to raise an error or return in case of lack of + targets """ if not self._channels: + if raises: + raise IOError("no targets available, maybe you " + "are trying call send() twice?") return - self.send() - - def send(self): - """ Sends a sourcedir to all added targets. - """ - if not self._channels: - raise IOError("no targets available, maybe you " - "are trying call send() twice?") # normalize a trailing '/' away self._sourcedir = os.path.dirname(os.path.join(self._sourcedir, 'x')) # send directory structure and file timestamps/sizes diff --git a/py/execnet/testing/test_rsync.py b/py/execnet/testing/test_rsync.py index 803685753..3387d690d 100644 --- a/py/execnet/testing/test_rsync.py +++ b/py/execnet/testing/test_rsync.py @@ -23,6 +23,7 @@ class TestRSync(DirSetup): def test_notargets(self): rsync = RSync(self.source) py.test.raises(IOError, "rsync.send()") + assert rsync.send(raises=False) is None def test_dirsync(self): dest = self.dest1 @@ -64,10 +65,12 @@ class TestRSync(DirSetup): rsync.send() assert self.dest1.join('hello').check() py.test.raises(IOError, "rsync.send()") + assert rsync.send(raises=False) is None rsync.add_target(gw, self.dest2) rsync.send() assert self.dest2.join('hello').check() py.test.raises(IOError, "rsync.send()") + assert rsync.send(raises=False) is None def test_rsync_default_reporting(self): source = self.source