summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2014-01-03 05:25:00 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2014-01-03 05:25:00 (GMT)
commitfbc785188db081c3d3940bf4dcd316de28fda066 (patch)
tree8ed41c9c1c664bafe4a88d6c13016861acb6e86b /Lib
parent9dee304205d34a8565f922fdad5b0f89fcff65a5 (diff)
downloadcpython-fbc785188db081c3d3940bf4dcd316de28fda066.zip
cpython-fbc785188db081c3d3940bf4dcd316de28fda066.tar.gz
cpython-fbc785188db081c3d3940bf4dcd316de28fda066.tar.bz2
Issue #20097: Fix bad use of "self" in importlib's WindowsRegistryFinder.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/importlib/_bootstrap.py2
-rw-r--r--Lib/test/test_importlib/test_windows.py29
2 files changed, 30 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index efe62d4..62e25a3 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1406,7 +1406,7 @@ class WindowsRegistryFinder:
@classmethod
def find_module(cls, fullname, path=None):
"""Find module named in the registry."""
- spec = self.find_spec(fullname, path)
+ spec = cls.find_spec(fullname, path)
if spec is not None:
return spec.loader
else:
diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py
new file mode 100644
index 0000000..96b4adc
--- /dev/null
+++ b/Lib/test/test_importlib/test_windows.py
@@ -0,0 +1,29 @@
+from . import util
+frozen_machinery, source_machinery = util.import_importlib('importlib.machinery')
+
+import sys
+import unittest
+
+
+@unittest.skipUnless(sys.platform.startswith('win'), 'requires Windows')
+class WindowsRegistryFinderTests:
+
+ # XXX Need a test that finds the spec via the registry.
+
+ def test_find_spec_missing(self):
+ spec = self.machinery.WindowsRegistryFinder.find_spec('spam')
+ self.assertIs(spec, None)
+
+ def test_find_module_missing(self):
+ loader = self.machinery.WindowsRegistryFinder.find_module('spam')
+ self.assertIs(loader, None)
+
+
+class Frozen_WindowsRegistryFinderTests(WindowsRegistryFinderTests,
+ unittest.TestCase):
+ machinery = frozen_machinery
+
+
+class Source_WindowsRegistryFinderTests(WindowsRegistryFinderTests,
+ unittest.TestCase):
+ machinery = source_machinery