예제 #1
0
    def test_requirements(self) -> None:
        pkgs = [
            ("django == 2.*", "[email protected]"),
            ("mccabe >= 9.9.9rc1", "[email protected]"),
            ("munch >= 9.9.10rc1", "[email protected]"),
            ("mypy >= 10.10.10rc1", "[email protected]"),
            ("numpy > 1.16.1, > 1.15.4, == 1.16.0", "[email protected]"),
            ("packaging == 2.0.0b3", "[email protected]"),
            ("pkg-resources == 1.3.0", "[email protected]"),
            ("pycodestyle == 1.3.0b2", "[email protected]"),
            ("pydocstyle > 1.2.9", "[email protected]"),
            ("pyflakes > 0.0.0b3", "[email protected]"),
            ("pyparsing >= 0b2", "pyparsing@0"),
            ("pytz ~= 2018.9", "[email protected]"),
            ("pyyaml > 5.1b5, < 8", "[email protected]"),
            ("requests == 2.21.0", "[email protected]"),
            ("scipy == 1.*.1", "[email protected]"),
            ("scrapy >= 1.6.0", "[email protected]"),
            ("setuptools < 5", "setuptools@0"),
            ("six == 1.2.3 --hash=sha256:abcd", "[email protected]"),
            ("snowballstemmer == 0.0.0b3", "[email protected]"),
            ("twisted", "twisted@0"),
            ("yapf >= 5.1b5", "[email protected]"),
        ]
        f = io.StringIO("\n".join(p for p, _ in pkgs))
        f.name = "requirements.txt"

        got = [p.coordinate for p in packages.get_from_files([f])]
        want = ["pkg:pypi/{}".format(p) for _, p in pkgs]
        self.assertEqual(sorted(got), sorted(want))
예제 #2
0
    def test_multiple(self) -> None:
        r = [
            ("pytz > 2018.9", "[email protected]"),
            ("requests == 1.2", "[email protected]"),
        ]
        rf = io.StringIO("\n".join(x for x, _ in r))
        rf.name = "requirements.txt"

        p = [
            ("pysocks = '>= 0.6.5rc5'", "[email protected]"),
            ("pytest = '>2.8.0'", "[email protected]"),
        ]
        pf = io.StringIO("[packages]\n{}".format("\n".join(x for x, _ in p)))
        pf.name = "Pipfile"

        t = [
            ("docutils >3.0", "[email protected]"),
            ("pylint", "pylint@0"),
        ]
        tf = io.StringIO("[x]\ndeps={}".format("\n ".join(x for x, _ in t)))
        tf.name = "tox.ini"

        got = [p.coordinate for p in packages.get_from_files([rf, pf, tf])]
        want = ["pkg:pypi/{}".format(x) for x in [y for *_, y in r + p + t]]
        self.assertEqual(sorted(got), sorted(want))
예제 #3
0
    def test_pipfile_lock(self) -> None:
        pkgs = [
            ("docutils", "> 0.6.5rc5", "[email protected]"),
            ("pytest", "==2.8.0", "[email protected]"),
        ]

        entries = {n: {"version": v, "hashes": []} for n, v, *_ in pkgs}
        f = io.StringIO(json.dumps({"default": entries}))
        f.name = "Pipfile.lock"

        got = [p.coordinate for p in packages.get_from_files([f])]
        want = ["pkg:pypi/{}".format(p) for *_, p in pkgs]
        self.assertEqual(sorted(got), sorted(want))
예제 #4
0
    def test_tox(self) -> None:
        pkgs = [
            ("pylint", "pylint@0"),
            ("pytest >= 3.0.0, <4", "[email protected]"),
            ("pytz ~= 2018.9", "[email protected]"),
        ]

        f = io.StringIO("[x]\ndeps={}".format("\n ".join(p for p, _ in pkgs)))
        f.name = "tox.ini"

        got = [p.coordinate for p in packages.get_from_files([f])]
        want = ["pkg:pypi/{}".format(p) for _, p in pkgs]
        self.assertEqual(sorted(got), sorted(want))
예제 #5
0
    def test_duplicates(self) -> None:
        pkgs = [
            ("django == 2.*", "[email protected]"),
            ("django == 2.0", "[email protected]"),
            ("mccabe == 9.9.9", "[email protected]"),
            ("mccabe == 7.0.0", "[email protected]"),
            ("munch == 1.2.3", "[email protected]"),
            ("munch == 1.2.3", "[email protected]"),
        ]

        f = io.StringIO("\n".join(p for p, _ in pkgs))
        f.name = "requirements.txt"

        got = [p.coordinate for p in packages.get_from_files([f])]
        want = list(set("pkg:pypi/{}".format(p) for _, p in pkgs))
        self.assertEqual(sorted(got), sorted(want))
예제 #6
0
    def test_pipfile(self) -> None:
        pkgs = [
            ("docutils = '> 0.6.5rc5'", "[email protected]"),
            ("flake8 = '==0.6.5'", "[email protected]"),
            ("pysocks = '>= 0.6.5rc5'", "[email protected]"),
            ("pytest = '>=2.8.0,<4.1'", "[email protected]"),
            ("pytest-mock = '>2.8.0,<4.1'", "[email protected]"),
            ("requests = '>5.1, >=4.2, >=3.3, >9.4'", "[email protected]"),
            ("sphinx = '==0.6.5rc5'", "[email protected]"),
            ("tox = '*'", "tox@0"),
        ]
        f = io.StringIO("[packages]\n{}".format("\n".join(p for p, _ in pkgs)))
        f.name = "Pipfile"

        got = [p.coordinate for p in packages.get_from_files([f])]
        want = ["pkg:pypi/{}".format(p) for _, p in pkgs]
        self.assertEqual(sorted(got), sorted(want))