add proxy2 test

This commit is contained in:
pikastech 2023-04-19 21:18:17 +08:00
parent f53f6571bd
commit 9094c13a57
2 changed files with 26 additions and 0 deletions

View File

@ -2818,6 +2818,8 @@ TEST_RUN_LINES(vm, char_issue4, "=")
TEST_SINGLE_FILE(vm, issue_star_dict, "test/python/issue/issue_star_dict.py")
TEST_SINGLE_FILE_PASS(vm, proxy2, "test/python/proxy/proxy2.py")
#endif
TEST_END

View File

@ -0,0 +1,24 @@
_dict = {}
class TestProxy:
def __getattr__(self, name):
return _dict[name]
def __setattr__(self, name, value):
_dict[name] = value
test = TestProxy()
test.A = 10
assert test.A == 10
class Test:
proxy = TestProxy()
test2 = Test()
test2.proxy.B = 20
assert test2.proxy.B == 20
print('PASS')