Esempio n. 1
0
        public void MergeRequirementsMismatchedCase()
        {
            AssertUtil.AreEqual(
                PipRequirementsUtils.MergeRequirements(new[] {
                "aaaaaa==0.0",
                "BbBbBb==0.1",
                "CCCCCC==0.2"
            }, new[] {
                "aaaAAA==0.1",
                "bbbBBB==0.2",
                "cccCCC==0.3"
            }.Select(p => PackageSpec.FromRequirement(p)), false),
                "aaaAAA==0.1",
                "bbbBBB==0.2",
                "cccCCC==0.3"
                );

            // https://pytools.codeplex.com/workitem/2465
            AssertUtil.AreEqual(
                PipRequirementsUtils.MergeRequirements(new[] {
                "Flask==0.10.1",
                "itsdangerous==0.24",
                "Jinja2==2.7.3",
                "MarkupSafe==0.23",
                "Werkzeug==0.9.6"
            }, new[] {
                "flask==0.10.1",
                "itsdangerous==0.24",
                "jinja2==2.7.3",
                "markupsafe==0.23",
                "werkzeug==0.9.6"
            }.Select(p => PackageSpec.FromRequirement(p)), false),
                "flask==0.10.1",
                "itsdangerous==0.24",
                "jinja2==2.7.3",
                "markupsafe==0.23",
                "werkzeug==0.9.6"
                );
        }
Esempio n. 2
0
        public void MergeRequirements()
        {
            // Comments should be preserved, only package specs should change.
            AssertUtil.AreEqual(
                PipRequirementsUtils.MergeRequirements(new[] {
                "a # with a comment",
                "B==0.2",
                "# just a comment B==01234",
                "",
                "x < 1",
                "d==1.0",
                "e==2.0",
                "f==3.0",
                "-r user/requirements.txt",
                "git+https://myvcs.com/some_dependency",
            }, new[] {
                "b==0.1",
                "a==0.2",
                "c==0.3",
                "e==4.0",
                "x==0.8"
            }.Select(p => PackageSpec.FromRequirement(p)), false),
                "a==0.2 # with a comment",
                "b==0.1",
                "# just a comment B==01234",
                "",
                "x==0.8",
                "d==1.0",
                "e==4.0",
                "f==3.0",
                "-r user/requirements.txt",
                "git+https://myvcs.com/some_dependency"
                );

            // addNew is true, so the c==0.3 should be added.
            AssertUtil.AreEqual(
                PipRequirementsUtils.MergeRequirements(new[] {
                "a # with a comment",
                "b==0.2",
                "# just a comment B==01234"
            }, new[] {
                "B==0.1",       // case is updated
                "a==0.2",
                "c==0.3"
            }.Select(p => PackageSpec.FromRequirement(p)), true),
                "a==0.2 # with a comment",
                "B==0.1",
                "# just a comment B==01234",
                "c==0.3"
                );

            // No existing entries, so the new ones are sorted and returned.
            AssertUtil.AreEqual(
                PipRequirementsUtils.MergeRequirements(null, new[] {
                "b==0.2",
                "a==0.1",
                "c==0.3"
            }.Select(p => PackageSpec.FromRequirement(p)), false),
                "a==0.1",
                "b==0.2",
                "c==0.3"
                );

            // Check all the inequalities
            const string inequalities = "<=|>=|<|>|!=|==";

            AssertUtil.AreEqual(
                PipRequirementsUtils.MergeRequirements(
                    inequalities.Split('|').Select(s => "a " + s + " 1.2.3"),
                    new[] { "a==0" }.Select(p => PackageSpec.FromRequirement(p)),
                    false
                    ),
                inequalities.Split('|').Select(_ => "a==0").ToArray()
                );
        }