summaryrefslogtreecommitdiff
path: root/test.py
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 /test.py
parent6f3bf75e285f6632d5be0201d090ea158f18ad7c (diff)
downloadpython-decorator-git-cbc46b5c31e82cdf06336f8aa96527bb0b33dfd2.tar.gz
Added a script test.py working both with Python 2 and 3
Diffstat (limited to 'test.py')
-rw-r--r--test.py17
1 files changed, 15 insertions, 2 deletions
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)