Example #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()
Example #2
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()
Example #3
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()
Example #4
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)
Example #5
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)
Example #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()
Example #7
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()
Example #8
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()
Example #9
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()
Example #10
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")))
Example #11
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()
Example #12
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")))
Example #13
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()
Example #14
0
    def test_simple_(self):
        # Given
        remover = EggInst(DUMMY_EGG, self.prefix)

        # When
        with testfixtures.LogCapture() as logger:
            remover.remove()

        # Then
        logger.check(('egginst.main', 'ERROR',
                      "Error: Can't find meta data for: 'dummy'"))
Example #15
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()
Example #16
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()
Example #17
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()
Example #18
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()
Example #19
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()
Example #20
0
    def test_simple_(self):
        # Given
        remover = EggInst(DUMMY_EGG, self.prefix)

        # When
        with testfixtures.LogCapture() as logger:
            remover.remove()

        # Then
        logger.check(
            ('egginst.main', 'ERROR',
             "Error: Can't find meta data for: 'dummy'")
        )
Example #21
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")))
Example #22
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()
Example #23
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"))
        )
Example #24
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)
Example #25
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()
Example #26
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)
Example #27
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)
Example #28
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))
Example #29
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))