Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock VCS dev-dependencies as category "dev" #1725

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions poetry/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def add_dependency(
branch=constraint.get("branch", None),
tag=constraint.get("tag", None),
rev=constraint.get("rev", None),
category=category,
optional=optional,
)
elif "file" in constraint:
Expand Down
12 changes: 10 additions & 2 deletions poetry/packages/vcs_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ class VCSDependency(Dependency):
"""

def __init__(
self, name, vcs, source, branch=None, tag=None, rev=None, optional=False
self,
name,
vcs,
source,
branch=None,
tag=None,
rev=None,
category="main",
optional=False,
):
self._vcs = vcs
self._source = source
Expand All @@ -21,7 +29,7 @@ def __init__(
self._rev = rev

super(VCSDependency, self).__init__(
name, "*", optional=optional, allows_prereleases=True
name, "*", category=category, optional=optional, allows_prereleases=True
)

@property
Expand Down
23 changes: 23 additions & 0 deletions tests/packages/test_package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import pytest

from poetry.packages import Package


Expand All @@ -14,3 +16,24 @@ def test_package_authors():
package.authors.insert(0, "John Doe")
assert package.author_name == "John Doe"
assert package.author_email is None


@pytest.mark.parametrize("category", ["main", "dev"])
def test_package_add_dependency_vcs_category(category):
package = Package("foo", "0.1.0")

dependency = package.add_dependency(
"poetry",
constraint={"git": "https://github.com/python-poetry/poetry.git"},
category=category,
)
assert dependency.category == category


def test_package_add_dependency_vcs_category_default_main():
package = Package("foo", "0.1.0")

dependency = package.add_dependency(
"poetry", constraint={"git": "https://github.com/python-poetry/poetry.git"}
)
assert dependency.category == "main"
13 changes: 13 additions & 0 deletions tests/packages/test_vcs_dependency.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from poetry.packages.vcs_dependency import VCSDependency


Expand Down Expand Up @@ -49,3 +51,14 @@ def test_to_pep_508_in_extras():
expected = 'poetry @ git+https://github.com/python-poetry/poetry.git@b;ar; ; extra == "foo;"'

assert expected == dependency.to_pep_508()


@pytest.mark.parametrize("category", ["main", "dev"])
def test_category(category):
dependency = VCSDependency(
"poetry",
"git",
"https://github.com/python-poetry/poetry.git",
category=category,
)
assert category == dependency.category