summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2014-02-28 15:44:45 (GMT)
committerBrett Cannon <brett@python.org>2014-02-28 15:44:45 (GMT)
commit298bb967767d666fca8177f8c2352c2134490565 (patch)
treea8e92ef700a9abdfb843d8d7cde40c6382245ac6 /Lib/test
parent815b41b1cdb98686fc3f9cdf995b6983c12c04b3 (diff)
downloadcpython-298bb967767d666fca8177f8c2352c2134490565.zip
cpython-298bb967767d666fca8177f8c2352c2134490565.tar.gz
cpython-298bb967767d666fca8177f8c2352c2134490565.tar.bz2
Issue #20778: Fix modulefinder to work with bytecode-only modules.
Bug filed and initial attempt at a patch by Bohuslav Kabrda.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_modulefinder.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py
index 53ea232..ed30d6f 100644
--- a/Lib/test/test_modulefinder.py
+++ b/Lib/test/test_modulefinder.py
@@ -1,5 +1,7 @@
import os
import errno
+import importlib.machinery
+import py_compile
import shutil
import unittest
import tempfile
@@ -208,6 +210,14 @@ a/module.py
from . import *
"""]
+bytecode_test = [
+ "a",
+ ["a"],
+ [],
+ [],
+ ""
+]
+
def open_file(path):
dirname = os.path.dirname(path)
@@ -288,6 +298,16 @@ class ModuleFinderTest(unittest.TestCase):
def test_relative_imports_4(self):
self._do_test(relative_import_test_4)
+ def test_bytecode(self):
+ base_path = os.path.join(TEST_DIR, 'a')
+ source_path = base_path + importlib.machinery.SOURCE_SUFFIXES[0]
+ bytecode_path = base_path + importlib.machinery.BYTECODE_SUFFIXES[0]
+ with open_file(source_path) as file:
+ file.write('testing_modulefinder = True\n')
+ py_compile.compile(source_path, cfile=bytecode_path)
+ os.remove(source_path)
+ self._do_test(bytecode_test)
+
def test_main():
support.run_unittest(ModuleFinderTest)