mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Sort packages alphabetically inside each category
When installing any package, sort all package names alphabetically inside the category, for easier reading. Unsure if this is the best place or way to implement. Small prototype to add to discussion in https://github.com/pypa/pipenv/issues/5964 Tests: before patch: ``` AssertionError: assert ['atomicwrite...ama', 'build'] == ['atomicwrite...', 'colorama'] At index 1 diff: 'colorama' != 'build' Full diff: - ['atomicwrites', 'build', 'colorama'] ? --------- + ['atomicwrites', 'colorama', 'build'] ? +++++++++ ``` after patch: pass.
This commit is contained in:
@@ -1226,6 +1226,7 @@ class Project:
|
||||
newly_added = True
|
||||
|
||||
p[category][normalized_name] = entry
|
||||
p[category] = dict(sorted(p[category].items()))
|
||||
|
||||
# Write Pipfile.
|
||||
self.write_toml(p)
|
||||
|
||||
@@ -556,3 +556,20 @@ dataclasses-json = {file = "https://files.pythonhosted.org/packages/85/94/1b3021
|
||||
assert c.returncode == 0
|
||||
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):
|
||||
with pipenv_instance_private_pypi() as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
contents = """
|
||||
[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"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user