forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-rhino-8.x' into rhino-8.x
- Loading branch information
Showing
12 changed files
with
493 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import System | ||
BASE = System.Object | ||
IBASE = System.Collections.IEnumerable | ||
|
||
|
||
class S1(BASE): | ||
def __getattr__(self, name): | ||
return super().__getattr__(name) | ||
|
||
def __getattr__(self, name): | ||
if name == 'answer1': | ||
return 1 | ||
return super().__getattr__(name) | ||
|
||
|
||
class S2(S1): | ||
def __getattr__(self, name): | ||
if name == 'answer2': | ||
return 2 | ||
return super().__getattr__(name) | ||
|
||
|
||
class S3(S2): | ||
def __getattr__(self, name): | ||
if name == 'answer3': | ||
return 3 | ||
return super().__getattr__(name) | ||
|
||
|
||
|
||
def test_method_getattr(): | ||
s1 = S1() | ||
assert s1.answer1 == 1 | ||
try: | ||
assert s1.answer2 == 2 | ||
except AttributeError: | ||
pass | ||
|
||
s2 = S2() | ||
assert s2.answer1 == 1 | ||
assert s2.answer2 == 2 | ||
|
||
s3 = S3() | ||
assert s2.answer1 == 1 | ||
assert s2.answer2 == 2 | ||
assert s3.answer3 == 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import System | ||
BASE = System.Object | ||
IBASE = System.Collections.IEnumerable | ||
|
||
|
||
class S1(BASE): | ||
def __getattribute__(self, name): | ||
return super().__getattribute__(name) | ||
|
||
def __getattr__(self, name): | ||
if name == 'answer1': | ||
return 1 | ||
return super().__getattr__(name) | ||
|
||
|
||
class S2(S1): | ||
def __getattribute__(self, name): | ||
if name == 'answer2': | ||
return 2 | ||
return super().__getattribute__(name) | ||
|
||
|
||
class S3(S2): | ||
def __getattr__(self, name): | ||
if name == 'answer3': | ||
return 3 | ||
return super().__getattr__(name) | ||
|
||
|
||
def test_method_getattr_mix(): | ||
s1 = S1() | ||
assert s1.answer1 == 1 | ||
try: | ||
assert s1.answer2 == 2 | ||
except AttributeError: | ||
pass | ||
|
||
s2 = S2() | ||
assert s2.answer1 == 1 | ||
assert s2.answer2 == 2 | ||
|
||
s3 = S3() | ||
assert s2.answer1 == 1 | ||
assert s2.answer2 == 2 | ||
assert s3.answer3 == 3 |
Oops, something went wrong.