Skip to content

Commit

Permalink
Returning deps after one unpinned dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
yeisonvargasf committed Nov 27, 2022
1 parent eadcbe1 commit 77b46da
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion safety/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def read_requirements(fh, resolve=True):
fg="yellow",
file=sys.stderr
)
return
continue

version = spec[1]
if spec[0] == '==':
Expand Down
1 change: 1 addition & 0 deletions tests/reqs_pinned.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
django==4.1.3
4 changes: 4 additions & 0 deletions tests/reqs_pinned_and_unpinned.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r reqs_pinned.txt
packaging==21.3
pipenv
flower==1.2.0
8 changes: 8 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def test_recursive_requirement(self):
result = list(read_requirements(fh, resolve=True))
self.assertEqual(len(result), 2)

def test_recursive_requirement_pinned_after_unpinned(self):
# this should find 3 packages, unpinned are ignored
dirname = os.path.dirname(__file__)
test_filename = os.path.join(dirname, "reqs_pinned_and_unpinned.txt")
with open(test_filename) as fh:
result = list(read_requirements(fh, resolve=True))
self.assertEqual(len(result), 3)

@patch("safety.util.get_flags_from_context")
@patch.object(sys, 'argv', ['safety/__main__.py', 'check', '--key=my-key', '-i', '3232', '-i', '3231', '--ignore',
'1212', '--json'])
Expand Down

0 comments on commit 77b46da

Please sign in to comment.