本文整理汇总了Python中pyup.requirements.Requirement.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Requirement.parse方法的具体用法?Python Requirement.parse怎么用?Python Requirement.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyup.requirements.Requirement
的用法示例。
在下文中一共展示了Requirement.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_requirement
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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),
]
)
示例2: test_pull_requests
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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()]
)
示例3: test_version_pinned
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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")
示例4: test_requirements
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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]
)
示例5: test_update_content_tabbed
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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")
示例6: test_parse_hashes
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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)
)
示例7: test_ignore_requirement
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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)
]
)
示例8: test_update_content_simple_unpinned
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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")
示例9: test_is_loose
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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)
示例10: test_update_content_unfinished_line
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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)
示例11: test_update_content_with_extras
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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")
示例12: test_version_unpinned
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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")
示例13: test_filter
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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])
)
示例14: test_latest_version_within_specs_called
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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()
示例15: test_update_content_with_dubious_package_name
# 需要导入模块: from pyup.requirements import Requirement [as 别名]
# 或者: from pyup.requirements.Requirement import parse [as 别名]
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)