cpython/Lib/importlib/test
Brett Cannon f23e374441 Implement importlib.abc.SourceLoader and deprecate PyLoader and PyPycLoader.
SourceLoader is a simplification of both PyLoader and PyPycLoader. If one only
wants to use source, then they need to only implement get_data and
get_filename. To also use bytecode -- sourceless loading is not supported --
then two abstract methods -- path_mtime and set_data -- need to be implemented.
Compared to PyLoader and PyPycLoader, there are less abstract methods
introduced and bytecode files become an optimization controlled by the ABC and
hidden from the user (this need came about as PEP 3147 showed that not treating
bytecode as an optimization can cause problems for compatibility).

PyLoader is deprecated in favor of SourceLoader. To be compatible from Python
3.1 onwards, a subclass need only use simple methods for source_path and
is_package. Otherwise conditional subclassing based on whether Python 3.1 or
Python 3.2 is being is the only change. The documentation and docstring for
PyLoader explain what is exactly needed.

PyPycLoader is deprecated also in favor of SourceLoader. Because PEP 3147
shifted bytecode path details so much, there is no foolproof way to provide
backwards-compatibility with SourceLoader. Because of this the class is simply
deprecated and users should move to SourceLoader (and optionally PyLoader for
Python 3.1). This does lead to a loss of support for sourceless loading
unfortunately.

At some point before Python 3.2 is released, SourceLoader will be moved over to
importlib._bootstrap so that the core code of importlib relies on the new code
instead of the old PyPycLoader code. This commit is being done now so that
there is no issue in having the API in Python 3.1a1.
2010-06-27 23:57:46 +00:00
..
builtin Move over to using assertRaises as a context manager for importlib tests. 2009-08-27 23:49:21 +00:00
extension Move over to using assertRaises as a context manager for importlib tests. 2009-08-27 23:49:21 +00:00
frozen Move over to using assertRaises as a context manager for importlib tests. 2009-08-27 23:49:21 +00:00
import_ Trying to import a submodule from another module and not a package was raising 2009-08-30 20:22:21 +00:00
source Implement importlib.abc.SourceLoader and deprecate PyLoader and PyPycLoader. 2010-06-27 23:57:46 +00:00
__init__.py Importlib was using custom code to discover all test modules in importlib.test. 2009-07-15 04:08:33 +00:00
__main__.py Remove unnecessary XXX 2010-04-17 00:31:11 +00:00
abc.py Introduce importlib.abc. The module contains various ABCs related to imports 2009-03-09 03:35:50 +00:00
benchmark.py Rework importlib benchmarks so that they measure number of executions within a 2009-09-03 20:45:21 +00:00
regrtest.py Clarify why test_import is failing under importlib. 2009-08-30 23:41:40 +00:00
test_abc.py Implement the PEP 302 protocol for get_filename() as 2009-07-20 04:23:48 +00:00
test_api.py Move over to using assertRaises as a context manager for importlib tests. 2009-08-27 23:49:21 +00:00
test_util.py Move over to assertIs. 2010-06-21 02:49:35 +00:00
util.py Remove custom test-skipping code in importlib tests for unittest code. 2009-07-20 01:05:40 +00:00