summaryrefslogtreecommitdiff
path: root/tests/basics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/object_new.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/basics/object_new.py b/tests/basics/object_new.py
index a9c9482cb..1bf7bc0ec 100644
--- a/tests/basics/object_new.py
+++ b/tests/basics/object_new.py
@@ -12,6 +12,11 @@ except AttributeError:
class Foo:
+ def __new__(cls):
+ # Should not be called in this test
+ print("in __new__")
+ raise RuntimeError
+
def __init__(self):
print("in __init__")
self.attr = "something"
@@ -19,12 +24,13 @@ class Foo:
o = object.__new__(Foo)
#print(o)
-print(hasattr(o, "attr"))
-print(isinstance(o, Foo))
+print("Result of __new__ has .attr:", hasattr(o, "attr"))
+print("Result of __new__ is already a Foo:", isinstance(o, Foo))
+
o.__init__()
#print(dir(o))
-print(hasattr(o, "attr"))
-print(o.attr)
+print("After __init__ has .attr:", hasattr(o, "attr"))
+print(".attr:", o.attr)
# should only be able to call __new__ on user types
try: