forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuiltin_object.py
More file actions
34 lines (26 loc) · 883 Bytes
/
builtin_object.py
File metadata and controls
34 lines (26 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class MyObject:
pass
assert not MyObject() == MyObject()
assert MyObject() != MyObject()
myobj = MyObject()
assert myobj == myobj
assert not myobj != myobj
object.__subclasshook__(1) == NotImplemented
assert MyObject().__eq__(MyObject()) == NotImplemented
assert MyObject().__ne__(MyObject()) == NotImplemented
assert MyObject().__lt__(MyObject()) == NotImplemented
assert MyObject().__le__(MyObject()) == NotImplemented
assert MyObject().__gt__(MyObject()) == NotImplemented
assert MyObject().__ge__(MyObject()) == NotImplemented
obj = MyObject()
assert obj.__eq__(obj) is True
assert obj.__ne__(obj) is False
assert not hasattr(obj, "a")
obj.__dict__ = {"a": 1}
assert obj.a == 1
# Value inside the formatter goes through a different path of resolution.
# Check that it still works all the same
d = {
0: "ab",
}
assert "ab ab" == "{k[0]} {vv}".format(k=d, vv=d[0])