本文整理汇总了Python中pyup.requirements.Requirement类的典型用法代码示例。如果您正苦于以下问题:Python Requirement类的具体用法?Python Requirement怎么用?Python Requirement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Requirement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()]
)
示例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),
]
)
示例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]
)
示例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")
示例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")
示例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)
)
示例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")
示例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)
]
)
示例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")
示例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)
示例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")
示例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)
示例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")
示例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])
)
示例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()