예제 #1
0
 def test_filepath (self):
   test_order = self.test_cases[0][1:]
   for test_case in self.test_cases[1:]:
     path, rest = test_case[0], test_case[1:]
     fp = fs.filepath (path)
     for n, test_item in enumerate (test_order):
       result = rest[n]
       if result.startswith ("x_"):
         exc = getattr (fs, result)
         try:
           getattr (fp, test_item)
         except exc:
           pass
         else:
           raise RuntimeError (
             "Path: %s; Part: %s; expected exception %s" % (path, test_item, result)
           )
       else:
         if result == "_":
           result = ""
         self.assertEquals (
           result,
           getattr (fp, test_item),
           "Path: %s; Part %s; expected: %s; result: %s" % (path, test_item, result, getattr (fp, test_item))
         )
예제 #2
0
 def test_is_relative (self):
   for path, result in [
     ("c:/", False),
     ("c:/temp/abc.txt", False),
     ("temp", True),
     ("c:temp", True),
     (r"\\server\share", False),
     (r"\\server\share\d1", False)
   ]:
     self.assertEquals (fs.filepath (path).is_relative (), result)
예제 #3
0
 def test_filepath(self):
     test_order = self.test_cases[0][1:]
     for test_case in self.test_cases[1:]:
         path, rest = test_case[0], test_case[1:]
         fp = fs.filepath(path)
         for n, test_item in enumerate(test_order):
             result = rest[n]
             if result.startswith("x_"):
                 exc = getattr(fs, result)
                 try:
                     getattr(fp, test_item)
                 except exc:
                     pass
                 else:
                     raise RuntimeError(
                         "Path: %s; Part: %s; expected exception %s" %
                         (path, test_item, result))
             else:
                 if result == "_":
                     result = ""
                 self.assertEquals(
                     result, getattr(fp, test_item),
                     "Path: %s; Part %s; expected: %s; result: %s" %
                     (path, test_item, result, getattr(fp, test_item)))
예제 #4
0
 def test_dump_absolute(self):
     with utils.fake_stdout():
         fs.filepath(__file__).dump()
예제 #5
0
 def test_radd (self):
   for l in self.left:
     for r in self.right:
       self.assertEquals (l + fs.filepath (r), os.path.join (l, r))
예제 #6
0
 def test_changed_filename(self):
     self.assertEquals(
         fs.filepath("c:\\temp\\abc.txt").changed(filename="def.ghi"),
         "c:\\temp\\def.ghi")
예제 #7
0
 def test_changed_infix(self):
     self.assertEquals(
         fs.filepath("c:\\temp\\abc.txt").changed(infix=".infix"),
         "c:\\temp\\abc.infix.txt")
예제 #8
0
 def test_changed_filename_and_ext(self):
     with self.assertRaises(fs.x_fs):
         fs.filepath(".").changed(filename="test.txt", ext=".txt")
예제 #9
0
 def test_changed_root(self):
     self.assertEquals(
         fs.filepath("c:\\temp\\abc.txt").changed(root="d:\\"),
         "d:\\temp\\abc.txt")
예제 #10
0
 def test_add(self):
     for l in self.left:
         for r in self.right:
             self.assertEquals(fs.filepath(l) + r, os.path.join(l, r))
예제 #11
0
 def test_changed_filename_and_ext (self):
   with self.assertRaises (fs.x_fs):
     fs.filepath (".").changed (filename="test.txt", ext=".txt")
예제 #12
0
 def test_changed_filename (self):
   self.assertEquals (fs.filepath ("c:\\temp\\abc.txt").changed (filename="def.ghi"), "c:\\temp\\def.ghi")
예제 #13
0
 def test_changed_base (self):
   self.assertEquals (fs.filepath ("c:\\temp\\abc.txt").changed (base="def"), "c:\\temp\\def.txt")
예제 #14
0
 def test_changed_dirname (self):
   self.assertEquals (fs.filepath ("c:\\temp\\abc.txt").changed (dirname="temp2"), "c:\\temp2\\abc.txt")
예제 #15
0
 def test_changed_root (self):
   self.assertEquals (fs.filepath ("c:\\temp\\abc.txt").changed (root="d:\\"), "d:\\temp\\abc.txt")
예제 #16
0
 def test_changed_filename_and_infix (self):
   with self.assertRaises (fs.x_fs):
     fs.filepath (".").changed (filename="test.txt", infix="-test-")
예제 #17
0
def test_dump_relative():
    fs.filepath("@@").dump()
예제 #18
0
 def test_is_relative(self):
     for path, result in [("c:/", False), ("c:/temp/abc.txt", False),
                          ("temp", True), ("c:temp", True),
                          (r"\\server\share", False),
                          (r"\\server\share\d1", False)]:
         self.assertEquals(fs.filepath(path).is_relative(), result)
예제 #19
0
 def test_changed_infix (self):
   self.assertEquals (fs.filepath ("c:\\temp\\abc.txt").changed (infix=".infix"), "c:\\temp\\abc.infix.txt")
예제 #20
0
 def test_absolute (self):
   for path in ["c:/temp", "temp", "c:temp", r"\\server\share\d1"]:
     self.assertEquals (fs.filepath (path).absolute ().lower (), os.path.abspath (path).lower ())
예제 #21
0
 def test_radd(self):
     for l in self.left:
         for r in self.right:
             self.assertEquals(l + fs.filepath(r), os.path.join(l, r))
예제 #22
0
 def test_changed_ext (self):
   self.assertEquals (fs.filepath ("c:\\temp\\abc.txt").changed (ext=".ext"), "c:\\temp\\abc.ext")
예제 #23
0
 def test_absolute(self):
     for path in ["c:/temp", "temp", "c:temp", r"\\server\share\d1"]:
         self.assertEquals(
             fs.filepath(path).absolute().lower(),
             os.path.abspath(path).lower())
예제 #24
0
 def test_dump_absolute (self):
   with utils.fake_stdout ():
     fs.filepath (__file__).dump ()
예제 #25
0
 def test_changed_filename_and_infix(self):
     with self.assertRaises(fs.x_fs):
         fs.filepath(".").changed(filename="test.txt", infix="-test-")
예제 #26
0
 def test_dump_relative (self):
   with utils.fake_stdout ():
     fs.filepath ("@@").dump ()
예제 #27
0
 def test_changed_dirname(self):
     self.assertEquals(
         fs.filepath("c:\\temp\\abc.txt").changed(dirname="temp2"),
         "c:\\temp2\\abc.txt")
예제 #28
0
def test_dump_relative():
    fs.filepath("@@").dump()
예제 #29
0
 def test_changed_base(self):
     self.assertEquals(
         fs.filepath("c:\\temp\\abc.txt").changed(base="def"),
         "c:\\temp\\def.txt")
예제 #30
0
def test_dump_absolute():
    fs.filepath(__file__).dump()
예제 #31
0
 def test_changed_ext(self):
     self.assertEquals(
         fs.filepath("c:\\temp\\abc.txt").changed(ext=".ext"),
         "c:\\temp\\abc.ext")
예제 #32
0
def test_dump_absolute():
    fs.filepath(__file__).dump()
예제 #33
0
 def test_dump_relative(self):
     with utils.fake_stdout():
         fs.filepath("@@").dump()
예제 #34
0
 def test_add (self):
   for l in self.left:
     for r in self.right:
       self.assertEquals (fs.filepath (l) + r, os.path.join (l, r))