예제 #1
0
    def test_custom_egg_with_usr_files_remove(self):
        egg = NOSE_1_3_0

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #2
0
    def test_custom_egg_with_usr_files_remove(self):
        egg = NOSE_1_3_0

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #3
0
    def test_symlink(self):
        """Test installing an egg with softlink in it."""
        # Given
        if sys.platform == "win32":
            incdir = os.path.join(self.prefix, "EGG-INFO", "foo", "usr",
                                  "include")
            header = os.path.join(incdir, "foo.h")
            link = os.path.join(self.prefix, "EGG-INFO", "foo", "usr",
                                "HEADERS")
        else:
            incdir = os.path.join(self.prefix, "include")
            header = os.path.join(incdir, "foo.h")
            link = os.path.join(self.prefix, "HEADERS")

        egg_filename = os.path.join(self.base_dir, "foo-1.0.egg")
        _create_egg_with_symlink(egg_filename, "foo")
        # When
        installer = EggInst(egg_filename, prefix=self.prefix)
        installer.install()

        # Then
        self.assertTrue(os.path.exists(header))
        self.assertTrue(os.path.exists(link))
        self.assertTrue(os.path.islink(link))
        self.assertEqual(os.readlink(link), "include")
        self.assertTrue(os.path.exists(os.path.join(link, "foo.h")))
예제 #4
0
    def test_softlink_with_broken_entry(self):
        # Given
        path = VTK_EGG_DEFERRED_SOFTLINK

        # When
        installer = EggInst(path, prefix=self.prefix)
        installer.install()
예제 #5
0
    def test_custom_egg_legacy_egg_info(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO",
                                            "flake8")
        egg_info_base = os.path.join(self.site_packages,
                                     "flake8-2.0.0-2.egg-info")
        legacy_egg_info_base = os.path.join(self.site_packages,
                                            "flake8.egg-info")

        custom_metadata = ("PKG-INFO.bak", "requires.txt", "spec/depend",
                           "spec/summary")

        egg = LEGACY_EGG_INFO_EGG

        egginst = EggInst(egg, self.base_dir)
        egginst.install()

        # Check for files installed in $prefix/EGG-INFO
        for f in custom_metadata:
            path = os.path.join(custom_egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        # Check for files installed in $site-packages/$package_egg_info-INFO
        for f in LEGACY_EGG_INFO_EGG_METADATA_FILES:
            path = os.path.join(egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        for f in LEGACY_EGG_INFO_EGG_METADATA_FILES:
            path = os.path.join(legacy_egg_info_base, f)
            self.assertFalse(os.path.exists(path))
예제 #6
0
    def test_simple_custom_egg_remove(self):
        egg = DUMMY_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #7
0
    def test_custom_egg_with_usr_files(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "nose")
        egg_info_base = os.path.join(self.site_packages,
                                     "nose-{0}.egg-info".
                                     format("1.3.0-1"))
        egg = NOSE_1_3_0

        egginst = EggInst(egg, self.base_dir)
        egginst.install()

        # Check for files installed in $prefix/EGG-INFO
        for f in DUMMY_EGG_METADATA_FILES:
            path = os.path.join(custom_egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        # Check for files installed in $site-packages/$package_egg_info-INFO
        path = os.path.join(egg_info_base, "PKG-INFO")
        self.assertTrue(os.path.exists(path))

        path = os.path.join(egg_info_base, "spec/depend")
        self.assertFalse(os.path.exists(path))

        path = os.path.join(egg_info_base, "spec/summary")
        self.assertFalse(os.path.exists(path))

        path = os.path.join(egg_info_base, "usr/share/man/man1/nosetests.1")
        self.assertFalse(os.path.exists(path))
예제 #8
0
    def test_simple_custom_egg_remove(self):
        egg = DUMMY_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #9
0
    def test_old_appinst(self):
        """
        Test that we still work with old (<= 2.1.1) appinst, where
        [un]install_from_dat only takes one argument (no prefix).
        """
        egg_path = DUMMY_EGG_WITH_APPINST
        appinst_path = os.path.join(self.meta_dir, "dummy_with_appinst", eggmeta.APPINST_PATH)

        egginst = EggInst(egg_path, self.base_dir)

        def mocked_old_install_from_dat(x):
            pass

        def mocked_old_uninstall_from_dat(x):
            pass

        # XXX: we use autospec to enforce function taking exactly one argument,
        # otherwise the proper TypeError exception is not raised when calling
        # it with two arguments, which is how old vs new appinst is detected.
        with mock.patch("appinst.install_from_dat", autospec=mocked_old_install_from_dat) as m:
            egginst.install()
            m.assert_called_with(appinst_path)

        with mock.patch("appinst.uninstall_from_dat", autospec=mocked_old_uninstall_from_dat) as m:
            egginst.remove()
            m.assert_called_with(appinst_path)
예제 #10
0
    def test_find_lib_with_targets(self):
        def _compute_target_list(path, d):
            # FIXME: we need this hack as the internal EggInst zipfile
            # object is only available within an EggInst.install call.
            egg_inst = EggInst(path, d)
            egg_inst.z = zp

            return _compute_targets(egg_inst.iter_targets(), egg_inst.prefix)

        # Given
        with _zipfile.ZipFile(DUMMY_EGG_WITH_INST_TARGETS) as zp:
            egg_inst = EggInst(DUMMY_EGG_WITH_INST_TARGETS, self.prefix)
            egg_inst.install()

            targets = _compute_target_list(DUMMY_EGG_WITH_INST_TARGETS,
                                           self.prefix)

            path = "libfoo.dylib"
            r_found_lib = os.path.join(self.prefix, "lib", "foo-4.2", path)

            # When
            found_lib = _find_lib(path, targets)

            # Then
            self.assertEqual(found_lib, r_found_lib)
예제 #11
0
    def test_old_appinst(self):
        """
        Test that we still work with old (<= 2.1.1) appinst, where
        [un]install_from_dat only takes one argument (no prefix).
        """
        egg_path = DUMMY_EGG_WITH_APPINST
        appinst_path = os.path.join(self.meta_dir, "dummy_with_appinst",
                                    eggmeta.APPINST_PATH)

        egginst = EggInst(egg_path, self.base_dir)

        def mocked_old_install_from_dat(x):
            pass

        def mocked_old_uninstall_from_dat(x):
            pass

        # XXX: we use autospec to enforce function taking exactly one argument,
        # otherwise the proper TypeError exception is not raised when calling
        # it with two arguments, which is how old vs new appinst is detected.
        with mock.patch("appinst.install_from_dat",
                        autospec=mocked_old_install_from_dat) as m:
            egginst.install()
            m.assert_called_with(appinst_path)

        with mock.patch("appinst.uninstall_from_dat",
                        autospec=mocked_old_uninstall_from_dat) as m:
            egginst.remove()
            m.assert_called_with(appinst_path)
예제 #12
0
    def test_custom_egg_legacy_egg_info_remove(self):
        egg = LEGACY_EGG_INFO_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #13
0
    def test_custom_egg_with_usr_files(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "nose")
        egg_info_base = os.path.join(self.site_packages,
                                     "nose-{0}.egg-info".format("1.3.0-1"))
        egg = NOSE_1_3_0

        egginst = EggInst(egg, self.base_dir)
        egginst.install()

        # Check for files installed in $prefix/EGG-INFO
        for f in DUMMY_EGG_METADATA_FILES:
            path = os.path.join(custom_egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        # Check for files installed in $site-packages/$package_egg_info-INFO
        path = os.path.join(egg_info_base, "PKG-INFO")
        self.assertTrue(os.path.exists(path))

        path = os.path.join(egg_info_base, "spec/depend")
        self.assertFalse(os.path.exists(path))

        path = os.path.join(egg_info_base, "spec/summary")
        self.assertFalse(os.path.exists(path))

        path = os.path.join(egg_info_base, "usr/share/man/man1/nosetests.1")
        self.assertFalse(os.path.exists(path))
예제 #14
0
    def test_symlink(self):
        """Test installing an egg with softlink in it."""
        # Given
        if sys.platform == "win32":
            incdir = os.path.join(self.prefix, "EGG-INFO", "foo", "usr",
                                  "include")
            header = os.path.join(incdir, "foo.h")
            link = os.path.join(self.prefix, "EGG-INFO", "foo", "usr",
                                "HEADERS")
        else:
            incdir = os.path.join(self.prefix, "include")
            header = os.path.join(incdir, "foo.h")
            link = os.path.join(self.prefix, "HEADERS")

        egg_filename = os.path.join(self.base_dir, "foo-1.0.egg")
        _create_egg_with_symlink(egg_filename, "foo")
        # When
        installer = EggInst(egg_filename, prefix=self.prefix)
        installer.install()

        # Then
        self.assertTrue(os.path.exists(header))
        self.assertTrue(os.path.exists(link))
        self.assertTrue(os.path.islink(link))
        self.assertEqual(os.readlink(link), "include")
        self.assertTrue(os.path.exists(os.path.join(link, "foo.h")))
예제 #15
0
    def test_custom_egg_legacy_egg_info(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "flake8")
        egg_info_base = os.path.join(self.site_packages,
                                     "flake8-2.0.0-2.egg-info")
        legacy_egg_info_base = os.path.join(self.site_packages, "flake8.egg-info")

        custom_metadata = ("PKG-INFO.bak", "requires.txt", "spec/depend",
                           "spec/summary")

        egg = LEGACY_EGG_INFO_EGG

        egginst = EggInst(egg, self.base_dir)
        egginst.install()

        # Check for files installed in $prefix/EGG-INFO
        for f in custom_metadata:
            path = os.path.join(custom_egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        # Check for files installed in $site-packages/$package_egg_info-INFO
        for f in LEGACY_EGG_INFO_EGG_METADATA_FILES:
            path = os.path.join(egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        for f in LEGACY_EGG_INFO_EGG_METADATA_FILES:
            path = os.path.join(legacy_egg_info_base, f)
            self.assertFalse(os.path.exists(path))
예제 #16
0
    def test_custom_egg_legacy_egg_info_remove(self):
        egg = LEGACY_EGG_INFO_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #17
0
    def test_softlink_with_broken_entry(self):
        # Given
        path = VTK_EGG_DEFERRED_SOFTLINK

        # When
        installer = EggInst(path, prefix=self.prefix)
        installer.install()
예제 #18
0
    def test_standard_egg_remove(self):
        egg = STANDARD_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()

            egginst.remove()
예제 #19
0
    def test_simple(self):
        egginst = EggInst(DUMMY_EGG, self.base_dir)

        egginst.install()
        self.assertTrue(os.path.exists(os.path.join(self.site_packages, "dummy.py")))

        egginst.remove()
        self.assertFalse(os.path.exists(os.path.join(self.site_packages, "dummy.py")))
예제 #20
0
    def _install_egg_empty_egg_info_dir(self, egg_path):
        installer = EggInst(egg_path, prefix=self.prefix)
        installer.install()

        egg_info_dir = os.path.join(installer.site_packages,
                                    setuptools_egg_info_dir(egg_path))
        shutil.rmtree(egg_info_dir)
        os.makedirs(egg_info_dir)
예제 #21
0
    def test_standard_egg_remove(self):
        egg = STANDARD_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()

            egginst.remove()
예제 #22
0
    def _install_egg_empty_egg_info_dir(self, egg_path):
        installer = EggInst(egg_path, prefix=self.prefix)
        installer.install()

        egg_info_dir = os.path.join(installer.site_packages,
                                    setuptools_egg_info_dir(egg_path))
        shutil.rmtree(egg_info_dir)
        os.makedirs(egg_info_dir)
예제 #23
0
    def _install_egg_file_egg_info_dir(self, egg_path):
        installer = EggInst(egg_path, prefix=self.prefix)
        installer.install()

        egg_info_dir = os.path.join(installer.site_packages,
                                    setuptools_egg_info_dir(egg_path))
        shutil.rmtree(egg_info_dir)
        with open(egg_info_dir, "w") as fp:
            fp.write("")
예제 #24
0
    def _install_egg_file_egg_info_dir(self, egg_path):
        installer = EggInst(egg_path, prefix=self.prefix)
        installer.install()

        egg_info_dir = os.path.join(installer.site_packages,
                                    setuptools_egg_info_dir(egg_path))
        shutil.rmtree(egg_info_dir)
        with open(egg_info_dir, "w") as fp:
            fp.write("")
예제 #25
0
    def test_simple(self):
        egginst = EggInst(DUMMY_EGG, self.base_dir)

        egginst.install()
        self.assertTrue(
            os.path.exists(os.path.join(self.site_packages, "dummy.py")))

        egginst.remove()
        self.assertFalse(
            os.path.exists(os.path.join(self.site_packages, "dummy.py")))
예제 #26
0
    def test_standard_egg_remove(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "jinja2")
        egg_info_base = os.path.join(self.site_packages,
                                     "Jinja2-2.6-py2.7.egg-info")
        egg = STANDARD_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()

            egginst.remove()
예제 #27
0
    def test_custom_egg_with_usr_files_remove(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "nose")
        egg_info_base = os.path.join(self.site_packages,
                                     "nose-{0}.egg-info". \
                                     format("1.3.0-1"))
        egg = NOSE_1_3_0

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #28
0
    def test_custom_egg_legacy_egg_info_remove(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "flake9")
        egg_info_base = os.path.join(self.site_packages,
                                     "flake8-2.0.0-2.egg-info")
        legacy_egg_info_base = os.path.join(self.site_packages, "flake8.egg-info")
        egg = LEGACY_EGG_INFO_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #29
0
    def test_find_lib_with_targets(self):
        """
        Test we handle the targets.dat hack correctly in find_lib.
        """
        with mkdtemp() as d:
            with mock.patch("egginst.object_code._targets", []):
                egg_inst = EggInst(DUMMY_EGG_WITH_INST_TARGETS, d)
                egg_inst.install()

                path = "libfoo.dylib"
                self.assertEqual(find_lib(path), op.join(d, "lib", "foo-4.2", path))
예제 #30
0
    def test_simple_custom_egg_remove(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "dummy")
        egg_info_base = os.path.join(self.site_packages,
                                     "dummy-{0}.egg-info". \
                                     format("1.0.1-1"))
        egg = DUMMY_EGG

        with assert_same_fs(self, self.base_dir):
            egginst = EggInst(egg, self.base_dir)
            egginst.install()
            egginst.remove()
예제 #31
0
    def test_enstaller_no_placeholder_hack(self):
        # Given
        path = _create_dummy_enstaller_egg(self.base_dir)

        # When
        with mock.patch("egginst.main.object_code.apply_placeholder_hack") \
                as m:
            installer = EggInst(path, prefix=self.prefix)
            installer.install()

        # Then
        self.assertFalse(m.called)
예제 #32
0
    def test_simple(self):
        # Given
        path = DUMMY_EGG
        with mkdtemp() as tempdir:
            create_venv(tempdir)
            installer = EggInst(path, prefix=tempdir)
            installer.install()

            # When
            freeze_list = get_freeze_list([tempdir])

        self.assertEqual(freeze_list, ["dummy 1.0.1-1"])
예제 #33
0
    def test_without_appinst(self):
        """
        Test egginst does not crash when appinst is not available and we try
        installing eggs using appinst
        """
        egg_path = DUMMY_EGG_WITH_APPINST

        egginst = EggInst(egg_path, self.base_dir)

        with mock.patch("egginst.main.appinst", None):
            egginst.install()
            egginst.remove()
예제 #34
0
    def test_enstaller_no_placeholder_hack(self):
        # Given
        path = _create_dummy_enstaller_egg(self.base_dir)

        # When
        with mock.patch("egginst.main.object_code.apply_placeholder_hack") \
                as m:
            installer = EggInst(path, prefix=self.prefix)
            installer.install()

        # Then
        self.assertFalse(m.called)
예제 #35
0
    def test_without_appinst(self):
        """
        Test egginst does not crash when appinst is not available and we try
        installing eggs using appinst
        """
        egg_path = DUMMY_EGG_WITH_APPINST

        egginst = EggInst(egg_path, self.base_dir)

        with mock.patch("egginst.main.appinst", None):
            egginst.install()
            egginst.remove()
예제 #36
0
    def test_entry_points(self):
        """
        Test we install console entry points correctly.
        """
        egginst = EggInst(DUMMY_EGG_WITH_ENTRY_POINTS, self.base_dir)

        egginst.install()
        self.assertTrue(op.exists(op.join(self.site_packages, "dummy.py")))
        self.assertTrue(op.exists(op.join(self.bindir, "dummy")))

        egginst.remove()
        self.assertFalse(op.exists(op.join(self.site_packages, "dummy.py")))
        self.assertFalse(op.exists(op.join(self.bindir, "dummy")))
예제 #37
0
    def test_appinst_failed(self):
        """
        Test egginst does not crash when appinst is not available and we try
        installing eggs using appinst
        """
        egg_path = DUMMY_EGG_WITH_APPINST

        egginst = EggInst(egg_path, self.base_dir)

        with mock.patch("egginst.main.appinst.install_from_dat", side_effect=ValueError):
            egginst.install()

        with mock.patch("egginst.main.appinst.uninstall_from_dat", side_effect=ValueError):
            egginst.remove()
예제 #38
0
    def test_post_install_script(self):
        # Given
        create_venv(self.prefix)

        egg_filename = DUMMY_EGG_WITH_POST_INSTALL
        # This file is expected to be created by the egg's post install script
        r_touch = os.path.join(self.prefix, "touch.txt")

        # When
        installer = EggInst(egg_filename, prefix=self.prefix)
        installer.install()

        # Then
        self.assertTrue(os.path.exists(r_touch))
예제 #39
0
    def test_simple(self):
        r_link = "libfoo.so"
        r_source = "libfoo.so.0.0.0"

        with mkdtemp() as d:
            egginst = EggInst(DUMMY_EGG_WITH_PROXY_SOFTLINK, d)
            egginst.install()

            link = os.path.join(d, "lib", r_link)
            source = os.path.join(d, "lib", r_source)
            self.assertTrue(os.path.exists(link))
            self.assertTrue(os.path.exists(source))
            self.assertTrue(os.path.islink(link))
            self.assertEqual(os.readlink(link), os.path.basename(source))
예제 #40
0
    def test_get_installed(self):
        r_installed_eggs = sorted([
            os.path.basename(DUMMY_EGG),
            os.path.basename(DUMMY_EGG_WITH_ENTRY_POINTS),
        ])

        with mkdtemp() as d:
            egginst = EggInst(DUMMY_EGG, d)
            egginst.install()

            egginst = EggInst(DUMMY_EGG_WITH_ENTRY_POINTS, d)
            egginst.install()

            installed_eggs = list(get_installed(d))
            self.assertEqual(installed_eggs, r_installed_eggs)
예제 #41
0
    def test_pre_egguninst(self):
        # Given
        create_venv(self.prefix)

        remover = EggInst(DUMMY_EGG_WITH_PRE_REMOVE, self.prefix)
        remover.install()

        # When
        remover.remove()

        # Then
        # Ensure text file created by pre-remove script exists
        self.assertTrue(
            os.path.exists(os.path.join(self.prefix, "touch.txt"))
        )
예제 #42
0
    def test_get_installed(self):
        r_installed_eggs = sorted([
            os.path.basename(DUMMY_EGG),
            os.path.basename(DUMMY_EGG_WITH_ENTRY_POINTS),
        ])

        with mkdtemp() as d:
            egginst = EggInst(DUMMY_EGG, d)
            egginst.install()

            egginst = EggInst(DUMMY_EGG_WITH_ENTRY_POINTS, d)
            egginst.install()

            installed_eggs = list(get_installed(d))
            self.assertEqual(installed_eggs, r_installed_eggs)
예제 #43
0
    def test_from_prefix(self):
        # Given
        path = DUMMY_EGG
        with mkdtemp() as tempdir:
            create_venv(tempdir)
            installer = EggInst(path, prefix=tempdir)
            installer.install()

            # When
            repository = Repository._from_prefixes([tempdir])

            # Then
            packages = repository.find_packages("dummy")
            self.assertEqual(len(packages), 1)
            self.assertEqual(packages[0].name, "dummy")
예제 #44
0
    def test_from_prefix(self):
        # Given
        path = DUMMY_EGG
        with mkdtemp() as tempdir:
            create_venv(tempdir)
            installer = EggInst(path, prefix=tempdir)
            installer.install()

            # When
            repository = Repository._from_prefixes([tempdir])

            # Then
            packages = repository.find_packages("dummy")
            self.assertEqual(len(packages), 1)
            self.assertEqual(packages[0].name, "dummy")
예제 #45
0
    def test_appinst_failed(self):
        """
        Test egginst does not crash when appinst is not available and we try
        installing eggs using appinst
        """
        egg_path = DUMMY_EGG_WITH_APPINST

        egginst = EggInst(egg_path, self.base_dir)

        with mock.patch("egginst.main.appinst.install_from_dat",
                        side_effect=ValueError):
            egginst.install()

        with mock.patch("egginst.main.appinst.uninstall_from_dat",
                        side_effect=ValueError):
            egginst.remove()
예제 #46
0
    def test_appinst(self):
        """
        Test we install appinst bits correctly.
        """
        egg_path = DUMMY_EGG_WITH_APPINST
        appinst_path = os.path.join(self.meta_dir, "dummy_with_appinst", eggmeta.APPINST_PATH)

        egginst = EggInst(egg_path, self.base_dir)

        with mock.patch("appinst.install_from_dat", autospec=True) as m:
            egginst.install()
            m.assert_called_with(appinst_path, self.base_dir)

        with mock.patch("appinst.uninstall_from_dat", autospec=True) as m:
            egginst.remove()
            m.assert_called_with(appinst_path, self.base_dir)
예제 #47
0
    def test_symlink(self):
        """Test installing an egg with softlink in it."""
        egg_filename = op.join(self.base_dir, "foo-1.0.egg")
        _create_egg_with_symlink(egg_filename, "foo")

        installer = EggInst(egg_filename, prefix=self.prefix)
        installer.install()

        incdir = op.join(self.prefix, "include")
        header = op.join(incdir, "foo.h")
        link = op.join(self.prefix, "HEADERS")

        self.assertTrue(op.exists(header))
        self.assertTrue(op.exists(link))
        self.assertTrue(op.islink(link))
        self.assertEqual(os.readlink(link), "include")
        self.assertTrue(op.exists(op.join(link, "foo.h")))
예제 #48
0
    def test_appinst(self):
        """
        Test we install appinst bits correctly.
        """
        egg_path = DUMMY_EGG_WITH_APPINST
        appinst_path = os.path.join(self.meta_dir, "dummy_with_appinst",
                                    eggmeta.APPINST_PATH)

        egginst = EggInst(egg_path, self.base_dir)

        with mock.patch("appinst.install_from_dat", autospec=True) as m:
            egginst.install()
            m.assert_called_with(appinst_path, self.base_dir)

        with mock.patch("appinst.uninstall_from_dat", autospec=True) as m:
            egginst.remove()
            m.assert_called_with(appinst_path, self.base_dir)
예제 #49
0
    def test_appinst(self):
        """
        Test we install appinst bits correctly.
        """
        egg_path = DUMMY_EGG_WITH_APPINST
        appinst_path = op.join(self.meta_dir, "dummy_with_appinst", APPINST_PATH)

        egginst = EggInst(egg_path, self.base_dir)

        mocked_appinst = mock.Mock()
        with mock.patch("appinst.install_from_dat", mocked_appinst.install_from_dat):
            egginst.install()
            mocked_appinst.install_from_dat.assert_called_with(appinst_path, self.base_dir)

        with mock.patch("appinst.uninstall_from_dat", mocked_appinst.uninstall_from_dat):
            egginst.remove()
            mocked_appinst.install_from_dat.assert_called_with(appinst_path, self.base_dir)
    def test_remove_actions(self):
        # Given
        repository = Repository()

        for egg in [DUMMY_EGG]:
            egginst = EggInst(egg, self.prefix)
            egginst.install()

        solver = Solver(repository, Repository._from_prefixes([self.prefix]))

        request = Request()
        request.remove(Requirement("dummy"))

        # When
        actions = solver.resolve(request)

        # Then
        self.assertEqual(actions, [("remove", os.path.basename(DUMMY_EGG))])
예제 #51
0
    def test_entry_points(self):
        """
        Test we install console entry points correctly.
        """
        py_script = os.path.join(self.site_packages, "dummy.py")
        if sys.platform == "win32":
            wrapper_script = os.path.join(self.bindir, "dummy.exe")
        else:
            wrapper_script = os.path.join(self.bindir, "dummy")

        egginst = EggInst(DUMMY_EGG_WITH_ENTRY_POINTS, self.base_dir)

        egginst.install()
        self.assertTrue(os.path.exists(py_script))
        self.assertTrue(os.path.exists(wrapper_script))

        egginst.remove()
        self.assertFalse(os.path.exists(py_script))
        self.assertFalse(os.path.exists(wrapper_script))
예제 #52
0
    def test_standard_egg(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO",
                                            "jinja2")
        egg_info_base = os.path.join(self.site_packages,
                                     "Jinja2-2.6-py2.7.egg-info")

        egg = STANDARD_EGG

        egginst = EggInst(egg, self.base_dir)
        egginst.install()

        # Check for files installed in $prefix/EGG-INFO
        for f in STANDARD_EGG_METADATA_FILES:
            path = os.path.join(custom_egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        # Check for files installed in $site-packages/$package_egg_info-INFO
        for f in STANDARD_EGG_METADATA_FILES:
            path = os.path.join(egg_info_base, f)
            self.assertTrue(os.path.exists(path))
예제 #53
0
    def test_simple_custom_egg(self):
        custom_egg_info_base = os.path.join(self.base_dir, "EGG-INFO", "dummy")
        egg_info_base = os.path.join(self.site_packages,
                                     "dummy-{0}.egg-info".format("1.0.1-1"))
        egg = DUMMY_EGG

        egginst = EggInst(egg, self.base_dir)
        egginst.install()

        # Check for files installed in $prefix/EGG-INFO
        for f in DUMMY_EGG_METADATA_FILES:
            path = os.path.join(custom_egg_info_base, f)
            self.assertTrue(os.path.exists(path))

        # Check for files installed in $site-packages/$package_egg_info-INFO
        path = os.path.join(egg_info_base, "PKG-INFO")
        self.assertTrue(os.path.exists(path))

        path = os.path.join(egg_info_base, "spec/depend")
        self.assertFalse(os.path.exists(path))

        path = os.path.join(egg_info_base, "spec/summary")
        self.assertFalse(os.path.exists(path))
예제 #54
0
    def test_print_installed(self):
        with mkdtemp() as d:
            r_out = textwrap.dedent("""\
                Name                 Version              Store
                ============================================================
                dummy                1.0.1-1              {0}
                """.format(disp_store_info(d)))
            ec = EggInst(DUMMY_EGG, d)
            ec.install()

            repository = Repository._from_prefixes([d])
            with mock_print() as m:
                print_installed(repository)
            self.assertMultiLineEqual(m.value, r_out)

            r_out = textwrap.dedent("""\
                Name                 Version              Store
                ============================================================
                """)

            repository = Repository._from_prefixes([d])
            with mock_print() as m:
                print_installed(repository, pat=re.compile("no_dummy"))
            self.assertEqual(m.value, r_out)
예제 #55
0
 def _install_egg(self, egg_path):
     installer = EggInst(egg_path, prefix=self.prefix)
     installer.install()