Skip to content

Commit

Permalink
Merge 0ee9076 into 060f52f
Browse files Browse the repository at this point in the history
  • Loading branch information
toanant committed Jun 13, 2020
2 parents 060f52f + 0ee9076 commit d3b58d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pipreqs/pipreqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ def init(args):
imports = local + get_imports_info(difference,
proxy=proxy,
pypi_server=pypi_server)
# sort imports based on lowercase name of package, similar to `pip freeze`.
imports = sorted(imports, key=lambda x: x['name'].lower())

path = (args["--savepath"] if args["--savepath"] else
os.path.join(input_path, "requirements.txt"))
Expand Down
3 changes: 3 additions & 0 deletions tests/test_pipreqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def test_init(self):
data = f.read().lower()
for item in self.modules[:-3]:
self.assertTrue(item.lower() in data)
# It should be sorted based on names.
data = data.strip().split('\n')
self.assertEqual(data, sorted(data))

def test_init_local_only(self):
"""
Expand Down

0 comments on commit d3b58d5

Please sign in to comment.