summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2015-03-16 15:26:20 +0100
committerMichele Simionato <michele.simionato@gmail.com>2015-03-16 15:26:20 +0100
commitcbc46b5c31e82cdf06336f8aa96527bb0b33dfd2 (patch)
treee558d7fed5459692e19db548e7fc18c20a047788
parent6f3bf75e285f6632d5be0201d090ea158f18ad7c (diff)
downloadpython-decorator-git-cbc46b5c31e82cdf06336f8aa96527bb0b33dfd2.tar.gz
Added a script test.py working both with Python 2 and 3
-rw-r--r--.travis.yml4
-rw-r--r--CHANGES.txt5
-rw-r--r--README.rst8
-rw-r--r--documentation.py7
-rw-r--r--documentation3.py8
-rw-r--r--test.py17
6 files changed, 25 insertions, 24 deletions
diff --git a/.travis.yml b/.travis.yml
index d632586..7a437a2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,9 +2,11 @@ language: python
python:
- "2.7"
+ - "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..3a6c1fc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,8 +1,9 @@
HISTORY
----------
-3.4.1 Ported the repository from GoogleCode to GitHub.
- setuptools is made mandatory in Python 3, and now the suggested
+3.4.1 Ported the repository from GoogleCode to GitHub and added Travis CI
+ support. Tests are now run with the 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)
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 0aab054..4825fa8 100644
--- a/documentation.py
+++ b/documentation.py
@@ -1043,7 +1043,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!
@@ -1146,8 +1146,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 92adac8..dea3821 100644
--- a/documentation3.py
+++ b/documentation3.py
@@ -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/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)