clone: add doctest for default destination
authorYuya Nishihara <yuya@tcha.org>
Sat, 22 Mar 2014 00:46:08 +0900
changeset 20799 069bf1b821c8
parent 20798 170d6d591a7d
child 20800 8253e55930a3
clone: add doctest for default destination
mercurial/hg.py
tests/test-doctest.py
--- a/mercurial/hg.py	Thu Mar 20 09:55:44 2014 -0700
+++ b/mercurial/hg.py	Sat Mar 22 00:46:08 2014 +0900
@@ -123,7 +123,21 @@
     return _peerorrepo(rui, path, create).peer()
 
 def defaultdest(source):
-    '''return default destination of clone if none is given'''
+    '''return default destination of clone if none is given
+
+    >>> defaultdest('foo')
+    'foo'
+    >>> defaultdest('/foo/bar')
+    'bar'
+    >>> defaultdest('/')
+    ''
+    >>> defaultdest('')
+    '.'
+    >>> defaultdest('http://example.org/')
+    '.'
+    >>> defaultdest('http://example.org/foo/')
+    'foo'
+    '''
     return os.path.basename(os.path.normpath(util.url(source).path or ''))
 
 def share(ui, source, dest=None, update=True):
--- a/tests/test-doctest.py	Thu Mar 20 09:55:44 2014 -0700
+++ b/tests/test-doctest.py	Sat Mar 22 00:46:08 2014 +0900
@@ -15,6 +15,7 @@
 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
 testmod('mercurial.dispatch')
 testmod('mercurial.encoding')
+testmod('mercurial.hg')
 testmod('mercurial.hgweb.hgwebdir_mod')
 testmod('mercurial.match')
 testmod('mercurial.minirst')