summaryrefslogtreecommitdiff
path: root/tests/functional/n/new_style_class_py_30.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/n/new_style_class_py_30.py')
-rw-r--r--tests/functional/n/new_style_class_py_30.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/functional/n/new_style_class_py_30.py b/tests/functional/n/new_style_class_py_30.py
new file mode 100644
index 000000000..fd78c5590
--- /dev/null
+++ b/tests/functional/n/new_style_class_py_30.py
@@ -0,0 +1,35 @@
+"""check builtin data descriptors such as mode and name attributes on a file are correctly handled
+
+bug notified by Pierre Rouleau on 2005-04-24
+"""
+from __future__ import print_function
+__revision__ = None
+
+
+class File(file): # pylint: disable=file-builtin,undefined-variable
+ """ Testing new-style class inheritance from file"""
+ def __init__(self, name, mode="r", buffering=-1, verbose=False):
+ """Constructor"""
+ self.was_modified = False
+ self.verbose = verbose
+ super(File, self).__init__(name, mode, buffering) # [super-with-arguments]
+ if self.verbose:
+ print("File %s is opened. The mode is: %s" % (self.name,
+ self.mode))
+
+ def write(self, a_string):
+ """ Write a string to the file."""
+ super(File, self).write(a_string) # [super-with-arguments]
+ self.was_modified = True
+
+ def writelines(self, sequence):
+ """ Write a sequence of strings to the file. """
+ super(File, self).writelines(sequence) # [super-with-arguments]
+ self.was_modified = True
+
+ def close(self):
+ """Close the file."""
+ if self.verbose:
+ print("Closing file %s" % self.name)
+ super(File, self).close() # [super-with-arguments]
+ self.was_modified = False