summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/source
Commit message (Collapse)AuthorAgeFilesLines
* Issue #13890: Fix importlib case-sensitivity tests to not run on Windows.Brett Cannon2012-01-301-0/+6
| | | | | | | Thanks to os.environ under Windows only updating the dict and not the environment itself (as exposed by nt.environ), tests using PYTHONCASEOK always fail. Now the tests are skipped when os.environ does not do what is expected.
* Move some code from importlib.__init__ to importlib._bootstrap thatBrett Cannon2012-01-251-4/+4
| | | | does not need to be exposed from C code for bootstrapping reasons.
* Port import fixes from 2.7.Antoine Pitrou2012-01-251-1/+1
|\
| * Port import fixes from 2.7.Antoine Pitrou2012-01-251-1/+1
| |
* | Port remaining test fixes, and fix test_importlib too.Antoine Pitrou2012-01-251-1/+9
|\ \ | |/
| * Port remaining test fixes, and fix test_importlib too.Antoine Pitrou2012-01-251-1/+9
| |
* | Issue #11235: Fix OverflowError when trying to import a source file whose ↵Antoine Pitrou2012-01-241-0/+17
|\ \ | |/ | | | | modification time doesn't fit in a 32-bit timestamp.
| * Issue #11235: Fix OverflowError when trying to import a source file whose ↵Antoine Pitrou2012-01-241-0/+17
| | | | | | | | modification time doesn't fit in a 32-bit timestamp.
* | kill useless import added by 87331661042bBenjamin Peterson2012-01-161-1/+0
| |
* | Issue #13645: pyc files now contain the size of the corresponding sourceAntoine Pitrou2012-01-132-15/+39
| | | | | | | | | | code, to avoid timestamp collisions (especially on filesystems with a low timestamp resolution) when checking for freshness of the bytecode.
* | Fix no-op tests in importlib.Antoine Pitrou2011-12-301-0/+4
|\ \ | |/
| * Fix no-op tests in importlib.Antoine Pitrou2011-12-301-0/+4
| |
* | Issue #13248: turn 3.2's PendingDeprecationWarning into 3.3's ↵Florent Xicluna2011-12-101-2/+2
|/ | | | DeprecationWarning (cgi, importlib, nntplib, smtpd).
* Closes #12291: Fixed bug which was found when doing multiple loads from one ↵Vinay Sajip2011-07-021-1/+1
| | | | stream.
* Make sure that no __pycache__ directory is needlessly left behind when testingBrett Cannon2010-08-221-7/+10
| | | | imports with an empty string in sys.path.
* Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-031-25/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-033-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-036-107/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Move importlib.abc.SourceLoader to _bootstrap.Brett Cannon2010-06-281-4/+3
| | | | | | | | | | | Required updating code relying on other modules to switch to _bootstrap's unique module requirements. This led to the realization that get_code was being too liberal in its exception catching when calling set_data by blindly grabbing IOError. Shifted the responsibility of safely ignoring writes to a read-only path to set_data. Importlib is still not relying on SourceLoader yet; requires creating a SourcelessLoader and updating the source finder.
* fix test with more obviously incorrect bytecodeBenjamin Peterson2010-06-281-1/+1
|
* Implement importlib.abc.SourceLoader and deprecate PyLoader and PyPycLoader.Brett Cannon2010-06-271-6/+394
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Repair test failure. Bug 8727.Barry Warsaw2010-05-181-0/+3
|
* PEP 3147Barry Warsaw2010-04-174-14/+29
|
* Importlib was not matching import's handling of .pyc files where it had lessBrett Cannon2010-02-191-24/+99
| | | | | | then 8 bytes total in the file. Fixes issues 7361 & 7875.
* When trying to write new bytecode, importlib was not catching the IOErrorBrett Cannon2009-11-071-0/+26
| | | | | | | thrown if the file happened to be read-only to keep the failure silent. Fixes issue #7187. Thanks, Dave Malcolm for the report and analysis of the problem.
* Use tempfile.mkdtemp() instead of tempfile.tempdir for where importlib placesBrett Cannon2009-11-051-11/+4
| | | | | | | source files for tests. Allows for concurrent execution of the tests by preventing various executions from trampling each other. Closes issue #7248.
* importlib.test.source.util referenced variables in the 'finally' part of aBrett Cannon2009-11-051-2/+6
| | | | try/finally which may not have been set.
* Move over to using assertRaises as a context manager for importlib tests.Brett Cannon2009-08-273-9/+12
| | | | | 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.
* Implement the PEP 302 protocol for get_filename() asBrett Cannon2009-07-201-3/+50
| | | | | | 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.
* Some tests in importlib.test.source.test_abc_loader were testing what happensBrett Cannon2009-07-201-8/+16
| | | | | | | | 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.
* Update importlib.test.source.test_abc_loader to new features added in Python ↵Brett Cannon2009-07-191-17/+19
| | | | 3.1.
* convert old fail* assertions to assert*Benjamin Peterson2009-06-304-24/+24
|
* Tests for case-senstivity were not being skipped for darwin when installed on aBrett Cannon2009-05-114-35/+26
| | | | | | | 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.
* importlib.test.source.test_abc_loader was making a bad assumption that all fileBrett Cannon2009-04-021-16/+21
| | | | | | paths used '/' as a path separator. Fixes issue #5646.
* Make a test in importlib have a more robust test value.Brett Cannon2009-04-021-1/+1
|
* Give a more informative message on an importlib test upon failure.Brett Cannon2009-04-021-1/+3
|
* Finish properly hiding importlib implementation code.Brett Cannon2009-03-125-19/+25
|
* Implement get_source for importlib.abc.PyLoader using source_path and get_data.Brett Cannon2009-03-101-9/+32
|
* Introduce importlib.abc. The module contains various ABCs related to importsBrett Cannon2009-03-093-96/+404
| | | | | | | (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.
* Make importlib.test.source.util.write_bytecode reset sys.dont_write_bytecode.Brett Cannon2009-03-091-1/+5
|
* Refactor source and bytecode file loaders in importlib so that thereBrett Cannon2009-02-212-13/+13
| | | | are source-only and source/bytecode loaders.
* Separate out finder for source and source/bytecode.Brett Cannon2009-02-212-2/+2
|
* Do some cleanup in importlib:Brett Cannon2009-02-213-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.
* Move importlib completely over to using rpartition and accepting the emptyBrett Cannon2009-02-071-1/+1
| | | | string for top-level modules.
* Rename importlib.test.support to importlib.test.util.Brett Cannon2009-02-016-9/+6
|
* Split out support code that is specific to source tests out ofBrett Cannon2009-02-016-30/+123
| | | | importlib.test.support to importlib.test.source.util.
* Move source loader tests (including reload tests) over toBrett Cannon2009-02-012-73/+72
| | | | importlib.test.abc.LoaderTests.
* Merge testing ABCs for importlib into importlib.test.abc.Brett Cannon2009-01-301-2/+2
|
* Tests of case-sensitivity were being executed on OSs which did not have aBrett Cannon2009-01-181-2/+1
| | | | | | 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.
* Add initial implementation of importlib. See the NOTES files for what isBrett Cannon2009-01-187-0/+617
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.