Exemple #1
0
 def test_relative_to(self):
     p = local.path("/var/log/messages")
     assert p.relative_to("/var/log/messages") == RelativePath([])
     assert p.relative_to("/var/") == RelativePath(["log", "messages"])
     assert p.relative_to("/") == RelativePath(["var", "log", "messages"])
     assert p.relative_to("/var/tmp") == RelativePath(["..", "log", "messages"])
     assert p.relative_to("/opt") == RelativePath(["..", "var", "log", "messages"])
     assert p.relative_to("/opt/lib") == RelativePath(["..", "..", "var", "log", "messages"])
     for src in [local.path("/var/log/messages"), local.path("/var"), local.path("/opt/lib")]:
         delta = p.relative_to(src)
         assert src + delta == p
Exemple #2
0
 def test_relative_to(self):
     p = local.path("/var/log/messages")
     self.assertEqual(p.relative_to("/var/log/messages"), RelativePath([]))
     self.assertEqual(p.relative_to("/var/"), RelativePath(["log", "messages"]))
     self.assertEqual(p.relative_to("/"), RelativePath(["var", "log", "messages"]))
     self.assertEqual(p.relative_to("/var/tmp"), RelativePath(["..", "log", "messages"]))
     self.assertEqual(p.relative_to("/opt"), RelativePath(["..", "var", "log", "messages"]))
     self.assertEqual(p.relative_to("/opt/lib"), RelativePath(["..", "..", "var", "log", "messages"]))
     for src in [local.path("/var/log/messages"), local.path("/var"), local.path("/opt/lib")]:
         delta = p.relative_to(src)
         self.assertEqual(src + delta, p)