[py-svn] r38174 - in py/trunk/py/execnet: . testing

fijal at codespeak.net fijal at codespeak.net
Thu Feb 8 17:01:52 CET 2007


Author: fijal
Date: Thu Feb  8 17:01:51 2007
New Revision: 38174

Modified:
   py/trunk/py/execnet/rsync.py
   py/trunk/py/execnet/testing/test_rsync.py
Log:
Flag instead of new method and a test.


Modified: py/trunk/py/execnet/rsync.py
==============================================================================
--- py/trunk/py/execnet/rsync.py	(original)
+++ py/trunk/py/execnet/rsync.py	Thu Feb  8 17:01:51 2007
@@ -93,19 +93,16 @@
         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

Modified: py/trunk/py/execnet/testing/test_rsync.py
==============================================================================
--- py/trunk/py/execnet/testing/test_rsync.py	(original)
+++ py/trunk/py/execnet/testing/test_rsync.py	Thu Feb  8 17:01:51 2007
@@ -23,6 +23,7 @@
     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 @@
         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



More information about the pytest-commit mailing list