mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
add proxy2 test
This commit is contained in:
parent
f53f6571bd
commit
9094c13a57
@ -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
|
24
test/python/proxy/proxy2.py
Normal file
24
test/python/proxy/proxy2.py
Normal 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')
|
Loading…
x
Reference in New Issue
Block a user