Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
a27d35eb
Unverified
Commit
a27d35eb
authored
May 08, 2023
by
Randy Döring
Committed by
GitHub
May 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: ensure forward compatibility with python-poetry/poetry-core#402 (#7852)
parent
1af8929a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
51 deletions
+105
-51
tests/utils/test_dependency_specification.py
+105
-51
No files found.
tests/utils/test_dependency_specification.py
View file @
a27d35eb
...
...
@@ -11,6 +11,8 @@ from poetry.utils.dependency_specification import RequirementsParser
if
TYPE_CHECKING
:
from
collections.abc
import
Collection
from
pytest_mock
import
MockerFixture
from
poetry.utils.cache
import
ArtifactCache
...
...
@@ -18,95 +20,144 @@ if TYPE_CHECKING:
@pytest.mark.parametrize
(
(
"requirement"
,
"
specification
"
),
(
"requirement"
,
"
expected_variants
"
),
[
(
"git+https://github.com/demo/demo.git"
,
{
"git"
:
"https://github.com/demo/demo.git"
,
"name"
:
"demo"
}
,
({
"git"
:
"https://github.com/demo/demo.git"
,
"name"
:
"demo"
},)
,
),
(
"git+ssh://github.com/demo/demo.git"
,
{
"git"
:
"ssh://github.com/demo/demo.git"
,
"name"
:
"demo"
}
,
({
"git"
:
"ssh://github.com/demo/demo.git"
,
"name"
:
"demo"
},)
,
),
(
"git+https://github.com/demo/demo.git#main"
,
{
"git"
:
"https://github.com/demo/demo.git"
,
"name"
:
"demo"
,
"rev"
:
"main"
},
(
{
"git"
:
"https://github.com/demo/demo.git"
,
"name"
:
"demo"
,
"rev"
:
"main"
,
},
),
),
(
"git+https://github.com/demo/demo.git@main"
,
{
"git"
:
"https://github.com/demo/demo.git"
,
"name"
:
"demo"
,
"rev"
:
"main"
},
(
{
"git"
:
"https://github.com/demo/demo.git"
,
"name"
:
"demo"
,
"rev"
:
"main"
,
},
),
),
(
"git+https://github.com/demo/subdirectories.git@main#subdirectory=two"
,
{
"git"
:
"https://github.com/demo/subdirectories.git"
,
"name"
:
"two"
,
"rev"
:
"main"
,
"subdirectory"
:
"two"
,
},
(
{
"git"
:
"https://github.com/demo/subdirectories.git"
,
"name"
:
"two"
,
"rev"
:
"main"
,
"subdirectory"
:
"two"
,
},
),
),
(
"demo"
,
({
"name"
:
"demo"
},)),
(
"demo@1.0.0"
,
({
"name"
:
"demo"
,
"version"
:
"1.0.0"
},)),
(
"demo@^1.0.0"
,
({
"name"
:
"demo"
,
"version"
:
"^1.0.0"
},)),
(
"demo@==1.0.0"
,
({
"name"
:
"demo"
,
"version"
:
"==1.0.0"
},)),
(
"demo@!=1.0.0"
,
({
"name"
:
"demo"
,
"version"
:
"!=1.0.0"
},)),
(
"demo@~1.0.0"
,
({
"name"
:
"demo"
,
"version"
:
"~1.0.0"
},)),
(
"demo[a,b]@1.0.0"
,
({
"name"
:
"demo"
,
"version"
:
"1.0.0"
,
"extras"
:
[
"a"
,
"b"
]},),
),
(
"demo"
,
{
"name"
:
"demo"
}),
(
"demo@1.0.0"
,
{
"name"
:
"demo"
,
"version"
:
"1.0.0"
}),
(
"demo@^1.0.0"
,
{
"name"
:
"demo"
,
"version"
:
"^1.0.0"
}),
(
"demo@==1.0.0"
,
{
"name"
:
"demo"
,
"version"
:
"==1.0.0"
}),
(
"demo@!=1.0.0"
,
{
"name"
:
"demo"
,
"version"
:
"!=1.0.0"
}),
(
"demo@~1.0.0"
,
{
"name"
:
"demo"
,
"version"
:
"~1.0.0"
}),
(
"demo[a,b]@1.0.0"
,
{
"name"
:
"demo"
,
"version"
:
"1.0.0"
,
"extras"
:
[
"a"
,
"b"
]}),
(
"demo[a,b]"
,
{
"name"
:
"demo"
,
"extras"
:
[
"a"
,
"b"
]}),
(
"../demo"
,
{
"name"
:
"demo"
,
"path"
:
"../demo"
}),
(
"../demo/demo.whl"
,
{
"name"
:
"demo"
,
"path"
:
"../demo/demo.whl"
}),
(
"demo[a,b]"
,
({
"name"
:
"demo"
,
"extras"
:
[
"a"
,
"b"
]},)),
(
"../demo"
,
({
"name"
:
"demo"
,
"path"
:
"../demo"
},)),
(
"../demo/demo.whl"
,
({
"name"
:
"demo"
,
"path"
:
"../demo/demo.whl"
},)),
(
"https://example.com/distributions/demo-0.1.0.tar.gz"
,
{
"name"
:
"demo"
,
"url"
:
"https://example.com/distributions/demo-0.1.0.tar.gz"
,
},
(
{
"name"
:
"demo"
,
"url"
:
"https://example.com/distributions/demo-0.1.0.tar.gz"
,
},
),
),
# PEP 508 inputs
(
"poetry-core (>=1.0.7,<1.1.0)"
,
{
"name"
:
"poetry-core"
,
"version"
:
">=1.0.7,<1.1.0"
}
,
({
"name"
:
"poetry-core"
,
"version"
:
">=1.0.7,<1.1.0"
},)
,
),
(
'requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "2.7"'
,
{
"name"
:
"requests"
,
"markers"
:
'python_version < "2.7"'
,
"version"
:
">=2.8.1,<2.9.0"
,
"extras"
:
[
"security"
,
"tests"
],
},
(
# allow several equivalent versions to make test more robust
{
"name"
:
"requests"
,
"markers"
:
'python_version < "2.7"'
,
"version"
:
">=2.8.1,<2.9"
,
"extras"
:
[
"security"
,
"tests"
],
},
{
"name"
:
"requests"
,
"markers"
:
'python_version < "2.7"'
,
"version"
:
">=2.8.1,<2.9.0"
,
"extras"
:
[
"security"
,
"tests"
],
},
{
"name"
:
"requests"
,
"markers"
:
'python_version < "2.7"'
,
"version"
:
">=2.8.1,<2.9.dev0"
,
"extras"
:
[
"security"
,
"tests"
],
},
{
"name"
:
"requests"
,
"markers"
:
'python_version < "2.7"'
,
"version"
:
">=2.8.1,<2.9.0.dev0"
,
"extras"
:
[
"security"
,
"tests"
],
},
{
"name"
:
"requests"
,
"markers"
:
'python_version < "2.7"'
,
"version"
:
">=2.8.1,==2.8.*"
,
"extras"
:
[
"security"
,
"tests"
],
},
),
),
(
"name (>=3,<4)"
,
{
"name"
:
"name"
,
"version"
:
">=3,<4"
}
),
(
"name (>=3,<4)"
,
({
"name"
:
"name"
,
"version"
:
">=3,<4"
},)
),
(
"name@http://foo.com"
,
{
"name"
:
"name"
,
"url"
:
"http://foo.com"
}
,
({
"name"
:
"name"
,
"url"
:
"http://foo.com"
},)
,
),
(
"name [fred,bar] @ http://foo.com ; python_version=='2.7'"
,
{
"name"
:
"name"
,
"markers"
:
'python_version == "2.7"'
,
"url"
:
"http://foo.com"
,
"extras"
:
[
"fred"
,
"bar"
],
},
(
{
"name"
:
"name"
,
"markers"
:
'python_version == "2.7"'
,
"url"
:
"http://foo.com"
,
"extras"
:
[
"fred"
,
"bar"
],
},
),
),
(
(
'cachecontrol[filecache] (>=0.12.9,<0.13.0); python_version >= "3.6"'
' and python_version < "4.0"'
),
{
"version"
:
">=0.12.9,<0.13.0"
,
"markers"
:
'python_version >= "3.6" and python_version < "4.0"'
,
"extras"
:
[
"filecache"
],
"name"
:
"cachecontrol"
,
},
(
{
"version"
:
">=0.12.9,<0.13.0"
,
"markers"
:
'python_version >= "3.6" and python_version < "4.0"'
,
"extras"
:
[
"filecache"
],
"name"
:
"cachecontrol"
,
},
),
),
],
)
def
test_parse_dependency_specification
(
requirement
:
str
,
specification
:
DependencySpec
,
expected_variants
:
Collection
[
DependencySpec
]
,
mocker
:
MockerFixture
,
artifact_cache
:
ArtifactCache
,
)
->
None
:
...
...
@@ -119,8 +170,11 @@ def test_parse_dependency_specification(
mocker
.
patch
(
"pathlib.Path.exists"
,
_mock
)
assert
not
DeepDiff
(
RequirementsParser
(
artifact_cache
=
artifact_cache
)
.
parse
(
requirement
),
specification
,
ignore_order
=
True
,
assert
any
(
not
DeepDiff
(
RequirementsParser
(
artifact_cache
=
artifact_cache
)
.
parse
(
requirement
),
specification
,
ignore_order
=
True
,
)
for
specification
in
expected_variants
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment