aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/importlib/test/source/test_file_loader.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/importlib/test/source/test_file_loader.py')
-rw-r--r--Lib/importlib/test/source/test_file_loader.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/importlib/test/source/test_file_loader.py b/Lib/importlib/test/source/test_file_loader.py
index 0a85bc43a2f..ce6f5d47a31 100644
--- a/Lib/importlib/test/source/test_file_loader.py
+++ b/Lib/importlib/test/source/test_file_loader.py
@@ -1,6 +1,7 @@
import importlib
from importlib import _bootstrap
from .. import abc
+from .. import util
from . import util as source_util
import imp
@@ -108,6 +109,22 @@ class SimpleTest(unittest.TestCase):
loader.load_module('_temp')
self.assertTrue('_temp' not in sys.modules)
+ def test_file_from_empty_string_dir(self):
+ # Loading a module found from an empty string entry on sys.path should
+ # not only work, but keep all attributes relative.
+ with open('_temp.py', 'w') as file:
+ file.write("# test file for importlib")
+ try:
+ with util.uncache('_temp'):
+ loader = _bootstrap._SourceFileLoader('_temp', '_temp.py')
+ mod = loader.load_module('_temp')
+ self.assertEqual('_temp.py', mod.__file__)
+ self.assertEqual(imp.cache_from_source('_temp.py'),
+ mod.__cached__)
+
+ finally:
+ os.unlink('_temp.py')
+
class BadBytecodeTest(unittest.TestCase):