mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 06:46:15 +00:00
Added new Pipenv option sort_alphabetical
Sort packages alphabetically inside each category. Currently runs on `install`.
This commit is contained in:
+3
-1
@@ -1226,7 +1226,9 @@ class Project:
|
||||
newly_added = True
|
||||
|
||||
p[category][normalized_name] = entry
|
||||
p[category] = dict(sorted(p[category].items()))
|
||||
|
||||
if self.settings.get("sort_alphabetical"):
|
||||
p[category] = dict(sorted(p[category].items()))
|
||||
|
||||
# Write Pipfile.
|
||||
self.write_toml(p)
|
||||
|
||||
@@ -557,9 +557,30 @@ dataclasses-json = {file = "https://files.pythonhosted.org/packages/85/94/1b3021
|
||||
c = p.pipenv("""run python -c "from dataclasses_json import dataclass_json" """)
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.basic
|
||||
@pytest.mark.install
|
||||
def test_packages_sorted_alphabetically_in_category(pipenv_instance_private_pypi):
|
||||
def test_category_sorted_alphabetically_with_directive(pipenv_instance_private_pypi):
|
||||
with pipenv_instance_private_pypi() as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
contents = """
|
||||
[pipenv]
|
||||
sort_alphabetical = true
|
||||
|
||||
[packages]
|
||||
atomicwrites = "*"
|
||||
colorama = "*"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv("install build")
|
||||
assert c.returncode == 0
|
||||
assert "build" in p.pipfile["packages"]
|
||||
assert list(p.pipfile["packages"].keys()) == ["atomicwrites", "build", "colorama"]
|
||||
|
||||
|
||||
@pytest.mark.basic
|
||||
@pytest.mark.install
|
||||
def test_category_not_sorted_without_directive(pipenv_instance_private_pypi):
|
||||
with pipenv_instance_private_pypi() as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
contents = """
|
||||
@@ -571,5 +592,8 @@ colorama = "*"
|
||||
c = p.pipenv("install build")
|
||||
assert c.returncode == 0
|
||||
assert "build" in p.pipfile["packages"]
|
||||
assert list(p.pipfile["packages"].keys()) == ["atomicwrites", "build", "colorama"]
|
||||
|
||||
assert list(p.pipfile["packages"].keys()) == [
|
||||
"atomicwrites",
|
||||
"colorama",
|
||||
"build",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user