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 new syntax in 3.10 #76

Open
alexmojaki opened this issue Dec 5, 2021 · 2 comments
Open

Test new syntax in 3.10 #76

alexmojaki opened this issue Dec 5, 2021 · 2 comments

Comments

@alexmojaki
Copy link
Contributor

https://docs.python.org/3/whatsnew/3.10.html

  • Pattern matching. One quick way is to add this so that test_sys_modules tests it:
      try:
        import test.test_patma
      except ImportError:
        pass

This works, which suggests that no fixes are needed. Slightly less crude would be making a proper fixture file. Obviously a targeted test would be ideal.

  • Parenthesised context managers.
@alexmojaki
Copy link
Contributor Author

ast.match_case nodes don't have lineno/col_offset, so ASTText doesn't support them, but ASTTokens does:

import ast
import asttokens

source = """
match foo:
    case bar:
        print(spam)
"""

atext = asttokens.ASTText(source)
print(ast.dump(atext.tree, include_attributes=True, indent=4))

match_case = atext.tree.body[0].cases[0]
assert atext.get_text(match_case) == ''
assert atext.asttokens.get_text(match_case) == """\
    case bar:
        print(spam)"""

@alexmojaki
Copy link
Contributor Author

Added a bit of testing in #102 but didn't check all the match-related AST nodes and didn't address the above.

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

No branches or pull requests

1 participant