示例#1
0
 def testStoresFragment(self):
     """WalkerBase stores the fragment portion of a supporting URL."""
     WalkerBase.FRAGMENTS = True
     try:
         w = WalkerBase("http://localhost/#foo")
         self.assertEqual(w.fragment, "foo")
     finally:
         WalkerBase.FRAGMENTS = False
示例#2
0
 def testNoUsername(self):
     """WalkerBase stores None when there is no username."""
     w = WalkerBase("ftp://localhost/")
     self.assertEqual(w.user, None)
示例#3
0
 def testUnescapesHost(self):
     """WalkerBase unescapes the host portion."""
     w = WalkerBase("ftp://local%40host/")
     self.assertEqual(w.host, "local@host")
示例#4
0
 def testNoScheme(self):
     """WalkerBase works when given a URL with no scheme."""
     w = WalkerBase("/")
     self.assertEqual(w.host, "")
示例#5
0
 def testSetsHost(self):
     """WalkerBase sets the host property."""
     w = WalkerBase("ftp://localhost/")
     self.assertEqual(w.host, "localhost")
示例#6
0
 def testSetsScheme(self):
     """WalkerBase sets the scheme property."""
     w = WalkerBase("ftp://localhost/")
     self.assertEqual(w.scheme, "ftp")
示例#7
0
 def testUnescapesPassword(self):
     """WalkerBase unescapes the password portion."""
     w = WalkerBase("ftp://*****:*****@localhost/")
     self.assertEqual(w.user, "scott")
     self.assertEqual(w.passwd, "wibble wobble")
     self.assertEqual(w.host, "localhost")
示例#8
0
 def testNoPassword(self):
     """WalkerBase stores None when there is no password."""
     w = WalkerBase("ftp://scott@localhost/")
     self.assertEqual(w.passwd, None)
示例#9
0
 def testCreatesDefaultLogger(self):
     """WalkerBase creates a default logger."""
     w = WalkerBase("/")
     self.assertTrue(isinstance(w.log, logging.Logger))
示例#10
0
 def testUnescapesPath(self):
     """WalkerBase leaves the path escaped."""
     w = WalkerBase("ftp://localhost/some%20thing/")
     self.assertEqual(w.path, "/some%20thing/")
示例#11
0
 def testStoresQuery(self):
     """WalkerBase stores the query portion of a supporting URL."""
     w = WalkerBase("http://localhost/?foo")
     self.assertEqual(w.query, "foo")
示例#12
0
 def testAddsSlashToPath(self):
     """WalkerBase adds a trailing slash to path if ommitted."""
     w = WalkerBase("ftp://localhost/path/to/something")
     self.assertEqual(w.path, "/path/to/something/")
示例#13
0
 def testPathInUrl(self):
     """WalkerBase stores the path portion of a complete URL."""
     w = WalkerBase("ftp://localhost/path/to/something/")
     self.assertEqual(w.path, "/path/to/something/")
示例#14
0
 def testPathOnly(self):
     """WalkerBase stores the path if that's all there is."""
     w = WalkerBase("/path/to/something/")
     self.assertEqual(w.path, "/path/to/something/")
示例#15
0
 def testUsername(self):
     """WalkerBase splits out the username from the host portion."""
     w = WalkerBase("ftp://scott@localhost/")
     self.assertEqual(w.user, "scott")
     self.assertEqual(w.host, "localhost")
示例#16
0
 def testCreatesChildLogger(self):
     """WalkerBase creates a child logger if given a parent."""
     parent = logging.getLogger("foo")
     w = WalkerBase("/", log_parent=parent)
     self.assertEqual(w.log.parent, parent)
示例#17
0
 def testUnescapesUsername(self):
     """WalkerBase unescapes the username portion."""
     w = WalkerBase("ftp://scott%3awibble@localhost/")
     self.assertEqual(w.user, "scott:wibble")
     self.assertEqual(w.host, "localhost")
示例#18
0
 def testSetsBase(self):
     """WalkerBase sets the base property."""
     w = WalkerBase("ftp://localhost/")
     self.assertEqual(w.base, "ftp://localhost/")
示例#19
0
 def testPassword(self):
     """WalkerBase splits out the password from the username."""
     w = WalkerBase("ftp://*****:*****@localhost/")
     self.assertEqual(w.user, "scott")
     self.assertEqual(w.passwd, "wibble")
     self.assertEqual(w.host, "localhost")
 def testCreatesDefaultLogger(self):
     """WalkerBase creates a default logger."""
     from logging import Logger
     w = WalkerBase("/")
     self.failUnless(isinstance(w.log, Logger))