Пример #1
0
 def test_get_dependency_links(self):
     with mockPackage(setup="""
         from setuptools import setup
         setup(name="abc", version="1.2.3", dependency_links=["foo"])
         """) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.get_dependency_links(), ["foo"])
Пример #2
0
 def test_get_dependency_links_missing(self):
     with mockPackage(setup="""
         from distutils.core import setup
         setup(name="abc", version="1.2.3")
         """) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.get_dependency_links(), [])
Пример #3
0
 def test_get_dependency_links(self):
     with mockPackage(
         setup="""
         from setuptools import setup
         setup(name="abc", version="1.2.3", dependency_links=["foo"])
         """
     ) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.get_dependency_links(), ["foo"])
Пример #4
0
 def test_get_dependency_links_missing(self):
     with mockPackage(
         setup="""
         from distutils.core import setup
         setup(name="abc", version="1.2.3")
         """
     ) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.get_dependency_links(), [])
Пример #5
0
 def test_get_deps_setup_requires(self):
     with mockPackage(setup="""
         from setuptools import setup
         setup(name="abc", version="1.2.3", setup_requires=['setuptools'])
         """) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(
             package.get_deps(),
             [Spec.from_line("setuptools", extra=("_setup_requires", ))])
Пример #6
0
 def test_get_deps_distutils(self):
     with mockPackage(setup="""
         from distutils.core import setup
         setup(
             name="abc", version="1.2.3",
             requires=["foo"]
         )
         """) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.get_deps(), [Spec.from_line("foo")])
Пример #7
0
 def test_get_deps_setup_requires(self):
     with mockPackage(
         setup="""
         from setuptools import setup
         setup(name="abc", version="1.2.3", setup_requires=['setuptools'])
         """
     ) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(
             package.get_deps(),
             [Spec.from_line("setuptools", extra=("_setup_requires",))]
         )
Пример #8
0
 def test_get_deps_distutils(self):
     with mockPackage(
         setup="""
         from distutils.core import setup
         setup(
             name="abc", version="1.2.3",
             requires=["foo"]
         )
         """
     ) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.get_deps(), [Spec.from_line("foo")])
Пример #9
0
 def test_get_deps(self):
     with mockPackage(setup="""
         from setuptools import setup
         setup(
             name="abc", version="1.2.3",
             install_requires=["setuptools", "pip"]
         )
         """) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(
             package.get_deps(),
             [Spec.from_line("setuptools"),
              Spec.from_line("pip")])
Пример #10
0
 def test_get_deps_extra(self):
     with mockPackage(setup="""
         from setuptools import setup
         setup(
             name="abc", version="1.2.3",
             extras_require={
                 'test': ['nose'], 'development': ['sphinx']
             }
         )
         """) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.get_deps(extra=("test", "development")), [
             Spec.from_line("nose", extra=("test", )),
             Spec.from_line("sphinx", extra=("development", ))
         ])
Пример #11
0
 def test_get_deps(self):
     with mockPackage(
         setup="""
         from setuptools import setup
         setup(
             name="abc", version="1.2.3",
             install_requires=["setuptools", "pip"]
         )
         """
     ) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(
             package.get_deps(),
             [Spec.from_line("setuptools"), Spec.from_line("pip")]
         )
Пример #12
0
 def test_get_deps_extra(self):
     with mockPackage(
         setup="""
         from setuptools import setup
         setup(
             name="abc", version="1.2.3",
             extras_require={
                 'test': ['nose'], 'development': ['sphinx']
             }
         )
         """
     ) as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(
             package.get_deps(extra=("test", "development")),
             [Spec.from_line("nose", extra=("test",)),
              Spec.from_line("sphinx", extra=("development",))]
         )
Пример #13
0
 def test_init_from_setup_arguments(self):
     with mockPackage(setup="""
         from setuptools import setup
         setup(name="abc", version="1.2.3")
         """) as m:
         package = Package(dist_dir=m)
         self.assertEqual(package.name, "abc")
         self.assertEqual(package.version, "1.2.3")
         self.assertEqual(package.dist_dir, m)
Пример #14
0
 def test_pkg_info(self):
     with mockPackage(setup="""
         from setuptools import setup
         setup(
             name="abc", version="1.2.3",
             long_description="very awesome. much package. wow.",
             license="BSD"
         )
         """) as m:
         pkginfo = Package(fullname="abc-1.2.3", dist_dir=m).get_pkginfo()
         self.assertEqual(pkginfo["Name"], "abc")
         self.assertEqual(pkginfo["Version"], "1.2.3")
         self.assertEqual(pkginfo["Description"],
                          "very awesome. much package. wow.")
         self.assertEqual(pkginfo["License"], "BSD")
Пример #15
0
 def test_pkg_info_distutils(self):
     with mockPackage(setup="""
         from distutils.core import setup
         setup(name="abc", version="1.2.3")
         """,
                      pkginfo="""
         Name: abc
         Version: 1.2.3
         Description: very awesome. much package. wow.
         License: BSD
         """) as m:
         pkginfo = Package(fullname="abc-1.2.3", dist_dir=m).get_pkginfo()
         self.assertEqual(pkginfo["Name"], "abc")
         self.assertEqual(pkginfo["Version"], "1.2.3")
         self.assertEqual(pkginfo["Description"],
                          "very awesome. much package. wow.")
         self.assertEqual(pkginfo["License"], "BSD")
Пример #16
0
    def test_get_dependencies_hook(self):
        """Tests if dependency hook works"""
        with mockPackage(setup="""
            from setuptools import setup
            setup(
                name="abc", version="1.2.3",
                install_requires=["setuptools", "pip"]
            )
            """) as m:
            spec = Spec.from_line("abc==1.2.3")
            dependency_hook = Mock(side_effect=lambda o, s, d, p: d)
            package = Package(fullname=spec.fullname, dist_dir=m)

            override = hashabledict({"spec": "somespec"})
            pkgmgr = PackageManager(dependency_hook=dependency_hook,
                                    overrides={"abc": override})
            pkgmgr.get_package = Mock(return_value=package)
            deps = pkgmgr.get_dependencies(spec.name, spec.pinned)
            dependency_hook.assert_called_with(override, spec, deps, package)
Пример #17
0
    def test_get_dependencies(self):
        """Tests if getting dependencies works"""
        with mockPackage(setup="""
            from setuptools import setup
            setup(
                name="abc", version="1.2.3",
                install_requires=["setuptools", "pip"]
            )
            """) as m:
            spec = Spec.from_line("abc==1.2.3")
            package = Package(fullname=spec.fullname, dist_dir=m)

            pkgmgr = PackageManager()
            pkgmgr.get_package = Mock(return_value=package)

            self.assertEqual(
                pkgmgr.get_dependencies(spec.name, spec.pinned),
                [Spec.from_line("setuptools"),
                 Spec.from_line("pip")])
            pkgmgr.get_package.assert_called_with(spec)
Пример #18
0
    def test_get_versions(self):
        """Tests if getting picked versions works"""
        with mockPackage(setup="""
            from setuptools import setup
            setup(name="abc", version="1.2.3")
            """) as m:
            spec = Spec.from_line("abc==1.2.3")
            spec_version = Spec.from_line("def==2.3.4")
            version_hook = Mock(side_effect=lambda o, s, p: [spec_version])
            package = Package(fullname=spec.fullname, dist_dir=m)

            override = hashabledict({"spec": "somespec"})
            pkgmgr = PackageManager(version_hook=version_hook,
                                    overrides={"abc": override})
            pkgmgr.get_package = Mock(return_value=package)
            vers = pkgmgr.get_versions(spec.name, spec.pinned)

            version_hook.assert_called_with(override, spec, package)
            self.assertEqual(vers, [spec_version])
            self.assertEqual(pkgmgr._version_cache, {(spec, override): vers})

            version_hook.reset_mock()
            vers = pkgmgr.get_versions(spec.name, spec.pinned)
            self.assertFalse(version_hook.called)
Пример #19
0
    def test_get_pkg_info(self):
        """Tests if getting pkg_info works"""
        with mockPackage(setup="""
            from setuptools import setup
            setup(
                name="abc", version="1.2.3",
                long_description="very awesome. much package. wow.",
                license="BSD",
                test_suite="test"
            )
            """) as m:
            spec = Spec.from_line("abc==1.2.3")
            package = Package(fullname=spec.fullname, dist_dir=m)
            pkgmgr = PackageManager()
            pkgmgr.get_package = Mock(return_value=package)
            pkginfo = pkgmgr.get_pkg_info(spec.name, spec.pinned)

            self.assertEqual(pkginfo["Name"], "abc")
            self.assertEqual(pkginfo["has_tests"], True)
            self.assertEqual(pkgmgr._pkg_info_cache, {spec: pkginfo})

            pkgmgr.get_package.reset_mock()
            pkgmgr.get_pkg_info(spec.name, spec.pinned)
            self.assertFalse(pkgmgr.get_package.called)
Пример #20
0
 def test_init_from_dir(self):
     with mockPackage(indir="abc-1.2.3") as m:
         package = Package(package_dir=m)
         self.assertEqual(package.name, "abc")
         self.assertEqual(package.version, "1.2.3")
         self.assertEqual(package.dist_dir, os.path.join(m, "abc-1.2.3"))
Пример #21
0
 def test_get_deps_no_setup(self):
     with mockPackage(indir="abc-1.2.3") as m:
         package = Package(package_dir=m)
         self.assertEqual(package.get_deps(), [])
Пример #22
0
 def test_no_pkg_info(self):
     with mockPackage(indir="abc-1.2.3") as m:
         package = Package(package_dir=m)
         with self.assertRaises(Exception):
             package.get_pkginfo()
Пример #23
0
 def test_no_pkg_info(self):
     with mockPackage(indir="abc-1.2.3") as m:
         package = Package(package_dir=m)
         with self.assertRaises(Exception):
             package.get_pkginfo()
Пример #24
0
 def test_get_deps_no_setup(self):
     with mockPackage(indir="abc-1.2.3") as m:
         package = Package(package_dir=m)
         self.assertEqual(package.get_deps(), [])
Пример #25
0
 def test_init_from_fullname(self):
     with mockPackage() as m:
         package = Package(fullname="abc-1.2.3", dist_dir=m)
         self.assertEqual(package.name, "abc")
         self.assertEqual(package.version, "1.2.3")
         self.assertEqual(package.dist_dir, m)