• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python requirements.Requirement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyup.requirements.Requirement的典型用法代码示例。如果您正苦于以下问题:Python Requirement类的具体用法?Python Requirement怎么用?Python Requirement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Requirement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_pull_requests

    def test_pull_requests(self):
        pr1 = pullrequest_factory("PR1")
        pr2 = pullrequest_factory("PR2")
        pr3 = pullrequest_factory("PR3")

        req1 = Requirement.parse("django", 0)
        req1.pull_request = pr1
        req2 = Requirement.parse("pyramid", 0)
        req2.pull_request = pr1
        req3 = Requirement.parse("flask", 0)
        req3.pull_request = pr2
        req4 = Requirement.parse("elixir", 0)
        req4.pull_request = pr3

        reqs = RequirementsBundle()

        req_file = RequirementFile(path="foo", content='')
        req_file._requirements = [
            req1, req2, req3, req4
        ]

        reqs.append(req_file)

        self.assertEqual(
            [pr1, pr2, pr3],
            [pr for pr in reqs.pull_requests()]
        )
开发者ID:wolfspyre,项目名称:pyup,代码行数:27,代码来源:test_requirements.py


示例2: test_parse_requirement

    def test_parse_requirement(self, package):
        package.return_value = True
        content = """
-e common/lib/calc
South==1.0.1
pycrypto>=2.6
git+https://github.com/pmitros/[email protected]
distribute>=0.6.28, <0.7
# bogus comment
-e .
pdfminer==20140328
-r production/requirements.txt
--requirement test.txt
        """
        r = RequirementFile("r.txt", content=content)

        self.assertEqual(
            r.other_files, [
                "production/requirements.txt",
                "test.txt"
            ]
        )

        self.assertEqual(
            r.requirements, [
                Requirement.parse("South==1.0.1", 3),
                Requirement.parse("pycrypto>=2.6", 4),
                Requirement.parse("distribute>=0.6.28, <0.7", 6),
                Requirement.parse("pdfminer==20140328", 3),
            ]
        )
开发者ID:pyupio,项目名称:pyup,代码行数:31,代码来源:test_requirements.py


示例3: test_requirements

    def test_requirements(self):
        with patch('pyup.requirements.Requirement.package', return_value=Mock()):
            reqs = RequirementsBundle()
            reqs.append(RequirementFile(path="r.txt", content='Bla\nFoo'))

            self.assertEqual([
                Requirement.parse("Bla", 1),
                Requirement.parse("Foo", 2)
            ],
                [r for r in reqs.requirements]
            )
开发者ID:pyupio,项目名称:pyup,代码行数:11,代码来源:test_requirements.py


示例4: test_version_pinned

    def test_version_pinned(self):
        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django", versions=["1.8", "1.9"])):
            r = Requirement.parse("Django==1.9", 0)
            self.assertEqual(r.version, "1.9")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django==1.9rc1",
                                                versions=["1.8", "1.9rc1", "1.9rc2"])):
            r = Requirement.parse("Django==1.9.2.rc14 # rq.filter != 1.44", 0)
            self.assertEqual(r.version, "1.9.2.rc14")
开发者ID:pyupio,项目名称:pyup,代码行数:11,代码来源:test_requirements.py


示例5: test_update_content_tabbed

    def test_update_content_tabbed(self):
        with patch('pyup.requirements.Requirement.latest_version_within_specs', new_callable=PropertyMock,
                   return_value="1.4.2"):
            content = "bla==1.4.1\t\t# some foo"
            req = Requirement.parse(content, 0)

            self.assertEqual(req.update_content(content), "bla==1.4.2 # some foo")

            content = "bla==1.4.1\t\t# pyup: <1.4.2"
            req = Requirement.parse(content, 0)

            self.assertEqual(req.update_content(content), "bla==1.4.2 # pyup: <1.4.2")
开发者ID:pyupio,项目名称:pyup,代码行数:12,代码来源:test_requirements.py


示例6: test_parse_hashes

 def test_parse_hashes(self):
     with open(os.path.dirname(os.path.realpath(__file__)) + "/data/hashed_reqs.txt") as f:
         content = f.read()
         r = RequirementFile("r.txt", content)
         self.assertEqual(
             [
                 Requirement.parse("alembic==0.8.9", 1),
                 Requirement.parse("amqp==2.1.1", 3),
                 Requirement.parse("argon2-cffi==16.3.0", 6),
                 Requirement.parse("Babel==2.3.4", 8),
             ],
             list(r.requirements)
         )
开发者ID:pombredanne,项目名称:pyup,代码行数:13,代码来源:test_requirements.py


示例7: test_get_latest_version_within_specs

    def test_get_latest_version_within_specs(self):
        latest = Requirement.get_latest_version_within_specs(
            (("==", "1.2"), ("!=", "1.2")),
            ["1.2", "1.3", "1.4", "1.5"]
        )

        self.assertEqual(latest, None)

        latest = Requirement.get_latest_version_within_specs(
            (("==", "1.2.1"),),
            ["1.2.0", "1.2.1", "1.2.2", "1.3"]
        )

        self.assertEqual(latest, "1.2.1")
开发者ID:pyupio,项目名称:pyup,代码行数:14,代码来源:test_requirements.py


示例8: test_ignore_requirement

    def test_ignore_requirement(self, package):
        package.return_value = True

        content = """foo
bar # pyup: ignore
baz"""
        r = RequirementFile("r.txt", content=content)
        self.assertEqual(len(r.requirements), 2)
        self.assertEqual(
            r.requirements, [
                Requirement.parse("foo", 0),
                Requirement.parse("baz", 2)
            ]
        )
开发者ID:pyupio,项目名称:pyup,代码行数:14,代码来源:test_requirements.py


示例9: test_update_content_simple_unpinned

    def test_update_content_simple_unpinned(self):
        with patch('pyup.requirements.Requirement.latest_version', new_callable=PropertyMock,
                   return_value="1.4.2"):
            content = "django"
            req = Requirement.parse(content, 0)

            self.assertEqual(req.update_content(content), "django==1.4.2")

        with patch('pyup.requirements.Requirement.latest_version', new_callable=PropertyMock,
                   return_value="1.4.2"):
            content = "Django"
            req = Requirement.parse(content, 0)

            self.assertEqual(req.update_content(content), "Django==1.4.2")
开发者ID:pyupio,项目名称:pyup,代码行数:14,代码来源:test_requirements.py


示例10: test_is_loose

    def test_is_loose(self):
        req = Requirement.parse("Django", 0)
        self.assertEqual(req.is_loose, True)

        req = Requirement.parse("Django==1.4,>1.5", 0)
        self.assertEqual(req.is_loose, False)

        req = Requirement.parse("Django===1.4", 0)
        self.assertEqual(req.is_loose, False)

        req = Requirement.parse("Django<=1.4,>=1.33", 0)
        self.assertEqual(req.is_loose, False)

        req = Requirement.parse("Django==1.4", 0)
        self.assertEqual(req.is_loose, False)
开发者ID:pyupio,项目名称:pyup,代码行数:15,代码来源:test_requirements.py


示例11: test_update_content_with_extras

    def test_update_content_with_extras(self):
        with patch('pyup.requirements.Requirement.latest_version_within_specs', new_callable=PropertyMock,
                   return_value="1.4.2"):
            content = "requests[security]==1.4.1"
            req = Requirement.parse(content, 0)

            self.assertEqual(req.update_content(content), "requests[security]==1.4.2")
开发者ID:pombredanne,项目名称:pyup,代码行数:7,代码来源:test_requirements.py


示例12: test_update_content_unfinished_line

 def test_update_content_unfinished_line(self):
     with patch('pyup.requirements.Requirement.latest_version', new_callable=PropertyMock,
                return_value="1.5.6"):
         content = 'raven==0.2\n'
         req = Requirement.parse("raven==0.2", 0)
         updated_content = 'raven==1.5.6\n'
         self.assertEqual(req.update_content(content), updated_content)
开发者ID:pyupio,项目名称:pyup,代码行数:7,代码来源:test_requirements.py


示例13: test_version_unpinned

    def test_version_unpinned(self):
        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django", versions=["1.9", "1.8"])):
            r = Requirement.parse("Django", 0)
            self.assertEqual(r.version, "1.9")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django", versions=["1.9rc1", "1.9", "1.8"])):
            r = Requirement.parse("Django", 0)
            self.assertEqual(r.version, "1.9")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django",
                                                versions=["1.9.1", "1.8", "1.9rc1"])):
            r = Requirement.parse("django", 0)
            self.assertEqual(r.version, "1.9.1")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(
                       name="django",
                       versions=["1.4.3", "1.5", "1.4.2", "1.4.1", ])):
            r = Requirement.parse("Django  # rq.filter: >=1.4,<1.5", 0)
            self.assertEqual(r.version, "1.4.3")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(
                       name="django",
                       versions=["1.4.3", "1.5", "1.4.2", "1.4.1", ])):
            r = Requirement.parse("Django  # pyup: >=1.4,<1.5", 0)
            self.assertEqual(r.version, "1.4.3")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django", versions=["1.8.1", "1.8"])):
            r = Requirement.parse("Django  # rq.filter: !=1.8.1", 0)
            self.assertEqual(r.version, "1.8")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django", versions=["1.8.1", "1.8"])):
            r = Requirement.parse("Django  # pyup: !=1.8.1", 0)
            self.assertEqual(r.version, "1.8")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django",
                                                versions=["1.9rc1", "1.9.1", "1.8", ])):
            r = Requirement.parse("django  # rq.filter: bogus", 0)
            self.assertEqual(r.version, "1.9.1")

        with patch('pyup.requirements.Requirement.package', new_callable=PropertyMock,
                   return_value=package_factory(name="django",
                                                versions=["1.9rc1", "1.9.1", "1.8", ])):
            r = Requirement.parse("django  # pyup: bogus", 0)
            self.assertEqual(r.version, "1.9.1")
开发者ID:pyupio,项目名称:pyup,代码行数:52,代码来源:test_requirements.py


示例14: test_filter

    def test_filter(self):
        r = Requirement.parse("Django==1.7.6", 0)
        self.assertEqual(r.filter, False)

        r = Requirement.parse("Django==1.7.6 # pyup: < 1.7.8", 0)
        self.assertEqual(r.filter, [("<", "1.7.8")])

        req = Requirement.parse("some-package==1.9.3 # rq.filter: <1.10 #some comment here", 0)
        self.assertEqual(req.filter, [("<", "1.10")])

        r = Requirement.parse("django==1.7.1  # pyup: <1.7.6", 0)

        r = Requirement.parse("Django==1.7.6 # pyup: < 1.7.8, > 1.7.2", 0)
        self.assertEqual(
            sorted(r.filter, key=lambda r: r[1]),
            sorted([("<", "1.7.8"), (">", "1.7.2")], key=lambda r: r[1])
        )
开发者ID:pyupio,项目名称:pyup,代码行数:17,代码来源:test_requirements.py


示例15: test_latest_version_within_specs_called

    def test_latest_version_within_specs_called(self):

        with patch('pyup.requirements.Requirement.latest_version_within_specs',
                   new_callable=PropertyMock, return_value="1.4.2") as mocked:
            content = "django==1.4.1"
            req = Requirement.parse(content, 0)
            self.assertEqual(req.update_content(content), "django==1.4.2")
            mocked.assert_called_with()
开发者ID:pyupio,项目名称:pyup,代码行数:8,代码来源:test_requirements.py


示例16: test_update_content_with_dubious_package_name

 def test_update_content_with_dubious_package_name(self):
     with patch('pyup.requirements.Requirement.latest_version', new_callable=PropertyMock,
                return_value="2.58.1.44"):
         content = 'raven\n' \
                   'ravenclient'
         req = Requirement.parse("raven", 0)
         updated_content = 'raven==2.58.1.44\n' \
                           'ravenclient'
         self.assertEqual(req.update_content(content), updated_content)
开发者ID:pyupio,项目名称:pyup,代码行数:9,代码来源:test_requirements.py


示例17: test_update_with_environment_markers_and_comment

    def test_update_with_environment_markers_and_comment(self):
        with patch('pyup.requirements.Requirement.latest_version_within_specs',
                   new_callable=PropertyMock,
                   return_value="1.4.2"):

            content = "uvloop==0.6.5; sys_platform != 'win32' # and here's some comment"
            req = Requirement.parse(content, 0)

            self.assertEqual(req.update_content(content), "uvloop==1.4.2; sys_platform != 'win32' # and here's some comment")
开发者ID:pombredanne,项目名称:pyup,代码行数:9,代码来源:test_requirements.py


示例18: test_needs_update

    def test_needs_update(self, requests):
        with open(os.path.dirname(os.path.realpath(__file__)) + "/data/django.json") as f:
            requests.get("https://pypi.python.org/pypi/Django/json", text=f.read())

            # is pinned and on latest
            r = Requirement.parse("Django==1.9rc1", 0)
            self.assertEqual(r.needs_update, False)

            # is ranged and open
            r = Requirement.parse("Django>=1.8", 0)
            self.assertEqual(r.needs_update, False)

            # is pinned but old
            r = Requirement.parse("Django==1.7", 0)
            self.assertEqual(r.needs_update, True)

            # is not pinned
            r = Requirement.parse("Django", 0)
            self.assertEqual(r.needs_update, True)
开发者ID:pyupio,项目名称:pyup,代码行数:19,代码来源:test_requirements.py


示例19: test_package_not_found

    def test_package_not_found(self, requests):
        requests.get("https://pypi.python.org/pypi/Fango/json", text="404", status_code=404)
        r = Requirement.parse("Fango", 0)
        self.assertEqual(r._fetched_package, False)
        self.assertEqual(r._package, None)

        # this triggers the fetch
        self.assertEqual(r.package, None)
        self.assertEqual(r._fetched_package, True)
        self.assertEqual(r._package, None)
开发者ID:pyupio,项目名称:pyup,代码行数:10,代码来源:test_requirements.py


示例20: test_package_found

    def test_package_found(self, requests):
        with open(os.path.dirname(os.path.realpath(__file__)) + "/data/django.json") as f:
            requests.get("https://pypi.python.org/pypi/Django/json", text=f.read())
        r = Requirement.parse("Django==1.9rc1", 0)
        self.assertEqual(r._fetched_package, False)
        self.assertEqual(r._package, None)

        # this triggers the fetch
        self.assertNotEqual(r.package, None)
        self.assertEqual(r._fetched_package, True)
        self.assertNotEqual(r._package, None)
开发者ID:pyupio,项目名称:pyup,代码行数:11,代码来源:test_requirements.py



注:本文中的pyup.requirements.Requirement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python downloader.FileDownloader类代码示例发布时间:2022-05-27
下一篇:
Python pyuno.getClass函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap