10000 gh-94499 Add test for private name mangling in class pattern matching by da-woods · Pull Request #94500 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-94499 Add test for private name mangling in class pattern matching #94500

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

Merged
merged 4 commits into from
Jul 13, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use alternative suggestion for test
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
  • Loading branch information
da-woods and brandtbucher committed Jul 13, 2022
commit 108e2b43ef21b5fb4d4a0013f752c352e97e9873
9 changes: 4 additions & 5 deletions Lib/test/test_patma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2656,18 +2656,17 @@ def get(key, default=None):

def test_patma_249(self):
class C:
pass
__attr = "_C__attr"
class Outer:
__attr = "_Outer__attr"
def f(self, x):
match x:
# looks up __attr, not _C__attr or _Outer__attr
case C(__attr=y):
return y
c = C()
setattr(c, "__attr", 1)
setattr(c, "_Outer__attr", 2)
setattr(c, "_C__attr", 3)
self.assertEqual(Outer().f(c), 1)
c.__attr = "__attr"
self.assertEqual(Outer().f(c), "__attr")


class TestSyntaxErrors(unittest.TestCase):
Expand Down
0