[py-svn] r51472 - in py/branch/guido-svn-auth/py/path/svn: . testing

hpk at codespeak.net hpk at codespeak.net
Thu Feb 14 08:51:48 CET 2008


Author: hpk
Date: Thu Feb 14 08:51:47 2008
New Revision: 51472

Modified:
   py/branch/guido-svn-auth/py/path/svn/svncommon.py
   py/branch/guido-svn-auth/py/path/svn/testing/test_auth.py
   py/branch/guido-svn-auth/py/path/svn/wccommand.py
Log:
introduce explicit makecmdlineoptions instead of using 
str() for producing auth cmdline options 


Modified: py/branch/guido-svn-auth/py/path/svn/svncommon.py
==============================================================================
--- py/branch/guido-svn-auth/py/path/svn/svncommon.py	(original)
+++ py/branch/guido-svn-auth/py/path/svn/svncommon.py	Thu Feb 14 08:51:47 2008
@@ -338,10 +338,13 @@
         self.password = password
         self.auth_cache = auth_cache
 
-    def __str__(self):
+    def makecmdoptions(self): 
         uname = self.username.replace('"', '\\"')
         passwd = self.password.replace('"', '\\"')
         ret = '--username="%s" --password="%s"' % (uname, passwd)
         if not self.auth_cache:
             ret += ' --no-auth-cache'
         return ret
+
+    def __str__(self):
+        return "<SvnAuth username=%s ...>" %(self.username,)

Modified: py/branch/guido-svn-auth/py/path/svn/testing/test_auth.py
==============================================================================
--- py/branch/guido-svn-auth/py/path/svn/testing/test_auth.py	(original)
+++ py/branch/guido-svn-auth/py/path/svn/testing/test_auth.py	Thu Feb 14 08:51:47 2008
@@ -2,22 +2,23 @@
 from py.path import SvnAuth
 
 class TestSvnAuth(object):
-    def test_uname_pw(self):
+    def test_basic(self):
         auth = py.path.SvnAuth('foo', 'bar')
         assert auth.username == 'foo'
         assert auth.password == 'bar'
+        assert str(auth)
 
-    def test_uname_pw_str(self):
+    def test_makecmdoptions_uname_pw_makestr(self):
         auth = py.path.SvnAuth('foo', 'bar')
-        assert str(auth) == '--username="foo" --password="bar"'
+        assert auth.makecmdoptions() == '--username="foo" --password="bar"'
 
-    def test_quote_escape(self):
+    def test_makecmdoptions_quote_escape(self):
         auth = py.path.SvnAuth('fo"o', '"ba\'r"')
-        assert str(auth) == '--username="fo\\"o" --password="\\"ba\'r\\""'
+        assert auth.makecmdoptions() == '--username="fo\\"o" --password="\\"ba\'r\\""'
 
-    def test_no_auth_cache(self):
+    def test_makecmdoptions_no_auth_cache(self):
         auth = py.path.SvnAuth('foo', 'bar', auth_cache=False)
-        assert str(auth) == '--username="foo" --password="bar" --no-auth-cache'
+        assert auth.makecmdoptions() == '--username="foo" --password="bar" --no-auth-cache'
 
 class svnwc_no_svn(py.path.svnwc):
     def __init__(self, *args, **kwargs):

Modified: py/branch/guido-svn-auth/py/path/svn/wccommand.py
==============================================================================
--- py/branch/guido-svn-auth/py/path/svn/wccommand.py	(original)
+++ py/branch/guido-svn-auth/py/path/svn/wccommand.py	Thu Feb 14 08:51:47 2008
@@ -76,7 +76,7 @@
             auth = self._auth 
         if auth is None:
             return ''
-        return str(auth) 
+        return auth.makecmdoptions()
 
     def _authsvn(self, cmd, args=None, auth=None):
         args = args and list(args) or [] 


More information about the py-svn mailing list