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

Test failure with Python 3.13.0b1 #16

Closed
frenzymadness opened this issue May 13, 2024 · 1 comment · Fixed by #17
Closed

Test failure with Python 3.13.0b1 #16

frenzymadness opened this issue May 13, 2024 · 1 comment · Fixed by #17

Comments

@frenzymadness
Copy link
Contributor

When run with Python 3.13.0b1 the test_sys_modules fails:

==================================== test session starts ====================================
platform linux -- Python 3.13.0b1, pytest-8.2.0, pluggy-1.5.0
cachedir: .tox/py313/.pytest_cache
rootdir: /home/lbalhar/Software/pure_eval
configfile: pyproject.toml
collected 47 items                                                                          

tests/test_core.py ...........3
......
tests/test_getattr_static.py .......................
tests/test_utils.py /usr/lib64/python3.13/importlib/_bootstrap.py
F......

========================================= FAILURES ==========================================
_____________________________________ test_sys_modules ______________________________________

    def test_sys_modules():
        modules = sys_modules_sources()
        if not os.environ.get('PURE_EVAL_SLOW_TESTS'):
            modules = islice(modules, 0, 3)
    
        for filename, source, tree in modules:
            print(filename)
            if not filename.endswith("ast.py"):
>               check_copy_ast_without_context(tree)

tests/test_utils.py:53: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

tree = <ast.Module object at 0x7fb367123fd0>

    def check_copy_ast_without_context(tree):
        tree2 = copy_ast_without_context(tree)
        dump1 = ast.dump(tree)
        dump2 = ast.dump(tree2)
        normalised_dump1 = re.sub(
            r", ctx=(Load|Store|Del)\(\)",
            "",
            dump1
        )
>       assert normalised_dump1 == dump2
E       assert "Module(body=...e__'))]))])])" == "Module(body=...e__'))]))])])"
E         
E         Skipping 4274 identical leading characters in diff, use -v to show
E         - alue=List()), Assign(targets=[Attribute(value=Name(id='self'), attr='_iterating')], value=Call(func=Name(id='set'))), Assign(targets=[Attribute(value=Name(id='self'), attr='data')], value=Dict())]), FunctionDef(name='_commit_removals', args=arguments(args=[arg(arg='self')]), body=[Assign(targets=[Name(id='pop')], value=Attribute(value=Attribute(value=Name(id='self'), attr='_pending_removals'), attr='pop')), Assign(targets=[Name(id='d')], value=Attribute(value=Name(id='self'), attr='data')), While(test=C...
E         
E         ...Full output truncated (4 lines hidden), use '-vv' to show

tests/test_utils.py:65: AssertionError
===================================== warnings summary ======================================

I run it with -s so you can see the filename in the output /usr/lib64/python3.13/importlib/_bootstrap.py. Unfortunately, when run with -vv the output is so long that it's not possible for me to detect the actual differences.

@frenzymadness
Copy link
Contributor Author

So, the difference between normalized_dump1 and dump2 is for example:

78c78
< attr='_pending_removals')], value=List(ctx=Load())), 
---
> attr='_pending_removals')], value=List()),

The re.sub removes ctx.Load() only if it's preceded by , which is not true in all cases. I'm gonna propose a fix for the regular expression.

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