コード例 #1
0
ファイル: test_pip_interface.py プロジェクト: ryansmick/pipd
 def test_uninstall(self):
     package_to_uninstall = "six"
     pip_interface.uninstall(package_to_uninstall)
     self.assertTrue(
         package_to_uninstall not in pip_interface.get_package_names(),
         "{} found in packages after attempted uninstall".format(
             package_to_uninstall))
コード例 #2
0
    def test_removing_top_level_package_with_dependencies(self):
        # Create a graph
        graph = DepGraph()
        graph.build_graph()

        # Assertions for initial state
        self.assertIn(
            "packaging", graph.packages,
            "Packaging package not initially installed in environment")
        self.assertIn(
            "pyparsing", graph.packages,
            "Pyparsing package not initially installed in environment")

        # Perform uninstall
        graph.uninstall("packaging")

        # Post-action assertions
        self.assertTrue("packaging" not in pip_interface.get_package_names(),
                        "Packaging still installed")
        self.assertTrue("pyparsing" not in pip_interface.get_package_names(),
                        "Pyparsing still installed")
コード例 #3
0
    def test_removing_top_level_package_with_no_dependencies(self):
        # Create a graph
        graph = DepGraph()
        graph.build_graph()

        # Assertions for initial state
        self.assertIn("termcolor", graph.packages,
                      "Termcolor not initially installed in environment.")

        # Perform action: add dependency
        graph.uninstall("termcolor")

        # Post-action assertions
        self.assertTrue("termcolor" not in pip_interface.get_package_names(),
                        "Termcolor still installed")
コード例 #4
0
    def build_graph(self):
        # Reset the packages
        self.packages = {}

        # Create a nwe node in self.packages for each pip package
        for package_name in pip_interface.get_package_names():
            self.packages[package_name] = PackageNode(package_name)

        # Add dependencies for each pip package
        for package_name, package in self.packages.items():
            for dep_name in pip_interface.get_package_dependencies(package_name):
                try:
                    package.add_dependency(self.packages[dep_name])
                except KeyError:
                    # If dependency isn't in self.packages, package either isn't installed and we will not worry about it
                    # Or package is a default pip package that doesn't appear in pip freeze, and we won't worry about it
                    pass
コード例 #5
0
ファイル: test_pip_interface.py プロジェクト: ryansmick/pipd
 def test_get_package_names(self):
     packages = pip_interface.get_package_names()
     self.assertSubset(self.installed_packages, packages)
コード例 #6
0
 def test_build_graph(self):
     g = DepGraph()
     g.build_graph()
     self.assertEqual(pip_interface.get_package_names(), set(g.packages.keys()))
     self.assertIn('six', g.packages['packaging'].dependencies)