summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-08-30 19:08:58 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-08-30 19:08:58 (GMT)
commit6afbaef2fd439e9c6a9269f07309f8bb91255fd3 (patch)
tree972dcd115b44fcaa6aa27ab176cb104a6459e620 /Lib/importlib/test
parent44b28a9f328f5688ceb774670a6db030fa54d5a3 (diff)
downloadcpython-6afbaef2fd439e9c6a9269f07309f8bb91255fd3.zip
cpython-6afbaef2fd439e9c6a9269f07309f8bb91255fd3.tar.gz
cpython-6afbaef2fd439e9c6a9269f07309f8bb91255fd3.tar.bz2
Raise TypeError if the name given to importlib.__import__() lacks an rpartition
attribute. Was throwing AttributeError before. Discovered when running test_builtin against importlib. This exception change is specific to importlib.__import__() and does not apply to import_module() as it is being done for compatibility reasons only.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r--Lib/importlib/test/import_/test_api.py22
-rw-r--r--Lib/importlib/test/regrtest.py1
2 files changed, 22 insertions, 1 deletions
diff --git a/Lib/importlib/test/import_/test_api.py b/Lib/importlib/test/import_/test_api.py
new file mode 100644
index 0000000..9075d42
--- /dev/null
+++ b/Lib/importlib/test/import_/test_api.py
@@ -0,0 +1,22 @@
+from . import util
+import unittest
+
+
+class APITest(unittest.TestCase):
+
+ """Test API-specific details for __import__ (e.g. raising the right
+ exception when passing in an int for the module name)."""
+
+ def test_name_requires_rparition(self):
+ # Raise TypeError if a non-string is passed in for the module name.
+ with self.assertRaises(TypeError):
+ util.import_(42)
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(APITest)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/regrtest.py b/Lib/importlib/test/regrtest.py
index 17e7f4e..aedc338 100644
--- a/Lib/importlib/test/regrtest.py
+++ b/Lib/importlib/test/regrtest.py
@@ -6,7 +6,6 @@ Otherwise all command-line options valid for test.regrtest are also valid for
this script.
XXX FAILING
- test_builtin # Wanting a TypeError for an integer name
test_import # execution bit, exception name differing, file name differing
between code and module (?)
test_importhooks # package not set in _gcd_import() but level > 0