Exemple #1
0
 def test_heritage(self):
     self.assertEqual(
         list(Path("a", "b", "c", "d").heritage()),
         [
             Path("a"),
             Path("a", "b"),
             Path("a", "b", "c"),
             Path("a", "b", "c", "d"),
         ],
     )
Exemple #2
0
 def test_from_string_repeated_separator(self):
     self.assertEqual(
         Path.from_string(
             (os.sep * 3 + "a" + os.sep * 2 + "b" + os.sep + "c"), ),
         Path("", "", "a", "", "b", "c"),
     )
Exemple #3
0
 def test_from_string_multiple_trailing_slashes(self):
     self.assertEqual(
         Path.from_string(os.sep + os.sep.join("ab") + os.sep + os.sep),
         Path("a", "b"),
     )
Exemple #4
0
 def test_from_string(self):
     self.assertEqual(
         Path.from_string(os.sep + os.sep.join("abc")),
         Path("a", "b", "c"),
     )
Exemple #5
0
 def test_relative_to(self):
     self.assertEqual(
         Path("a", "b", "c").relative_to(Path("d", "e")),
         Path("a", "b", "c"),
     )
Exemple #6
0
 def test_parent(self):
     self.assertEqual(Path("a", "b").parent(), Path("a"))
Exemple #7
0
 def test_sibling(self):
     self.assertEqual(Path("a", "b").sibling("c"), Path("a", "c"))
Exemple #8
0
 def test_repr(self):
     self.assertEqual(repr(Path("a", "b", "c")), "<Path /a/b/c>")
Exemple #9
0
 def test_multi_descendant(self):
     self.assertEqual(Path("a").descendant("b", "c"), Path("a", "b", "c"))
Exemple #10
0
 def test_div_nonsense(self):
     with self.assertRaises(TypeError):
         Path("a") / object()
Exemple #11
0
 def test_root_dirname(self):
     self.assertEqual(Path().dirname(), os.sep)
Exemple #12
0
 def test_dirname(self):
     self.assertEqual(
         Path("a", "b", "c").dirname(),
         os.path.join(os.sep, "a", "b"),
     )
Exemple #13
0
 def test_root_basename(self):
     self.assertEqual(Path().basename(), "")
Exemple #14
0
 def test_basename(self):
     self.assertEqual(Path("a", "b").basename(), "b")
Exemple #15
0
 def test_root(self):
     self.assertEqual(Path.root(), Path())
Exemple #16
0
 def test_div(self):
     self.assertEqual(Path("a") / "b" / "c", Path("a", "b", "c"))