Skip to content

Add more cases to test_patma #106135

@sobolevn

Description

@sobolevn

While anwsering #106133 I've noticed that test_patma does not have tests for some corner-cases:

  1. Case case [x] | x: ... is mentined in https://peps.python.org/pep-0634/#capture-patterns but is never tested, the closest we have to it is case [z] | [1, (0 | 1 as z)] | [z]:, which is not the same
  2. Guards can have side effects according to https://peps.python.org/pep-0634/#guards but it is never tested
  3. Guards are never tested with: mapping patterns, dotted value patterns
  4. In ClassPattern section PEP says: If name_or_attr is not an instance of the builtin type, TypeError is raised. It is never tested in TestTypeErrors
  5. LiteralPattern might have some more expected SyntaxError cases, like using * and /, using three numbers like 0 + 0j + 0
  6. LiteralPattern says: The singleton literals None, True and False are compared using the is operator., but only None is checked

I would like to send a PR with the new test cases.

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions