Commit Graph

128 Commits

Author SHA1 Message Date
Brett Cannon 23cf5743ae Rework importlib benchmarks so that they measure number of executions within a
second instead of some fixed number.

Keeps benchmark faster by putting a cap on total execution time. Before a run
using importlib took longer by some factor, but now it takes roughly the
same amount of time as using the built-in __import__.
2009-09-03 20:45:21 +00:00
Brett Cannon d95863f6f3 Clarify why test_import is failing under importlib. 2009-08-30 23:41:40 +00:00
Brett Cannon 1c1dcbfd5d Trying to import a submodule from another module and not a package was raising
AttributeError in importlib when it should be an ImportError.

Found when running importlib against test_runpy.
2009-08-30 20:22:21 +00:00
Brett Cannon 82a23fe392 test_pep3120 is no longer a problem for importlib as the test was tweaked. 2009-08-30 20:08:15 +00:00
Brett Cannon de4ebfe559 When the globals argument to importlib.__import__() contained any value for
__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.
2009-08-30 19:53:48 +00:00
Brett Cannon ce7d4cbc3b Turn on verbose2 for importlib.test.regrtest so as to see failures when they occur. 2009-08-30 19:44:32 +00:00
Brett Cannon 6afbaef2fd Raise TypeError if the name given to importlib.__import__() lacks an rpartition
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.
2009-08-30 19:08:58 +00:00
Brett Cannon 44b28a9f32 Fix the importlib_only test decorator to work again; don't capture the flag variable as it might change later. 2009-08-30 18:59:21 +00:00
Brett Cannon a6503606f9 Use the public API, not a private one. 2009-08-30 18:40:23 +00:00
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 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
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 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 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 12e533d7bf Rip out a useless method that the superclass implements properly. 2009-04-01 03:35:20 +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 e43b060b05 Document import's semantics for the language reference. This includes filling
in missing details for the sys module.
2009-03-21 03:11:16 +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 0e0d8a63b1 Clean up docstring from importlib.util.module_for_loader. 2009-03-15 00:00:19 +00:00
Brett Cannon f87e04d339 Finish properly hiding importlib implementation code. 2009-03-12 22:47:53 +00:00
Brett Cannon e9103d2619 Last big re-organization of importlib._bootstrap. Should actually be able to find something in the file now. 2009-03-12 22:37:06 +00:00
Brett Cannon ce43ddfee5 Do a little bit of reorganization on importlib._bootstrap. 2009-03-12 22:28:55 +00:00
Brett Cannon 3eeaa0a821 Make utility code in importlib._bootstrap private. 2009-03-12 22:07:17 +00:00
Brett Cannon 9495f182a0 Define importlib.__init__.__all__. 2009-03-12 22:01:40 +00:00
Brett Cannon c59cd68847 Add a NOTE for importlib to fill in the docstrings for the ABCs. 2009-03-11 05:14:27 +00:00