summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2015-03-16 16:19:29 +0100
committerMichele Simionato <michele.simionato@gmail.com>2015-03-16 16:19:29 +0100
commit0a949e970b90c502607daf091feda8b0e3e84a8c (patch)
tree66640cd68b7c6b165f5491db25ff7cdd90d60585
parentfbb573305de8a4b464640fe1251b51bc8b6378f8 (diff)
parent4dbca25bb139bead4221ab19eade93cfd7ce16ea (diff)
downloadpython-decorator-git-0a949e970b90c502607daf091feda8b0e3e84a8c.tar.gz
Merge branch '3.4.1'
-rw-r--r--.travis.yml5
-rw-r--r--CHANGES.txt7
-rw-r--r--README.rst8
-rw-r--r--documentation.py15
-rw-r--r--documentation3.py12
-rw-r--r--src/decorator.py2
-rw-r--r--test.py17
7 files changed, 33 insertions, 33 deletions
diff --git a/.travis.yml b/.travis.yml
index d632586..62c5eb8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,9 +2,12 @@ language: python
python:
- "2.7"
+ - "3.2"
+ - "3.3"
+ - "3.4"
install:
- python setup.py install
script:
- python documentation.py
+ python test.py -v
diff --git a/CHANGES.txt b/CHANGES.txt
index e4d9010..5595fb6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,9 +1,10 @@
HISTORY
----------
-3.4.1 Ported the repository from GoogleCode to GitHub.
- setuptools is made mandatory in Python 3, and now the suggested
- installation tool is pip, not easy_install. Supported IronPython
+3.4.1 Ported the repository from GoogleCode to GitHub and added Travis CI
+ support. Tests are executed with the new command `python test.py -v`.
+ setuptools is now mandatory in Python 3. The suggested
+ installation tool is `pip`, not `easy_install`. Supported IronPython
and other Python implementations without sys._getframe, as requested by
Doug Blank (2015/03/16)
3.4.0 Added the ability to use classes and generic callables as callers and
diff --git a/README.rst b/README.rst
index bd8fd44..1457395 100644
--- a/README.rst
+++ b/README.rst
@@ -30,13 +30,9 @@ in the main directory, possibly as superuser.
Testing
--------
-For Python 2.5, 2.6, 2.7 run
+Run
- `$ python documentation.py`
-
-for Python 3.X run
-
- `$ python3 documentation3.py`
+ `$ python test.py`
You will see a few innocuous errors with Python 2.5, because some
inner details such as the introduction of the ArgSpec namedtuple and
diff --git a/documentation.py b/documentation.py
index 1548b5c..9f5c111 100644
--- a/documentation.py
+++ b/documentation.py
@@ -780,9 +780,7 @@ you will get a ``NameError``:
Finally, the implementation is such that the decorated function
attribute ``.func_globals`` is a *copy* of the original function
-attribute. On the other hand the function attribute dictionary
-of the decorated function is just a reference to the
-original function dictionary, i.e. ``vars(decorated_f) is vars(f)``:
+attribute, just as the attribute dictionary of the decorated function.
.. code-block:: python
@@ -795,8 +793,8 @@ original function dictionary, i.e. ``vars(decorated_f) is vars(f)``:
>>> traced_f.attr1
'something'
>>> traced_f.attr2 = "something different" # setting attr
- >>> f.attr2 # the original attribute did change
- 'something different'
+ >>> f.attr2 # the original attribute did not change
+ 'something else'
Compatibility notes
---------------------------------------------------------------
@@ -1044,7 +1042,7 @@ class Action(object):
"""
>>> a = Action()
>>> a.view() # ok
- >>> a.insert() # err
+ >>> a.insert() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
PermissionError: User does not have the permission to run insert!
@@ -1147,8 +1145,3 @@ def hello(user):
AFTER
"""
print('hello %s' % user)
-
-if __name__ == '__main__':
- import doctest
- err = doctest.testmod()[0]
- sys.exit(err)
diff --git a/documentation3.py b/documentation3.py
index 5be0cca..dea3821 100644
--- a/documentation3.py
+++ b/documentation3.py
@@ -788,8 +788,8 @@ the original function dictionary:
>>> traced_f.attr1
'something'
>>> traced_f.attr2 = "something different" # setting attr
- >>> f.attr2 # the original attribute did change, works in Python 3.4
- 'something different'
+ >>> f.attr2 # the original attribute did not change
+ 'something else'
Compatibility notes
---------------------------------------------------------------
@@ -1062,11 +1062,10 @@ class Action(object):
"""
>>> a = Action()
>>> a.view() # ok
- >>> a.insert() # err
+ >>> a.insert() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
PermissionError: User does not have the permission to run insert!
-
"""
@restricted(User)
def view(self):
@@ -1207,8 +1206,3 @@ def hello(user):
AFTER
"""
print('hello %s' % user)
-
-if __name__ == '__main__':
- import doctest
- err = doctest.testmod()[0]
- sys.exit(err)
diff --git a/src/decorator.py b/src/decorator.py
index 4ed7247..ece2488 100644
--- a/src/decorator.py
+++ b/src/decorator.py
@@ -111,7 +111,7 @@ class FunctionMaker(object):
allshortargs.append('**' + self.varkw)
self.signature = ', '.join(allargs)
self.shortsignature = ', '.join(allshortargs)
- self.dict = func.__dict__
+ self.dict = func.__dict__.copy()
# func=None happens when decorating a caller
if name:
self.name = name
diff --git a/test.py b/test.py
index 460c36a..ed9873b 100644
--- a/test.py
+++ b/test.py
@@ -3,32 +3,45 @@ Some simple tests
"""
import os
+import sys
+import doctest
from decorator import decorator
+
@decorator
def identity(f, *a, **k):
"do nothing decorator"
return f(*a, **k)
+
@identity
def f1():
"f1"
+
def getfname(func):
fname = os.path.basename(func.__globals__['__file__'])
return os.path.splitext(fname)[0] + '.py'
+
def test0():
this = getfname(identity)
assert this == 'test.py', this
- print(identity.__doc__)
+
def test1():
this = getfname(f1)
assert this == 'test.py', this
- print(f1.__doc__)
if __name__ == '__main__':
for name, test in list(globals().items()):
if name.startswith('test'):
test()
+
+ if sys.version >= '3':
+ import documentation3 as doc
+ else:
+ import documentation as doc
+
+ err = doctest.testmod(doc)[0]
+ sys.exit(err)