summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2011-12-15 04:53:13 (GMT)
committerMeador Inge <meadori@gmail.com>2011-12-15 04:53:13 (GMT)
commit96ff0840b68a9568d859a7bef2f59e851f811ae3 (patch)
tree9e808bed9b13b385a8fe23ca216dfbc54a217b06 /Lib
parentc2f9874280006d0567797ba49e6575edcd9a56a3 (diff)
downloadcpython-96ff0840b68a9568d859a7bef2f59e851f811ae3.zip
cpython-96ff0840b68a9568d859a7bef2f59e851f811ae3.tar.gz
cpython-96ff0840b68a9568d859a7bef2f59e851f811ae3.tar.bz2
Issue #13593: updating the importlib utility decorators for __qualname__.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/importlib/_bootstrap.py2
-rw-r--r--Lib/importlib/test/test_util.py10
2 files changed, 11 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 25533fc..520c10a 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -111,7 +111,7 @@ def _write_atomic(path, data):
def _wrap(new, old):
"""Simple substitute for functools.wraps."""
- for replace in ['__module__', '__name__', '__doc__']:
+ for replace in ['__module__', '__name__', '__qualname__', '__doc__']:
setattr(new, replace, getattr(old, replace))
new.__dict__.update(old.__dict__)
diff --git a/Lib/importlib/test/test_util.py b/Lib/importlib/test/test_util.py
index 602447f..c7cdad1 100644
--- a/Lib/importlib/test/test_util.py
+++ b/Lib/importlib/test/test_util.py
@@ -59,6 +59,11 @@ class ModuleForLoaderTests(unittest.TestCase):
self.raise_exception(name)
self.assertIs(module, sys.modules[name])
+ def test_decorator_attrs(self):
+ def fxn(self, module): pass
+ wrapped = util.module_for_loader(fxn)
+ self.assertEqual(wrapped.__name__, fxn.__name__)
+ self.assertEqual(wrapped.__qualname__, fxn.__qualname__)
class SetPackageTests(unittest.TestCase):
@@ -108,6 +113,11 @@ class SetPackageTests(unittest.TestCase):
module.__package__ = value
self.verify(module, value)
+ def test_decorator_attrs(self):
+ def fxn(module): pass
+ wrapped = util.set_package(fxn)
+ self.assertEqual(wrapped.__name__, fxn.__name__)
+ self.assertEqual(wrapped.__qualname__, fxn.__qualname__)
def test_main():
from test import support