-
-
Notifications
You must be signed in to change notification settings - Fork 776
Fix Poetry lock optional dependency parsing #5295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -398,6 +398,39 @@ def test_parse_poetry_lock_univers(self): | |
| expected_loc = self.get_test_loc('pypi/poetry/univers-poetry.lock-expected.json') | ||
| self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES) | ||
|
|
||
| def test_parse_poetry_lock_package_optional(self): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use an actual test file and expected results file like in the tests above? |
||
| test_file = self.get_temp_file('poetry.lock') | ||
| with open(test_file, 'w') as lockfile: | ||
| lockfile.write('''\ | ||
| [[package]] | ||
| name = "required-dep" | ||
| version = "1.0.0" | ||
| description = "required dependency" | ||
| optional = false | ||
| python-versions = ">=3.8" | ||
|
|
||
| [[package]] | ||
| name = "optional-dep" | ||
| version = "2.0.0" | ||
| description = "optional dependency" | ||
| optional = true | ||
| python-versions = ">=3.8" | ||
|
|
||
| [metadata] | ||
| lock-version = "2.0" | ||
| python-versions = ">=3.8" | ||
| content-hash = "test" | ||
| ''') | ||
|
|
||
| package_data = list(pypi.PoetryLockHandler.parse(test_file))[0] | ||
| dependencies_by_purl = { | ||
| dependency['purl']: dependency | ||
| for dependency in package_data.dependencies | ||
| } | ||
|
|
||
| assert dependencies_by_purl['pkg:pypi/required-dep@1.0.0']['is_optional'] is False | ||
| assert dependencies_by_purl['pkg:pypi/optional-dep@2.0.0']['is_optional'] is True | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to parse results and assert specifically, we run whole file results test with a test and an expected file, just check the expected behaviour and results as a whole |
||
|
|
||
| def test_parse_pyproject_toml_poetry_univers(self): | ||
| test_file = self.get_test_loc('pypi/poetry/univers/pyproject.toml') | ||
| package = pypi.PoetryPyprojectTomlHandler.parse(test_file) | ||
|
|
@@ -805,4 +838,3 @@ def test_parse_setup_py(test_loc): | |
| ) | ||
| def test_parse_more_setup_py(test_loc): | ||
| check_setup_py_parsing(test_loc) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch