summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_imp.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-05-11 18:48:41 (GMT)
committerBrett Cannon <brett@python.org>2012-05-11 18:48:41 (GMT)
commitc049952de76cbcd00e490e48445ed7a50d3dc83a (patch)
tree91d1ff6bffbb8d6c5b04a8bae6b53944eb078335 /Lib/test/test_imp.py
parent0c59b039b86afa9f51c30f7d9f340d9c75984488 (diff)
downloadcpython-c049952de76cbcd00e490e48445ed7a50d3dc83a.zip
cpython-c049952de76cbcd00e490e48445ed7a50d3dc83a.tar.gz
cpython-c049952de76cbcd00e490e48445ed7a50d3dc83a.tar.bz2
Issue #13959: Have
importlib.abc.FileLoader.load_module()/get_filename() and importlib.machinery.ExtensionFileLoader.load_module() have their single argument be optional as the loader's constructor has all the ncessary information. This allows for the deprecation of imp.load_source()/load_compile()/load_package().
Diffstat (limited to 'Lib/test/test_imp.py')
-rw-r--r--Lib/test/test_imp.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 5b285fc..3f419b7 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -1,11 +1,12 @@
import imp
+import importlib
import os
import os.path
import shutil
import sys
-import unittest
from test import support
-import importlib
+import unittest
+import warnings
class LockTests(unittest.TestCase):
@@ -154,18 +155,24 @@ class ImportTests(unittest.TestCase):
mod = imp.load_module(temp_mod_name, file, filename, info)
self.assertEqual(mod.a, 1)
- mod = imp.load_source(temp_mod_name, temp_mod_name + '.py')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore')
+ mod = imp.load_source(temp_mod_name, temp_mod_name + '.py')
self.assertEqual(mod.a, 1)
- mod = imp.load_compiled(
- temp_mod_name, imp.cache_from_source(temp_mod_name + '.py'))
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore')
+ mod = imp.load_compiled(
+ temp_mod_name, imp.cache_from_source(temp_mod_name + '.py'))
self.assertEqual(mod.a, 1)
if not os.path.exists(test_package_name):
os.mkdir(test_package_name)
with open(init_file_name, 'w') as file:
file.write('b = 2\n')
- package = imp.load_package(test_package_name, test_package_name)
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore')
+ package = imp.load_package(test_package_name, test_package_name)
self.assertEqual(package.b, 2)
finally:
del sys.path[0]