Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ff7f64ca
Commit
ff7f64ca
authored
Dec 11, 2011
by
Meador Inge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13544: Add __qualname__ to functools.WRAPPER_ASSIGNMENTS.
Patch by Filip Gruszczyński.
parent
bf6e560d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
Lib/functools.py
Lib/functools.py
+2
-1
Lib/test/test_functools.py
Lib/test/test_functools.py
+9
-3
No files found.
Lib/functools.py
View file @
ff7f64ca
...
...
@@ -21,7 +21,8 @@ except:
# update_wrapper() and wraps() are tools to help write
# wrapper functions that can handle naive introspection
WRAPPER_ASSIGNMENTS
=
(
'__module__'
,
'__name__'
,
'__doc__'
,
'__annotations__'
)
WRAPPER_ASSIGNMENTS
=
(
'__module__'
,
'__name__'
,
'__qualname__'
,
'__doc__'
,
'__annotations__'
)
WRAPPER_UPDATES
=
(
'__dict__'
,)
def
update_wrapper
(
wrapper
,
wrapped
,
...
...
Lib/test/test_functools.py
View file @
ff7f64ca
...
...
@@ -226,6 +226,7 @@ class TestUpdateWrapper(unittest.TestCase):
self
.
check_wrapper
(
wrapper
,
f
)
self
.
assertIs
(
wrapper
.
__wrapped__
,
f
)
self
.
assertEqual
(
wrapper
.
__name__
,
'f'
)
self
.
assertEqual
(
wrapper
.
__qualname__
,
f
.
__qualname__
)
self
.
assertEqual
(
wrapper
.
attr
,
'This is also a test'
)
self
.
assertEqual
(
wrapper
.
__annotations__
[
'a'
],
'This is a new annotation'
)
self
.
assertNotIn
(
'b'
,
wrapper
.
__annotations__
)
...
...
@@ -246,6 +247,7 @@ class TestUpdateWrapper(unittest.TestCase):
functools
.
update_wrapper
(
wrapper
,
f
,
(),
())
self
.
check_wrapper
(
wrapper
,
f
,
(),
())
self
.
assertEqual
(
wrapper
.
__name__
,
'wrapper'
)
self
.
assertNotEqual
(
wrapper
.
__qualname__
,
f
.
__qualname__
)
self
.
assertEqual
(
wrapper
.
__doc__
,
None
)
self
.
assertEqual
(
wrapper
.
__annotations__
,
{})
self
.
assertFalse
(
hasattr
(
wrapper
,
'attr'
))
...
...
@@ -263,6 +265,7 @@ class TestUpdateWrapper(unittest.TestCase):
functools
.
update_wrapper
(
wrapper
,
f
,
assign
,
update
)
self
.
check_wrapper
(
wrapper
,
f
,
assign
,
update
)
self
.
assertEqual
(
wrapper
.
__name__
,
'wrapper'
)
self
.
assertNotEqual
(
wrapper
.
__qualname__
,
f
.
__qualname__
)
self
.
assertEqual
(
wrapper
.
__doc__
,
None
)
self
.
assertEqual
(
wrapper
.
attr
,
'This is a different test'
)
self
.
assertEqual
(
wrapper
.
dict_attr
,
f
.
dict_attr
)
...
...
@@ -309,17 +312,18 @@ class TestWraps(TestUpdateWrapper):
def
wrapper
():
pass
self
.
check_wrapper
(
wrapper
,
f
)
return
wrapper
return
wrapper
,
f
def
test_default_update
(
self
):
wrapper
=
self
.
_default_update
()
wrapper
,
f
=
self
.
_default_update
()
self
.
assertEqual
(
wrapper
.
__name__
,
'f'
)
self
.
assertEqual
(
wrapper
.
__qualname__
,
f
.
__qualname__
)
self
.
assertEqual
(
wrapper
.
attr
,
'This is also a test'
)
@
unittest
.
skipIf
(
not
sys
.
flags
.
optimize
<=
1
,
"Docstrings are omitted with -O2 and above"
)
def
test_default_update_doc
(
self
):
wrapper
=
self
.
_default_update
()
wrapper
,
_
=
self
.
_default_update
()
self
.
assertEqual
(
wrapper
.
__doc__
,
'This is a test'
)
def
test_no_update
(
self
):
...
...
@@ -332,6 +336,7 @@ class TestWraps(TestUpdateWrapper):
pass
self
.
check_wrapper
(
wrapper
,
f
,
(),
())
self
.
assertEqual
(
wrapper
.
__name__
,
'wrapper'
)
self
.
assertNotEqual
(
wrapper
.
__qualname__
,
f
.
__qualname__
)
self
.
assertEqual
(
wrapper
.
__doc__
,
None
)
self
.
assertFalse
(
hasattr
(
wrapper
,
'attr'
))
...
...
@@ -351,6 +356,7 @@ class TestWraps(TestUpdateWrapper):
pass
self
.
check_wrapper
(
wrapper
,
f
,
assign
,
update
)
self
.
assertEqual
(
wrapper
.
__name__
,
'wrapper'
)
self
.
assertNotEqual
(
wrapper
.
__qualname__
,
f
.
__qualname__
)
self
.
assertEqual
(
wrapper
.
__doc__
,
None
)
self
.
assertEqual
(
wrapper
.
attr
,
'This is a different test'
)
self
.
assertEqual
(
wrapper
.
dict_attr
,
f
.
dict_attr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment