mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
Update dir tests
This commit is contained in:
parent
a7d83934c1
commit
a156aaa81c
@ -51,19 +51,18 @@ assert not all([False, False])
|
|||||||
assert list(enumerate([1,2,3])) == [(0,1), (1,2), (2,3)]
|
assert list(enumerate([1,2,3])) == [(0,1), (1,2), (2,3)]
|
||||||
assert list(enumerate([1,2,3], 1)) == [(1,1), (2,2), (3,3)]
|
assert list(enumerate([1,2,3], 1)) == [(1,1), (2,2), (3,3)]
|
||||||
|
|
||||||
class C1:
|
assert "__name__" in dir()
|
||||||
def c(): ...
|
|
||||||
|
|
||||||
class C2(C1):
|
class Base:
|
||||||
a = 'a'
|
def inherited(): ...
|
||||||
|
|
||||||
|
class Test(Base):
|
||||||
|
cls_attr = 'a'
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.b = 1
|
self.self_attr = 1
|
||||||
|
assert {"self_attr", "cls_attr", "inherited"}.issubset(dir(Test()))
|
||||||
|
|
||||||
class C3:
|
class CustomDir:
|
||||||
def __dir__(self):
|
def __dir__(self):
|
||||||
return ["custom"]
|
return ["custom"]
|
||||||
|
assert ["custom"] == dir(CustomDir())
|
||||||
assert "__name__" in dir()
|
|
||||||
assert "a", "b" in dir(C2())
|
|
||||||
assert "c" in dir(C2())
|
|
||||||
assert ["custom"] == dir(C3())
|
|
Loading…
x
Reference in New Issue
Block a user