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
Brett Cannon
32732e3fbd
Change importlib.machinery.PathFinder to not have implicit semantics (that's
...
not handled by importlib._bootstrap._DefaultPathFinder).
2009-02-15 05:48:13 +00:00
Brett Cannon
7bf8d4ed4d
Add the missing importlib.test.extension.util.
2009-02-07 02:33:52 +00:00
Brett Cannon
534b2cd176
Factor out helper code from importlib.test.extension.test_path_hook.
2009-02-07 02:06:43 +00:00
Brett Cannon
06c9d96b70
Move importlib completely over to using rpartition and accepting the empty
...
string for top-level modules.
2009-02-07 01:52:25 +00:00
Brett Cannon
d94e558fdc
Move importlib's built-in importer to use rpartition for __package__.
2009-02-07 01:40:19 +00:00
Brett Cannon
eb2e0dd19d
Move importlib's frozen importer over to rpartition for setting __package__.
2009-02-07 01:38:38 +00:00
Brett Cannon
2c318a1390
Rewrite the code implementing __import__ for importlib. Now it is much simpler
...
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).
2009-02-07 01:15:27 +00:00
Brett Cannon
6411aa5dd4
Finish implementing tests for importlib.machinery.PathFinder by testing that
...
implicit hooks are handled properly.
2009-02-06 00:07:49 +00:00
Brett Cannon
1f9bcd38a9
Add tests for using sys.path_hooks by importlib.machinery.PathFinder.
2009-02-05 23:36:02 +00:00
Brett Cannon
48f5c4eec6
Implement test for sys.path_importer_cache having None for
...
importlib.machinery.PathFinder.
2009-02-05 22:02:03 +00:00
Brett Cannon
939ea76b3c
Begin writing tests for importlib.machinery.PathFinder.
2009-02-05 02:53:23 +00:00
Brett Cannon
d720b36248
Move import semantic util code to importlib.test.import_.util.
2009-02-01 04:28:04 +00:00
Brett Cannon
bcb26c53c0
Rename importlib.test.support to importlib.test.util.
2009-02-01 04:00:05 +00:00
Brett Cannon
ae9ad186d0
Do not execute the .pyc/.pyo files as well as the .py files.
2009-02-01 03:51:54 +00:00
Brett Cannon
4ee2cdaf65
Split out support code that is specific to source tests out of
...
importlib.test.support to importlib.test.source.util.
2009-02-01 03:08:31 +00:00
Brett Cannon
30b047dc35
Move source loader tests (including reload tests) over to
...
importlib.test.abc.LoaderTests.
2009-02-01 02:05:11 +00:00
Brett Cannon
223a19d8b1
Fix importlib.machinery.FrozenImporter.load_module() to set __package__
...
properly. Discovered by also moving the loader tests over to
importlib.test.abc.LoaderTests.
2009-02-01 01:34:13 +00:00
Brett Cannon
e70485e7c1
Move extension module loader tests over to importlib.test.abc.LoaderTests.
2009-02-01 00:49:41 +00:00
Brett Cannon
d98a6a014d
Move built-in loader tests to importlib.test.abc.LoaderTests.
2009-02-01 00:37:13 +00:00
Brett Cannon
f254a75176
Merge testing ABCs for importlib into importlib.test.abc.
2009-01-30 00:22:35 +00:00
Brett Cannon
a74ccea968
Initial take on importlib.test.loader_tests.
2009-01-27 02:39:33 +00:00
Brett Cannon
d197a2b136
Move importlib.test.frozen.test_finder over to importlib.test.finder_tests.
2009-01-27 01:44:50 +00:00
Brett Cannon
1d0b43d24e
Move importlib.test.builtin.test_finder over to importlib.test.finder_tests.
2009-01-27 01:41:57 +00:00
Brett Cannon
97c8a07f1d
Make importlib.test.finder_tests an ABC.
2009-01-27 01:34:30 +00:00
Brett Cannon
c49715f682
Move importlib.test.extension.test_finder over to importlib.test.finder_tests.
2009-01-27 01:33:54 +00:00
Brett Cannon
5abdc93eb8
Add importlib.machinery with its first tenants, BuitinImporter and
...
FrozenImporter. Docs forthcoming.
I plan on all finders and loaders (and most likely hooks) to live
in imoprtlib.machinery. Utility stuff will end up in importlib.util.
Higher-level API stuff will stay on imoprtlib directly (e.g. import_module).
2009-01-22 22:43:07 +00:00
Brett Cannon
d994864d54
Remove a debugging print statement that accidentally got left in.
2009-01-19 07:07:58 +00:00
Brett Cannon
2c5c79cfc4
Tests of case-sensitivity were being executed on OSs which did not have a
...
case-insensitive file system, leading to test failures. This was due to using
the TestCase objects directly instead of the guard in the test_main() function.
Move over to a class decorator instead to control if the tests should be run.
2009-01-18 06:55:05 +00:00
Brett Cannon
7044d6b848
Skip over any file or folder that starts with a dot (e.g. .svn).
2009-01-18 00:36:22 +00:00
Brett Cannon
23cbd8a656
Add initial implementation of importlib. See the NOTES files for what is
...
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.
2009-01-18 00:24:28 +00:00