summaryrefslogtreecommitdiff
path: root/tests/basics
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-08-30 21:29:23 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-08-30 21:29:23 +0300
commitb565c36963178817fedec4971c6719ea96987c71 (patch)
tree1a870cbe03ae12c5d6fc81db5d3361394b5dda29 /tests/basics
parentdf6605eaba1b07a8e95349b0b8fb8dec9a13fa36 (diff)
tests/object_new: Better messages, check user __new__() method.
Make messages more verbose and easier to follow and check that user class' __new__() is not called by object.__new__(user_class).
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: