summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/import_
Commit message (Collapse)AuthorAgeFilesLines
* Issue #15168: Move importlb.test to test.test_importlib.Brett Cannon2012-07-2010-933/+0
| | | | | This should make the Linux distros happy as it is now easier to leave importlib's tests out of their base Python distribution.
* Issue #15111: When a module was imported using a 'from import'Brett Cannon2012-07-101-14/+3
| | | | | | | statement (e.g. ``from distutils import msvc9compiler``) that triggers an ImportError of its own (e.g. the non-existence of winreg), let that exception propagate instead of raising a generic ImportError for the module being requested (e.g. msvc9compiler).
* Use assertIsNone. Thanks Terry Reedy.Eric V. Smith2012-06-282-2/+2
|
* Changed importlib tests to use assertIs, assertIsInstance, etc., instead of ↵Eric V. Smith2012-06-274-20/+21
| | | | just assertTrue.
* Issue #14583: Fix importlib bug when a package's __init__.py would first ↵Antoine Pitrou2012-05-071-0/+56
| | | | import one of its modules then raise an error.
* Issue #14605: Use None in sys.path_importer_cache to represent noBrett Cannon2012-04-271-23/+5
| | | | finder instead of using some (now non-existent) implicit finder.
* Issue #14605: Stop having implicit entries for sys.meta_path.Brett Cannon2012-04-271-0/+18
| | | | ImportWarning is raised if sys.meta_path is found to be empty.
* Issue #14605: Make explicit the entries on sys.path_hooks that used toBrett Cannon2012-04-262-59/+27
| | | | | | | | | | | | be implicit. Added a warning for when sys.path_hooks is found to be empty. Also changed the meaning of None in sys.path_importer_cache to represent trying sys.path_hooks again (an interpretation of previous semantics). Also added a warning for when None was found. The long-term goal is for None in sys.path_importer_cache to represent the same as imp.NullImporter: no finder found for that sys.path entry.
* rollback 005fd1fe31ab (see #14609 and #14582)Benjamin Peterson2012-04-181-4/+28
| | | | | Being able to overload a sys.module entry during import of a module was broken by this changeset.
* Issue #12599: Be more strict in accepting None vs. a false-like objectBrett Cannon2012-04-181-0/+9
| | | | | | | in importlib. Thanks to PJE for pointing out the issue and Nick Coghlan for filing the bug.
* Issue #14592: A relative import will raise a KeyError if __package__Brett Cannon2012-04-171-0/+5
| | | | | | or __name__ are not set in globals. Thanks to Stefan Behnel for the bug report.
* Issue #14582: Import returns the module returned by a loader insteadBrett Cannon2012-04-151-28/+4
| | | | | | | | | | | | of sys.modules when possible. This is being done for two reasons. One is to gain a little bit of performance by skipping an unnecessary dict lookup in sys.modules. But the other (and main) reason is to be a little bit more clear in how things should work from the perspective of import's interactions with loaders. Otherwise loaders can easily forget to return the module even though PEP 302 explicitly states they are expected to return the module they loaded.
* Handle importing pkg.mod by executingBrett Cannon2012-04-151-0/+9
| | | | | __import__('mod', {'__packaging__': 'pkg', level=1) w/o properly (and thus not segfaulting).
* Issue #2377: Make importlib the implementation of __import__().Brett Cannon2012-04-142-2/+1
| | | | | | | importlib._bootstrap is now frozen into Python/importlib.h and stored as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen code along with sys and imp and then uses _frozen_importlib._install() to set builtins.__import__() w/ _frozen_importlib.__import__().
* Have importlib take advantage of ImportError's new 'name' and 'path'Brett Cannon2012-04-132-3/+6
| | | | attributes.
* Issue #14500: Fix importlib.test.import_.test_packages to clean upBrett Cannon2012-04-061-1/+5
| | | | after itself properly.
* If a module injects something into sys.modules as a side-effect ofBrett Cannon2012-04-031-0/+13
| | | | | | | | importation, then respect that injection. Discovered thanks to Lib/xml/parsers/expat.py injecting xml.parsers.expat.errors and etree now importing that directly as a module.
* Improper type for __package__ should raise TypeError, not ValueError.Brett Cannon2012-02-231-1/+1
|
* Issue #14043: Speed up importlib's _FileFinder by at least 8x, and add a new ↵Antoine Pitrou2012-02-201-2/+2
| | | | | | importlib.invalidate_caches() function. importlib is now often faster than imp.find_module() at finding modules.
* Tweak the handling of the empty string in sys.path for importlib.Brett Cannon2012-02-161-1/+1
| | | | | | | It seems better to cache the finder for the cwd under its full path insetad of '' in case the cwd changes. Otherwise FileFinder needs to dynamically change itself based on whether it is given '' instead of caching a finder for every change to the cwd.
* importlib.__import__() now raises ValueError when level < 0.Brett Cannon2012-02-161-0/+7
| | | | | This is to bring it more in line with what PEP 328 set out to do with removing ambiguous absolute/relative import semantics.
* Use the cwd when the empty string is found in sys.path. This leads toBrett Cannon2012-02-081-0/+10
| | | | | __file__ being an absolute path when the module is found in the current directory.
* #9424: Replace deprecated assert* methods in the Python test suite.Ezio Melotti2010-11-204-23/+23
|
* Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-031-14/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This required moving the class from importlib/abc.py into importlib/_bootstrap.py and jiggering some code to work better with the class. This included changing how the file finder worked to better meet import semantics. This also led to fixing importlib to handle the empty string from sys.path as import currently does (and making me wish we didn't support that instead just required people to insert '.' instead to represent cwd). It also required making the new set_data abstractmethod create any needed subdirectories implicitly thanks to __pycache__ (it was either this or grow the SourceLoader ABC to gain an 'exists' method and either a mkdir method or have set_data with no data arg mean to create a directory). Lastly, as an optimization the file loaders cache the file path where the finder found something to use for loading (this is thanks to having a sourceless loader separate from the source loader to simplify the code and cut out stat calls). Unfortunately test_runpy assumed a loader would always work for a module, even if you changed from underneath it what it was expected to work with. By simply dropping the previous loader in test_runpy so the proper loader can be returned by the finder fixed the failure. At this point importlib deviates from import on two points: 1. The exception raised when trying to import a file is different (import does an explicit file check to print a special message, importlib just says the path cannot be imported as if it was just some module name). 2. the co_filename on a code object is not being set to where bytecode was actually loaded from instead of where the marshalled code object originally came from (a solution for this has already been agreed upon on python-dev but has not been implemented yet; issue8611).
* Trying to import a submodule from another module and not a package was raisingBrett Cannon2009-08-301-0/+6
| | | | | | AttributeError in importlib when it should be an ImportError. Found when running importlib against test_runpy.
* When the globals argument to importlib.__import__() contained any value forBrett Cannon2009-08-301-7/+13
| | | | | | | | __package__, it was used. This was incorrect since it could be set to None to represent the fact that a proper value was unknown. Now None will trigger the calculation for __package__. Discovered when running importlib against test_importhooks.
* Raise TypeError if the name given to importlib.__import__() lacks an rpartitionBrett Cannon2009-08-301-0/+22
| | | | | | | | 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.
* Fix the importlib_only test decorator to work again; don't capture the flag ↵Brett Cannon2009-08-301-1/+3
| | | | variable as it might change later.
* Use the public API, not a private one.Brett Cannon2009-08-301-1/+1
|
* Allow importlib.__import__ to accept any iterable for fromlist. Discovered whenBrett Cannon2009-08-301-2/+9
| | | | running importlib against test___all__.
* Have importlib raise ImportError if None is found in sys.modules. This matchesBrett Cannon2009-08-301-4/+14
| | | | current import semantics.
* Move over to using assertRaises as a context manager for importlib tests.Brett Cannon2009-08-272-7/+10
| | | | | Obviously one shouldn't do whole sale conversions like this, but I was already going through the test code and I was bored at the airport.
* Make __package__ setting tests specific to importlib. Also move to ↵Brett Cannon2009-08-271-4/+5
| | | | assertRaises context manager.
* Move a test-skipping decorator over to unittest.skipIf.Brett Cannon2009-08-271-10/+3
|
* Remove unused import for function that no longer exists.R. David Murray2009-07-011-1/+0
|
* convert old fail* assertions to assert*Benjamin Peterson2009-06-306-31/+31
|
* Fixup/simplify another nested context manager.Raymond Hettinger2009-06-121-6/+3
|
* Fix importlib.machinery.PathFinder.find_module() to essentially skip over NoneBrett Cannon2009-03-301-0/+19
| | | | | | entries in sys.path_importer_cache. While this differs from semantics in how __import__ works, it prevents any implicit semantics from taking hold with users.
* A few more docstring/API cleanups for importlib.Brett Cannon2009-03-151-1/+1
|
* Remove a dead XXX comment.Brett Cannon2009-03-091-1/+0
|
* Do some cleanup in importlib:Brett Cannon2009-02-211-3/+3
| | | | | | | + Ditch using arguments to super(). + Ditch subclassing from object directly. + Move directory check out of chaining path hook to file path hook/finder. + Rename some classes to better reflect they are finders, not importers.
* Change importlib.machinery.PathFinder to not have implicit semantics (that'sBrett Cannon2009-02-152-34/+35
| | | | not handled by importlib._bootstrap._DefaultPathFinder).
* Rewrite the code implementing __import__ for importlib. Now it is much simplerBrett Cannon2009-02-074-148/+9
| | | | | | | | | and relies much more on meta path finders to abstract out various parts of import. As part of this the semantics for import_module tightened up and now follow __import__ much more closely (biggest thing is that the 'package' argument must now already be imported, else a SystemError is raised).
* Finish implementing tests for importlib.machinery.PathFinder by testing thatBrett Cannon2009-02-061-4/+19
| | | | implicit hooks are handled properly.
* Add tests for using sys.path_hooks by importlib.machinery.PathFinder.Brett Cannon2009-02-051-2/+10
|
* Implement test for sys.path_importer_cache having None forBrett Cannon2009-02-051-2/+14
| | | | importlib.machinery.PathFinder.
* Begin writing tests for importlib.machinery.PathFinder.Brett Cannon2009-02-051-1/+57
|
* Move import semantic util code to importlib.test.import_.util.Brett Cannon2009-02-018-56/+99
|
* Rename importlib.test.support to importlib.test.util.Brett Cannon2009-02-017-129/+124
|
* Add initial implementation of importlib. See the NOTES files for what isBrett Cannon2009-01-188-0/+799
planned for the package. There are no docs yet, but they are coming once the API for the first new function, importlib.import_module() is finalized.