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_find_existing_by_dir_succeeds_for_existing_virtualenvs(self):
        self.filesystem.create_directory(self.locator.root / "bla")

        path = Path("foo", "bla")
        stdout, stderr = self.run_cli(
            ["find", "--existing-only", "directory",
             str(path)], )
        self.assertEqual(
            (stdout, stderr),
            (str(self.locator.for_directory(path).path) + "\n", ""),
        )
Exemple #3
0
    def setUp(self):
        super(CLIMixin, self).setUp()

        self.stdin = NativeStringIO()
        self.stdout = NativeStringIO()
        self.stderr = NativeStringIO()

        self.filesystem = filesystems.memory.FS()

        self.root_dir = Path("virtualenvs")
        self.filesystem.create_directory(self.root_dir)

        self.link_dir = Path("bin")
        self.filesystem.create_directory(self.link_dir)

        self.locator = Locator(
            root=self.root_dir,
            make_virtualenv=lambda **kwargs: VirtualEnv(
                create=self.fake_create, install=self.fake_install, **kwargs),
        )
Exemple #4
0
 def temporary_directory(self):
     # TODO: Maybe this isn't good enough.
     directory = Path(uuid4().hex)
     self.create_directory(path=directory, with_parents=False)
     return directory
Exemple #5
0
 def test_descendant(self):
     self.assertEqual(Path("a", "b").descendant("c"), Path("a", "b", "c"))
Exemple #6
0
 def test_relative_to(self):
     self.assertEqual(
         RelativePath("a", "b", "c").relative_to(Path("d", "e")),
         Path("d", "e", "a", "b", "c"),
     )
Exemple #7
0
 def test_root_dirname(self):
     self.assertEqual(Path().dirname(), "/")
Exemple #8
0
 def test_dirname(self):
     self.assertEqual(Path("a", "b", "c").dirname(), "/a/b")
Exemple #9
0
 def test_root_basename(self):
     self.assertEqual(Path().basename(), "")
Exemple #10
0
 def test_instances_are_independent(self):
     fs = self.FS()
     fs.touch(Path("file"))
     self.assertTrue(fs.exists(Path("file")))
     self.assertFalse(self.FS().exists(Path("file")))
Exemple #11
0
 def test_root(self):
     self.assertEqual(Path.root(), Path())
Exemple #12
0
 def test_from_string(self):
     self.assertEqual(Path.from_string("/a/b/c"), Path("a", "b", "c"))
Exemple #13
0
 def test_sibling(self):
     self.assertEqual(Path("a", "b").sibling("c"), Path("a", "c"))
Exemple #14
0
 def test_parent(self):
     self.assertEqual(Path("a", "b").parent(), Path("a"))
Exemple #15
0
 def test_basename(self):
     self.assertEqual(Path("a", "b").basename(), "b")
Exemple #16
0
 def test_prepended_override(self):
     command = Command("foo", "bar", cwd=Path("tmp", "foo"))
     self.assertThat(
         command.prepended("baz", cwd=Path("tmp", "bar")),
         Equals(Command("baz", "foo", "bar", cwd=Path("tmp", "bar"))),
     )
Exemple #17
0
 def test_children_of_nonempty_root(self):
     fs = self.FS()
     fs.touch(Path("file"))
     self.assertEqual(fs.children(Path.root()), s(Path("file")))