Skip to content
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

AST parser fails on Python 3.9 #288

Closed
bnavigator opened this issue Mar 22, 2021 · 0 comments · Fixed by #301
Closed

AST parser fails on Python 3.9 #288

bnavigator opened this issue Mar 22, 2021 · 0 comments · Fixed by #301

Comments

@bnavigator
Copy link

bnavigator commented Mar 22, 2021

These tests fail with Python 3.9.2 while they pass with 3.8.8:

[   32s] ============================= test session starts ==============================
[   32s] platform linux -- Python 3.9.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
[   32s] rootdir: /home/abuild/rpmbuild/BUILD/requirementslib-1.5.16, configfile: setup.cfg
[   32s] plugins: hypothesis-6.8.1, timeout-1.4.2
[   32s] timeout: 300.0s
[   32s] timeout method: signal
[   32s] timeout func_only: False
[   32s] collected 189 items / 20 deselected / 169 selected
[   32s] 
[   32s] tests/unit/test_exceptions.py ......                                     [  3%]
[   34s] tests/unit/test_lockfile.py ...                                          [  5%]
[   34s] tests/unit/test_markers.py .........................................     [ 29%]
[   42s] tests/unit/test_metadata.py ..                                           [ 30%]
[   42s] tests/unit/test_pipfile.py ........                                      [ 35%]
[   42s] tests/unit/test_project.py ....................                          [ 47%]
[   46s] tests/unit/test_requirements.py ........................................ [ 71%]
[   46s] .....                                                                    [ 73%]
[   46s] tests/unit/test_setup_info.py .......F...F..                             [ 82%]
[   49s] tests/unit/test_uri.py ..                                                [ 83%]
[   49s] tests/unit/test_utils.py ............................                    [100%]
[   49s] 
[   49s] =================================== FAILURES ===================================
[   49s] _________________ test_ast_parser_handles_repeated_assignments _________________
[   49s] 
[   49s] setup_py_dir = PosixPath('/home/abuild/rpmbuild/BUILD/requirementslib-1.5.16/tests/fixtures/setup_py')
[   49s] 
[   49s]     def test_ast_parser_handles_repeated_assignments(setup_py_dir):
[   49s]         target = setup_py_dir.joinpath(
[   49s]             "package_with_repeated_assignments/setup.py"
[   49s]         ).as_posix()
[   49s]         parsed = ast_parse_setup_py(target)
[   49s]         analyzer = ast_parse_file(target)
[   49s]         assert parsed["name"] == "test_package_with_repeated_assignments"
[   49s] >       assert isinstance(parsed["version"], str) is False
[   49s] E       AssertionError: assert True is False
[   49s] E        +  where True = isinstance('os.environ', str)
[   49s] 
[   49s] tests/unit/test_setup_info.py:269: AssertionError

[   49s] _ test_ast_parser_handles_dependency_on_env_vars[env_vars1-expected_install_requires1] _
[   49s] 
[   49s] env_vars = {'READTHEDOCS': '1'}
[   49s] expected_install_requires = ['sphinx', 'sphinx-argparse']
[   49s] setup_py_dir = PosixPath('/home/abuild/rpmbuild/BUILD/requirementslib-1.5.16/tests/fixtures/setup_py')
[   49s] 
[   49s]     @pytest.mark.parametrize(
[   49s]         "env_vars, expected_install_requires",
[   49s]         [
[   49s]             ({"NOTHING": "1"}, []),
[   49s]             ({"READTHEDOCS": "1"}, ["sphinx", "sphinx-argparse"]),
[   49s]         ],
[   49s]     )
[   49s]     def test_ast_parser_handles_dependency_on_env_vars(
[   49s]         env_vars, expected_install_requires, setup_py_dir
[   49s]     ):
[   49s]         @contextlib.contextmanager
[   49s]         def modified_environ(**update):
[   49s]             env = os.environ
[   49s]             try:
[   49s]                 env.update(update)
[   49s]                 yield
[   49s]             finally:
[   49s]                 [env.pop(k) for k in update]
[   49s]     
[   49s]         with modified_environ(**env_vars):
[   49s]             parsed = ast_parse_setup_py(
[   49s]                 setup_py_dir.joinpath(
[   49s]                     "package_with_dependence_on_env_vars/setup.py"
[   49s]                 ).as_posix()
[   49s]             )
[   49s] >           assert list(sorted(parsed["install_requires"])) == list(
[   49s]                 sorted(expected_install_requires)
[   49s]             )
[   49s] E           AssertionError: assert ['docs'] == ['sphinx', 'sphinx-argparse']
[   49s] E             At index 0 diff: 'docs' != 'sphinx'
[   49s] E             Right contains one more item: 'sphinx-argparse'
[   49s] E             Use -v to get the full diff
[   49s] 
[   49s] tests/unit/test_setup_info.py:327: AssertionError

install_requires=extras_require["docs"] if "READTHEDOCS" in os.environ else [],

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Mar 24, 2021
https://build.opensuse.org/request/show/880607
by user bnavigator + dimstar_suse
- Don't test requirementslib on python39. Isort calls it a
  "deprecated finder" anyway. Colorama needs to be pulled in
  seperately then. gh#sarugaku/requirementslib#288
- Update to version 5.8.0
  * Fixed #1631: as import comments can in some cases be
    duplicated.
  * Fixed #1667: extra newline added with float-to-top, after
    skip, in some cases.
  * Fixed #1594: incorrect placement of noqa comments with
    multiple from imports.
  * Fixed #1566: in some cases different length limits for dos
    based line endings.
  * Implemented #1648: Export MyPY type hints.
  * Implemented #1641: Identified import statements now return
    runnable code.
  * Implemented #1661: Added "wemake" profile.
  * Implemented #1669: Parallel (-j) now defaults to number of CPU
    cores if no value is pro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant