예제 #1
0
 def test_absolute(self):
     """Test if absolute paths are set corectly."""
     fname = "t.vtk"
     f = file_path.FilePath(fname)
     cwd = os.getcwd()
     # Easy case of both in same dir.
     f.set_absolute(join(cwd, "foo", "test", "t.mv2"))
     self.assertEqual(f.abs_pth, join(cwd, "foo", "test", fname))
     # One level lower.
     fname = join(os.pardir, "t.vtk")
     f.set(fname)
     f.set_absolute(join(cwd, "foo", "test", "t.mv2"))
     self.assertEqual(f.abs_pth, abspath(join(cwd, "foo", "test", fname)))
     # One level higher.
     fname = join("test", "t.vtk")
     f.set(fname)
     f.set_absolute(join(cwd, "foo", "t.mv2"))
     self.assertEqual(f.abs_pth, abspath(join(cwd, "foo", fname)))
예제 #2
0
 def test_relative(self):
     """Test if relative paths are set correctly."""
     fname = "t.vtk"
     f = file_path.FilePath(fname)
     cwd = os.getcwd()
     # Trivial case of both in same dir.
     f.set_relative(abspath(join(cwd, "t.mv2")))
     self.assertEqual(f.rel_pth, fname)
     # Move one directory deeper.
     f.set_relative(abspath(join(cwd, "tests", "t.mv2")))
     self.assertEqual(f.rel_pth, join(os.pardir, fname))
     # Move one directory shallower.
     f.set_relative(abspath(join(dirname(cwd), "t.mv2")))
     diff = basename(cwd)
     self.assertEqual(f.rel_pth, join(diff, fname))
     # Test where the path is relative to the root.
     f.set(abspath(join("data", fname)))
     f.set_relative("/tmp/test.mv2")
     if sys.platform.startswith("win"):
         expect = os.pardir + abspath(join("data", fname))[2:]
     else:
         expect = os.pardir + abspath(join("data", fname))
     self.assertEqual(f.rel_pth, expect)
예제 #3
0
 def __init__(self):
     self.f = file_path.FilePath()