From 77b46da3b18c3b64a83812c0c730700f55ca00c2 Mon Sep 17 00:00:00 2001 From: Yeison Vargas Date: Sun, 27 Nov 2022 17:07:24 -0500 Subject: [PATCH] Returning deps after one unpinned dependency. --- safety/util.py | 2 +- tests/reqs_pinned.txt | 1 + tests/reqs_pinned_and_unpinned.txt | 4 ++++ tests/test_util.py | 8 ++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/reqs_pinned.txt create mode 100644 tests/reqs_pinned_and_unpinned.txt diff --git a/safety/util.py b/safety/util.py index aa6683ab..5f7d29a5 100644 --- a/safety/util.py +++ b/safety/util.py @@ -70,7 +70,7 @@ def read_requirements(fh, resolve=True): fg="yellow", file=sys.stderr ) - return + continue version = spec[1] if spec[0] == '==': diff --git a/tests/reqs_pinned.txt b/tests/reqs_pinned.txt new file mode 100644 index 00000000..c42d7bdf --- /dev/null +++ b/tests/reqs_pinned.txt @@ -0,0 +1 @@ +django==4.1.3 \ No newline at end of file diff --git a/tests/reqs_pinned_and_unpinned.txt b/tests/reqs_pinned_and_unpinned.txt new file mode 100644 index 00000000..2d92d60b --- /dev/null +++ b/tests/reqs_pinned_and_unpinned.txt @@ -0,0 +1,4 @@ +-r reqs_pinned.txt +packaging==21.3 +pipenv +flower==1.2.0 \ No newline at end of file diff --git a/tests/test_util.py b/tests/test_util.py index d52181f4..43cb3cf4 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -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'])