Commit graph

130 commits

Author SHA1 Message Date
Brett Cannon
9e0e1a63c8 Allow importlib.__import__ to accept any iterable for fromlist. Discovered when
running importlib against test___all__.
2009-08-30 18:28:46 +00:00
Brett Cannon
12c3fc9343 Provide module docstrings for the two main test drivers in importlib that
explain what they are for and how to use command-line arguments to tweak
semantics.
2009-08-30 08:39:57 +00:00
Brett Cannon
6cc8310ded Tweak importlib.test.regrtest to only specify the implicit tests to exclude
when running entire test suite. Allows normal command-line arguments normally
given to test.regrtest to work (e.g. specifying a single test).
2009-08-30 08:30:35 +00:00
Brett Cannon
8a1a59f0ec Merged revisions 74584 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r74584 | brett.cannon | 2009-08-29 20:47:36 -0700 (Sat, 29 Aug 2009) | 3 lines

  Have importlib raise ImportError if None is found in sys.modules. This matches
  current import semantics.
........
2009-08-30 04:29:47 +00:00
Brett Cannon
4d75fc1ce9 Have importlib raise ImportError if None is found in sys.modules. This matches
current import semantics.
2009-08-30 03:47:36 +00:00
Brett Cannon
5e129dbc16 Add a test file to importlib that runs regrtest using importlib.__import__.
The file must be run using runpy. Certain tests are currently excluded from
being run as they have known failures based on golden value checks that fail
for various reasons (typically because __loader__ is not expected to be set on
modules). Running the tests with this file does discover some incompatibilites
in importlib that will be fixed in the near future (as noted currently in the
docstring).
2009-08-27 23:52:35 +00:00
Brett Cannon
5c26eaad23 Add support for a --builtin argument to importlib.test to trigger running
import-specific tests with __import__ instead of importlib.
2009-08-27 23:49:56 +00:00
Brett Cannon
2153dc001f Move over to using assertRaises as a context manager for importlib tests.
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.
2009-08-27 23:49:21 +00:00
Brett Cannon
c5951fc996 Make __package__ setting tests specific to importlib. Also move to assertRaises context manager. 2009-08-27 23:46:38 +00:00
Brett Cannon
6d2bb7f5aa Move a test-skipping decorator over to unittest.skipIf. 2009-08-27 23:44:18 +00:00
Georg Brandl
ab91fdef1f Merged revisions 73715 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k

........
  r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line

  convert old fail* assertions to assert*
........
2009-08-13 08:51:18 +00:00
Brett Cannon
6919427e94 Implement the PEP 302 protocol for get_filename() as
importlib.abc.ExecutionLoader. PyLoader now inherits from this ABC instead of
InspectLoader directly. Both PyLoader and PyPycLoader provide concrete
implementations of get_filename in terms of source_path and bytecode_path.
2009-07-20 04:23:48 +00:00
Brett Cannon
2e3155e2fe Merged revisions 74107 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r74107 | brett.cannon | 2009-07-19 20:19:18 -0700 (Sun, 19 Jul 2009) | 8 lines

  Importlib's documentation said that importlib.abc.PyLoader inherited from
  importlib.abc.ResourceLoader, when in fact it did not. Fixed the ABC to inherit
  as documented.

  This does in introduce an backwards-incompatiblity as the code in PyLoader
  already required the single method ResourceLoader defined as an abstract
  method.
........
2009-07-20 03:22:43 +00:00
Brett Cannon
64ef00fa60 Importlib's documentation said that importlib.abc.PyLoader inherited from
importlib.abc.ResourceLoader, when in fact it did not. Fixed the ABC to inherit
as documented.

This doesn't introduce an backwards-incompatiblity as the code in PyLoader
already required the single method ResourceLoader defined as an abstract
method.
2009-07-20 03:19:18 +00:00
Brett Cannon
4dc3193973 Remove custom test-skipping code in importlib tests for unittest code. 2009-07-20 01:05:40 +00:00
Brett Cannon
10e35b30fb Backport of r74103. 2009-07-20 00:19:49 +00:00
Brett Cannon
3c2738488a Some tests in importlib.test.source.test_abc_loader were testing what happens
when a loader is given missing or bad code object bytecode. Unfortunately an
exception related to source paths was masking what the proper exception to test
should be. Making the test explicitly set the environment fixed the test.

The code being test was not affected.
2009-07-20 00:14:29 +00:00
Brett Cannon
0a49c58fb0 Update importlib.test.source.test_abc_loader to new features added in Python 3.1. 2009-07-19 23:43:45 +00:00
Brett Cannon
b49c70c7d3 Importlib was using custom code to discover all test modules in importlib.test.
This has now been removed in favor of using unittest's test discovery code in
TestLoader.discover().
2009-07-15 04:08:33 +00:00
R. David Murray
9b2611ee40 Remove unused import for function that no longer exists. 2009-07-01 02:51:00 +00:00
Benjamin Peterson
c9c0f201fe convert old fail* assertions to assert* 2009-06-30 23:06:06 +00:00
Raymond Hettinger
554290d920 Fixup/simplify another nested context manager. 2009-06-12 11:25:59 +00:00
Brett Cannon
1262e7c746 Tests for case-senstivity were not being skipped for darwin when installed on a
case-sensitive filesystems -- which is not the default case. Along the way also
fixed the skipping of tests when sys.dont_write_bytecode is true.

Closes issue #5442 again.
2009-05-11 01:47:11 +00:00
Benjamin Peterson
3c33b833dd fix name again 2009-04-04 01:21:56 +00:00
Benjamin Peterson
3e0c9176fe fix name 2009-04-04 00:46:15 +00:00
Benjamin Peterson
309633db08 fix naming 2009-04-03 23:47:26 +00:00
Benjamin Peterson
8d55a9e8dd os.path.listdir -> os.listdir 2009-04-03 22:23:43 +00:00
Brett Cannon
5561982b64 importlib.test.source.test_abc_loader was making a bad assumption that all file
paths used '/' as a path separator.

Fixes issue #5646.
2009-04-02 17:54:43 +00:00
Brett Cannon
f86213f6f2 Make a test in importlib have a more robust test value. 2009-04-02 15:35:09 +00:00
Brett Cannon
978259e9b3 Give a more informative message on an importlib test upon failure. 2009-04-02 15:32:07 +00:00
Brett Cannon
a3d056ed95 Check that on a platform that is expected to have a case-insensitive filesystem
that is in fact the case.

Closes issue #5442.
2009-04-02 05:17:54 +00:00
Brett Cannon
8593a75688 Fix importlib.machinery.PathFinder.find_module() to essentially skip over None
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.
2009-03-30 19:57:15 +00:00
Brett Cannon
6ae7a7d13d Add simple tests for __import__ for future optimizations to importlib. 2009-03-30 15:53:01 +00:00
Brett Cannon
8d11013169 Implement InspectLoader for FrozenImporter. 2009-03-15 02:20:16 +00:00
Brett Cannon
a113ac58be Implement InspectLoader for BuiltinImporter. 2009-03-15 01:41:33 +00:00
Brett Cannon
7aa21f75c1 A few more docstring/API cleanups for importlib. 2009-03-15 00:53:05 +00:00
Brett Cannon
f87e04d339 Finish properly hiding importlib implementation code. 2009-03-12 22:47:53 +00:00
Brett Cannon
2cf03a8204 Implement importlib.util.set_loader: a decorator to automatically set
__loader__ on modules.
2009-03-10 05:17:37 +00:00
Brett Cannon
d43b30b046 Implement get_source for importlib.abc.PyLoader using source_path and get_data. 2009-03-10 03:29:23 +00:00
Brett Cannon
2a922ed6ad Introduce importlib.abc. The module contains various ABCs related to imports
(mostly stuff specified by PEP 302). There are two ABCs, PyLoader and
PyPycLoader, which help with implementing source and source/bytecode loaders by
implementing load_module in terms of other methods. This removes a lot of
gritty details loaders typically have to worry about.
2009-03-09 03:35:50 +00:00
Brett Cannon
ba3fcf17c8 Remove a dead XXX comment. 2009-03-09 01:58:13 +00:00
Brett Cannon
f2b55fb5ee Make importlib.test.source.util.write_bytecode reset sys.dont_write_bytecode. 2009-03-09 00:02:01 +00:00
Brett Cannon
79925fdbfe Skip case-sensitivity tests for extension modules if _testcapi cannot be found. 2009-03-08 20:50:32 +00:00
Brett Cannon
435aad878c Rename importlib.util.set___package__ to set_package. 2009-03-04 16:07:00 +00:00
Brett Cannon
b5f03c6779 Add a test for importlib.import_module. 2009-03-04 01:02:54 +00:00
Brett Cannon
57b46f5b0e Expose importlib.util.set___package__. 2009-03-02 14:38:26 +00:00
Brett Cannon
91cf882b36 Refactor source and bytecode file loaders in importlib so that there
are source-only and source/bytecode loaders.
2009-02-21 05:41:15 +00:00
Brett Cannon
4afab6b30b Separate out finder for source and source/bytecode. 2009-02-21 03:31:35 +00:00
Brett Cannon
2dee597e05 Do some cleanup in importlib:
+ 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.
2009-02-21 03:15:37 +00:00
Brett Cannon
d2e7b33815 Implement the more specific PEP 302 semantics for loaders and what happens upon
load failure in relation to reloads. Also expose
importlib.util.module_for_loader to handle all of the details of this along
with making sure all current loaders behave nicely.
2009-02-17 02:45:03 +00:00