Failures in test_requirements_file.py
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
Research direction
Start with tests/test_requirements_parser.py::test_RequirementsFile_to_dict and tests/pip_requirements_parser_tests/test_requirements_file.py, then inspect the failing requirement fixtures and their -expected.json and -expected.dumps files. Run the affected tests under Python 3.12 and compare the generated invalid-line messages with the checked-in expectations; done means the affected tests pass without changing unrelated behavior.
Written by the indexing model from the issue text.
Description
Environment:
- Python 3.12.0rc1
- Fedora Rawhide
- pip-requirements-parser 32.0.1
It seems some error messages changed, which make the comparison fail for the following tests:
test_RequirementsFile_to_dict
test_RequirementsFile_dumps_unparse
=================================== FAILURES ===================================
_ test_RequirementsFile_to_dict[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/requirements_parser_reqfiles/fail_1.txt] _
test_file = '/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/requirements_parser_reqfiles/fail_1.txt'
regen = False
@pytest.mark.parametrize("test_file", ALL_REQFILES)
def test_RequirementsFile_to_dict(
test_file: str,
regen=False,
) -> None:
expected_file = test_file + "-expected.json"
results = pip_requirements_parser.RequirementsFile.from_file(test_file).to_dict()
if regen:
with open (expected_file, 'w') as outp:
json.dump(results, outp, indent=2)
expected = results
else:
with open (expected_file) as inp:
expected = json.load(inp)
> assert results == expected
E AssertionError: assert {'comments': ...irements': []} == {'comments': ...irements': []}
E Omitting 3 identical items, use -vv to show
E Differing items:
E {'invalid_lines': [{'error_message': 'Invalid requirement: : Expected end or semicolon (after name and no valid versio...on (after name and no valid version specifier)\n test=>1.2.0\n ^', 'line': 'test=>1.2.0', 'line_number': 2}]} != {'invalid_lines': [{'error_message': 'Invalid requirement: : Expected version after operator\n test>>1.2.0\n ...on (after name and no valid version specifier)\n test=>1.2.0\n ^', 'line': 'test=>1.2.0', 'line_number': 2}]}
E Use -v to get more diff
tests/test_requirements_parser.py:74: AssertionError
_ test_RequirementsFile_to_dict[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/more-requirements/nikdoof-test-auth-requirements.txt] _
test_file = Path('/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/more-requirements/nikdoof-test-auth-requirements.txt')
regen = False
@pytest.mark.parametrize("test_file", all_test_requirements_files)
def test_RequirementsFile_to_dict(
test_file: str,
regen=False,
) -> None:
expected_file = test_file + "-expected.json"
results = pip_requirements_parser.RequirementsFile.from_file(test_file).to_dict()
if regen:
with open (expected_file, 'w') as outp:
json.dump(results, outp, indent=2)
expected = results
else:
with open (expected_file) as inp:
expected = json.load(inp)
> assert results == expected
E AssertionError: assert {'comments': ...], ...}, ...]} == {'comments': ...], ...}, ...]}
E Omitting 3 identical items, use -vv to show
E Differing items:
E {'invalid_lines': [{'error_message': 'Invalid requirement: : Expected end or semicolon (after name and no valid version specifier)\n fabric==dev\n ^', 'line': 'fabric==dev', 'line_number': 4}]} != {'invalid_lines': [{'error_message': 'Invalid requirement: : Expected version after operator\n fabric==dev\n ^', 'line': 'fabric==dev', 'line_number': 4}]}
E Use -v to get more diff
tests/pip_requirements_parser_tests/test_requirements_file.py:38: AssertionError
_ test_RequirementsFile_to_dict[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/sc-requirements/invalid_spec-requirements.txt] _
test_file = Path('/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/sc-requirements/invalid_spec-requirements.txt')
regen = False
@pytest.mark.parametrize("test_file", all_test_requirements_files)
def test_RequirementsFile_to_dict(
test_file: str,
regen=False,
) -> None:
expected_file = test_file + "-expected.json"
results = pip_requirements_parser.RequirementsFile.from_file(test_file).to_dict()
if regen:
with open (expected_file, 'w') as outp:
json.dump(results, outp, indent=2)
expected = results
else:
with open (expected_file) as inp:
expected = json.load(inp)
> assert results == expected
E AssertionError: assert {'comments': ...irements': []} == {'comments': ...irements': []}
E Omitting 3 identical items, use -vv to show
E Differing items:
E {'invalid_lines': [{'error_message': 'Invalid requirement: : Expected end or semicolon (after name and no valid versio...on (after name and no valid version specifier)\n test=>1.2.0\n ^', 'line': 'test=>1.2.0', 'line_number': 2}]} != {'invalid_lines': [{'error_message': 'Invalid requirement: : Expected version after operator\n test>>1.2.0\n ...on (after name and no valid version specifier)\n test=>1.2.0\n ^', 'line': 'test=>1.2.0', 'line_number': 2}]}
E Use -v to get more diff
tests/pip_requirements_parser_tests/test_requirements_file.py:38: AssertionError
_ test_RequirementsFile_dumps_unparse[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/more-requirements/nikdoof-test-auth-requirements.txt] _
test_file = Path('/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/more-requirements/nikdoof-test-auth-requirements.txt')
regen = False
@pytest.mark.parametrize("test_file", all_test_requirements_files)
def test_RequirementsFile_dumps_unparse(
test_file: str,
regen=False,
) -> None:
dumped = pip_requirements_parser.RequirementsFile.from_file(test_file).dumps(
preserve_one_empty_line=True,
)
expected_file = test_file + "-expected.dumps"
if regen:
with open(expected_file, "w") as out:
out.write(dumped)
expected = dumped
else:
with open(expected_file) as inp:
expected = inp.read()
> assert dumped == expected
E AssertionError: assert 'xmlrpclib\nx...aven>=2.0.3\n' == 'xmlrpclib\nx...aven>=2.0.3\n'
E Skipping 51 identical leading characters in diff, use -v to show
E - Expected version after operator
E + Expected end or semicolon (after name and no valid version specifier)
E fabric==dev
E - ^
E ? --
E + ^...
E
E ...Full output truncated (18 lines hidden), use '-vv' to show
tests/pip_requirements_parser_tests/test_requirements_file.py:61: AssertionError
_ test_RequirementsFile_dumps_unparse[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/sc-requirements/invalid_spec-requirements.txt] _
test_file = Path('/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/sc-requirements/invalid_spec-requirements.txt')
regen = False
@pytest.mark.parametrize("test_file", all_test_requirements_files)
def test_RequirementsFile_dumps_unparse(
test_file: str,
regen=False,
) -> None:
dumped = pip_requirements_parser.RequirementsFile.from_file(test_file).dumps(
preserve_one_empty_line=True,
)
expected_file = test_file + "-expected.dumps"
if regen:
with open(expected_file, "w") as out:
out.write(dumped)
expected = dumped
else:
with open(expected_file) as inp:
expected = inp.read()
> assert dumped == expected
E AssertionError: assert '# Invalid re...test=>1.2.0\n' == '# Invalid re...test=>1.2.0\n'
E - # Invalid requirement: : Expected version after operator
E + # Invalid requirement: : Expected end or semicolon (after name and no valid version specifier)
E test>>1.2.0
E - ^
E ? -
E + ^
E test>>1.2.0...
E
E ...Full output truncated (4 lines hidden), use '-vv' to show
tests/pip_requirements_parser_tests/test_requirements_file.py:61: AssertionError
=============================== warnings summary ===============================
tests/test_requirements_detector_parsing.py: 16 warnings
tests/pip_requirements_parser_tests/unit/test_utils_temp_dir.py: 18 warnings
/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/unit/misc.py:43: DeprecationWarning: onerror argument is deprecated, use onexc instead
shutil.rmtree(directory, ignore_errors=ignore_errors, onerror=rmtree_errorhandler)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_requirements_parser.py::test_RequirementsFile_to_dict[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/requirements_parser_reqfiles/fail_1.txt]
FAILED tests/pip_requirements_parser_tests/test_requirements_file.py::test_RequirementsFile_to_dict[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/more-requirements/nikdoof-test-auth-requirements.txt]
FAILED tests/pip_requirements_parser_tests/test_requirements_file.py::test_RequirementsFile_to_dict[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/sc-requirements/invalid_spec-requirements.txt]
FAILED tests/pip_requirements_parser_tests/test_requirements_file.py::test_RequirementsFile_dumps_unparse[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/more-requirements/nikdoof-test-auth-requirements.txt]
FAILED tests/pip_requirements_parser_tests/test_requirements_file.py::test_RequirementsFile_dumps_unparse[/builddir/build/BUILD/pip-requirements-parser-32.0.1/tests/pip_requirements_parser_tests/data/sc-requirements/invalid_spec-requirements.txt]
XFAIL tests/test_packaging_legacy_version.py::TestLegacyVersion::test_legacy_version_is_deprecated - We vendored packaging to reinstate LegacyVersion
====== 5 failed, 8265 passed, 5 skipped, 1 xfailed, 34 warnings in 11.69s ======
- Dominant language
- Python
- Stars
- 20
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aboutcode-org/pip-requirements-parser
-
Quadratic comment split on a requirements file line (pip_requirements_parser.py:1058)May be free again @Anurag-S1ngh claimed this 25 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aboutcode-org/pip-requirements-parser#30 · 1 comment ·
-
Support PEP 561 Distributing and Packaging Type Information (py.typed marker)May be free again A pull request for this issue was closed without being merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 60/100
-
Tests failures with packaging 26.0Possibly taken @s-t-e-v-e-n-k claimed this 290 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Doesn't support local paths to wheelsMay be free again @Anurag-S1ngh claimed this 18 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 48/100
aboutcode-org/pip-requirements-parser#26 · 3 comments ·
-
[BUG] VCS URLs are detected as path on linux systemsMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
All issues in aboutcode-org/pip-requirements-parser
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
GoogleCloudPlatform/professional-services-data-validator#1899 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mohanraj00/entelos#200 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
sweep
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bketelsen/truenas-mcp#77 ·
Maintainers usually reply within 1 day
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
sandbox-quantum/switch#2163 ·
Maintainers usually reply within 1 day