Пример #1
0
 def testConstructor(self):
     vfs = OSFilePath
     self.assertTrue(
         issubclass(vfs, VirtualFilePath),
         "OSFilePath subclass of VirtualFilePath abstract class")
     self.assertTrue(vfs.curdir == ".", "Current directory component")
     self.assertTrue(vfs.pardir == "..", "Parent directory component")
     path = vfs()
     self.assertTrue(isinstance(path, VirtualFilePath),
                     "VirtualFilePath abstract class")
     self.assertTrue(path.IsEmpty(), "Empty path creation")
     self.assertTrue(path.IsSingleComponent,
                     "Empty path is a single component")
     self.assertFalse(path.IsDirLike(), "Empty path is not diretory like")
     self.assertFalse(path.IsRoot(), "Empty path is not the root")
     self.assertFalse(path, "Non-zero test of empty path")
     path = vfs('hello')
     self.assertFalse(path.IsEmpty(), "Single path component")
     self.assertTrue(path.IsSingleComponent,
                     "Empty path is a single component")
     self.assertFalse(path.IsDirLike(), "Empty path is not diretory like")
     self.assertFalse(path.IsRoot(), "Empty path is not the root")
     self.assertTrue(str(path) == "hello", "convert to str")
     self.assertTrue(unicode(path) == u"hello", "convert to unicode str")
     self.assertTrue(path, "Non-zero test of non-empty path")
     path = vfs(u'Caf\xe9')
     self.assertTrue(
         str(path) == u'Caf\xe9'.encode(sys.getfilesystemencoding()),
         "convert to str")
     self.assertTrue(unicode(path) == u'Caf\xe9', "convert to unicode str")
Пример #2
0
 def testConstructor(self):
     vfs = OSFilePath
     self.assertTrue(issubclass(vfs, VirtualFilePath),
                     "OSFilePath subclass of VirtualFilePath abstract class")
     self.assertTrue(vfs.curdir == ".", "Current directory component")
     self.assertTrue(vfs.pardir == "..", "Parent directory component")
     path = vfs()
     self.assertTrue(
         isinstance(path, VirtualFilePath), "VirtualFilePath abstract class")
     self.assertTrue(path.IsEmpty(), "Empty path creation")
     self.assertTrue(
         path.IsSingleComponent, "Empty path is a single component")
     self.assertFalse(path.IsDirLike(), "Empty path is not diretory like")
     self.assertFalse(path.IsRoot(), "Empty path is not the root")
     self.assertFalse(path, "Non-zero test of empty path")
     path = vfs('hello')
     self.assertFalse(path.IsEmpty(), "Single path component")
     self.assertTrue(
         path.IsSingleComponent, "Empty path is a single component")
     self.assertFalse(path.IsDirLike(), "Empty path is not diretory like")
     self.assertFalse(path.IsRoot(), "Empty path is not the root")
     self.assertTrue(str(path) == "hello", "convert to str")
     self.assertTrue(unicode(path) == u"hello", "convert to unicode str")
     self.assertTrue(path, "Non-zero test of non-empty path")
     path = vfs(u'Caf\xe9')
     self.assertTrue(str(path) == u'Caf\xe9'.encode(
         sys.getfilesystemencoding()), "convert to str")
     self.assertTrue(unicode(path) == u'Caf\xe9', "convert to unicode str")
Пример #3
0
	def testJoin(self):
		"""Join one or more path components intelligently. If any component is
		an absolute path, all previous components (on Windows, including the
		previous drive letter, if there was one) are thrown away, and joining
		continues. The return value is the concatenation of path1, and
		optionally path2, etc., with exactly one directory separator (os.sep)
		inserted between components, unless path2 is empty. Note that on
		Windows, since there is a current directory for each drive,
		os.path.join("c:", "foo") represents a path relative to the current
		directory on drive C: (c:foo), not c:\\foo."""
		vfs=OSFilePath
		path=vfs.getcwd()
		path1=vfs.join(path,vfs('bye'))
		path2=vfs.join(path,vfs('hello'),path,vfs('bye'))
		self.assertTrue(path1==path2,"If any component is an absolute path, all previous components are thrown away")
		path1=vfs.join(path,'bye')
		path2=vfs.join(path,'hello',path,'bye')
		self.assertTrue(path1==path2,"Re-test with strings in join")
Пример #4
0
	def testAbs(self):
		vfs=OSFilePath
		path=vfs.getcwd()
		self.assertTrue(path.isabs(),"CWD not absolute")
		self.assertTrue(vfs.isabs(path),"CWD not absolute, alternative")
		self.assertTrue(path.abspath()==path,"Absolute path from cwd")		
		path=vfs('hello')
		self.assertFalse(path.isabs(),"path component not absolute")
		self.assertFalse(vfs.isabs(path),"path component not absolute, alternative")
Пример #5
0
 def testAbs(self):
     vfs = OSFilePath
     path = vfs.getcwd()
     self.assertTrue(path.isabs(), "CWD not absolute")
     self.assertTrue(vfs.isabs(path), "CWD not absolute, alternative")
     self.assertTrue(path.abspath() == path, "Absolute path from cwd")
     path = vfs('hello')
     self.assertFalse(path.isabs(), "path component not absolute")
     self.assertFalse(vfs.isabs(path),
                      "path component not absolute, alternative")
Пример #6
0
 def testJoin(self):
     """Join one or more path components intelligently. If any component is
     an absolute path, all previous components (on Windows, including the
     previous drive letter, if there was one) are thrown away, and joining
     continues. The return value is the concatenation of path1, and
     optionally path2, etc., with exactly one directory separator (os.sep)
     inserted between components, unless path2 is empty. Note that on
     Windows, since there is a current directory for each drive,
     os.path.join("c:", "foo") represents a path relative to the current
     directory on drive C: (c:foo), not c:\\foo."""
     vfs = OSFilePath
     path = vfs.getcwd()
     path1 = vfs.join(path, vfs('bye'))
     path2 = vfs.join(path, vfs('hello'), path, vfs('bye'))
     self.assertTrue(
         path1 == path2,
         "If any component is an absolute path, all previous components are thrown away"
     )
     path1 = vfs.join(path, 'bye')
     path2 = vfs.join(path, 'hello', path, 'bye')
     self.assertTrue(path1 == path2, "Re-test with strings in join")