Commit Graph

45 Commits

Author SHA1 Message Date
Miss Islington (bot) 72cdd2ade6
[3.13] gh-123780: Make test_pkgutil clean up `spam` module (GH-123036) (#123781)
gh-123780: Make test_pkgutil clean up `spam` module (GH-123036)
(cherry picked from commit eca3fe40c2)

Co-authored-by: Malcolm Smith <smith@chaquo.com>
2024-09-06 22:57:46 +02:00
Miss Islington (bot) 963e97d901
[3.13] gh-59022: Added tests for `pkgutil.extend_path` (GH-121673) (GH-121951)
This adds tests for the documented behaviour of `pkgutil.extend_path`
regarding different argument types as well as for `*.pkg` files.
(cherry picked from commit 8f2532168b)

Co-authored-by: Andreas Stocker <andreas@stocker.co.it>
2024-07-19 16:35:51 +02:00
Miss Islington (bot) 1dc7fcd803
[3.13] gh-119064: Use os_helper.FakePath instead of pathlib.Path in tests (GH-119065) (GH-119087)
(cherry picked from commit 0152dc4ff5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-16 10:51:18 +03:00
Serhiy Storchaka c0eaa232f6
gh-117860: Add tests for resolving names when import rebind names (GH-118176)
Add tests for "import", pkgutil.resolve_name() and unittest.mock.path()
for cases when "import a.b as x" and "from a import b as x" give
different results.
2024-04-30 17:23:44 +03:00
Nikita Sobolev d6e83fbf30
gh-97850: Deprecate `find_loader` and `get_loader` in `pkgutil` (GH-98520)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-05-03 16:11:54 -07:00
Barry Warsaw 326997829d
gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059)
* Remove deprecated classes from pkgutil
* Remove some other PEP 302 obsolescence
* Use find_spec instead of load_module
* Remove more tests of PEP 302 obsolete APIs
* Remove another bunch of tests using obsolete load_modules()
* Remove deleted names from __all__
* Remove obsolete footnote
* imp is removed
* Remove `imp` from generated stdlib names
* What's new and blurb
* Update zipimport documentation for the removed methods
* Fix some Windows tests
* Remove any test (or part of a test) that references `find_module()`.
* Use assertIsNone() / assertIsNotNone() consistently.
* Update Doc/reference/import.rst
* We don't need pkgutil._get_spec() any more either
*  test.test_importlib.fixtures.NullFinder
* ...BadLoaderFinder.find_module
* ...test_api.InvalidatingNullFinder.find_module
* ...test.test_zipimport test of z.find_module
* Suppress cross-references to find_loader and find_module
* Suppress cross-references to Finder
* Suppress cross-references to pkgutil.ImpImporter and pkgutil.ImpLoader

---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2023-05-03 04:55:22 -07:00
Barry Warsaw e1f14643dc
gh-98040: Remove just the `imp` module (#98573) 2023-04-28 16:17:58 -07:00
Serhiy Storchaka 40348acc18
bpo-45229: Remove test_main in many tests (GH-28405)
Instead of explicitly enumerate test classes for run_unittest()
use the unittest ability to discover tests. This also makes these
tests discoverable and runnable with unittest.

load_tests() can be used for dynamic generating tests and adding
doctests. setUpModule(), tearDownModule() and addModuleCleanup()
can be used for running code before and after all module tests.
2021-09-19 15:27:33 +03:00
Miguel Brito e9d7f88d56
bpo-44061: Fix pkgutil.iter_modules regression when passed a pathlib.Path object (GH-25964) 2021-05-12 00:27:22 +01:00
Brett Cannon dc6d3e1e4c
bpo-43720: Update import-related stdlib deprecation messages to say they will be removed in Python 3.12 (GH-25167) 2021-04-03 15:31:15 -07:00
Hai Shi 96a6a6d42b
bpo-40275: Use new test.support helper submodules in tests (GH-21412) 2020-07-09 15:25:10 +02:00
Michael Felt e0acec1541
bpo-12915: Skip test_pkgutil.test_name_resolution() non-encodable filenames (GH-18720)
When filesystem encoding cannot encode the Unicode string used for a filename
continue testing with the next example.
2020-03-03 11:11:11 +01:00
Vinay Sajip 4f17c5cd9a
bpo-12915: Improve Unicode support for package names and attributes. (GH-18517) 2020-02-28 14:26:27 +00:00
Vinay Sajip 1ed61617a4
bpo-12915: Add pkgutil.resolve_name (GH-18310) 2020-02-14 22:02:13 +00:00
Sanyam Khurana b9c3da5c89 bpo-24744: Raises error in pkgutil.walk_packages if path is str (#1926)
bpo-24744: Raise error in pkgutil.walk_packages if path is str

Previously an empty result list was accidentallly returned, since the
code iterated over the string as if it were the expected list of paths,
and of course found nothing.
2017-06-13 13:11:14 -04:00
Eric Snow d5f9223981 Issue #17211: Yield a namedtuple in pkgutil.
Patch by Ramchandra Apte.
2016-09-07 18:37:17 -07:00
Brett Cannon 4a2360d3f7 Issue #25805: Skip a test for test_pkgutil when __name__ == __main__.
Thanks to SilentGhost for the patch.
2016-08-12 10:53:53 -07:00
Brett Cannon fdcdd9ed80 Issue #26896: Disambiguate uses of "importer" with "finder".
Thanks to Oren Milman for the patch.
2016-07-08 11:00:00 -07:00
Łukasz Langa 0d18c15fbf Issue #14209: pkgutil.iter_zipimport_modules ignores the prefix for packages
Patch by James Pickering.
2016-06-11 18:02:46 -07:00
Brett Cannon 02d8454002 Issue #23014: Make importlib.abc.Loader.create_module() required when
importlib.abc.Loader.exec_module() is also defined.

Before this change, create_module() was optional **and** could return
None to trigger default semantics. This change now reduces the
options for choosing default semantics to one and in the most
backporting-friendly way (define create_module() to return None).
2015-01-09 11:39:21 -05:00
Brett Cannon 8447c703d1 Issue #14710: Fix both pkgutil.find_loader() and get_loader() to not
raise an exception when a module doesn't exist.

Thanks to Pavel Aslanov for the bug report.
2014-05-23 12:30:37 -04:00
Eric Snow 658af31372 Issue #21200: Return None from pkgutil.get_loader() when __spec__ is missing. 2014-04-19 00:13:23 -06:00
Nick Coghlan dc855b7b1f Close #20839: pkgutil.find_loader now uses importlib.util.find_spec 2014-03-04 20:39:42 +10:00
Benjamin Peterson f617fa88de merge 3.3 2014-02-16 14:53:55 -05:00
Benjamin Peterson cf62603276 backout fafac90b69c4 2014-02-16 14:52:01 -05:00
Benjamin Peterson a118c4fa79 merge 3.3 2014-01-09 11:12:31 -06:00
Benjamin Peterson 50b82c765f clear zip stat cache after each ref leak run 2014-01-09 11:10:30 -06:00
Eric Snow 37148b27ac Issue #19708: Update pkgutil to use the new importer APIs. 2014-01-04 15:09:53 -07:00
Eric Snow 2ba66ebc20 Issue #19724: clear out colliding temp module. 2013-11-22 13:55:23 -07:00
Eric Snow b523f8433a Implement PEP 451 (ModuleSpec). 2013-11-22 09:05:39 -07:00
Brett Cannon 9529fbfd36 Issue #17177: Stop using imp in a bunch of tests 2013-06-15 17:11:25 -04:00
Nick Coghlan c4e0d982f3 Close issue #16163: handle submodules in pkgutil.iter_importers 2013-04-14 22:30:42 +10:00
Nick Coghlan 9455492142 Issue #15314: Tweak a pkgutil test to hopefully be more Windows friendly 2012-07-17 21:37:58 +10:00
Nick Coghlan 8ecf50474c Issue #15343: Handle importlib.machinery.FileFinder instances in pkgutil.walk_packages (et al) 2012-07-15 21:19:18 +10:00
Nick Coghlan 85e729ec3b Take the first step in resolving the messy pkgutil vs importlib edge cases by basing pkgutil explicitly on importlib, deprecating its internal import emulation and setting __main__.__loader__ correctly so that runpy still works (Affects #15343, #15314, #15357) 2012-07-15 18:09:52 +10:00
Antoine Pitrou b2dd880e0a Issue #15294: Fix a regression in pkgutil.extend_path()'s handling of nested namespace packages. 2012-07-09 21:23:58 +02:00
Eric V. Smith 984b11f88f issue 14660: Implement PEP 420, namespace packages. 2012-05-24 20:21:04 -04:00
Eric V. Smith 5cdc6308b6 Cleanup so subsequent tests won't fail. Needs to be moved into a support routine (see 14715). 2012-05-16 04:48:04 -04:00
Eric V. Smith a790c9b6d6 Issue #14817: Add rudimentary tests for pkgutil.extend_path. 2012-05-15 20:44:06 -04:00
Ned Deily 7010a07bd0 Issue #7367: Ensure test directory always gets removed. 2011-10-07 12:01:40 -07:00
Ned Deily caf5a22c5f Issue #7367: Add test case to test_pkgutil for walking path with
an unreadable directory.
2011-10-06 14:19:06 -07:00
Alexandre Vassalotti 515a74fbf9 Issue 4005: Remove .sort() call on dict_keys object.
This caused pydoc to fail when there was a zip file in sys.path.

Patch contributed by Amaury Forgeot d'Arc.
2009-07-05 06:42:44 +00:00
Benjamin Peterson ee8712cda4 #2621 rename test.test_support to test.support 2008-05-20 21:35:26 +00:00
Christian Heimes e57950fbfe Merged revisions 62420-62421,62423-62424 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r62420 | mark.dickinson | 2008-04-20 20:30:05 +0200 (Sun, 20 Apr 2008) | 3 lines

  Even more fixes for alpha Tru64, this time for
  the phase and polar methods.
........
  r62421 | mark.dickinson | 2008-04-20 22:38:48 +0200 (Sun, 20 Apr 2008) | 2 lines

  Add test for tanh(-0.) == -0. on IEEE 754 systems
........
  r62423 | amaury.forgeotdarc | 2008-04-20 23:02:21 +0200 (Sun, 20 Apr 2008) | 3 lines

  Correct an apparent refleak in test_pkgutil: zipimport._zip_directory_cache contains
  info for all processed zip files, even when they are no longer used.
........
  r62424 | mark.dickinson | 2008-04-20 23:39:04 +0200 (Sun, 20 Apr 2008) | 4 lines

  math.atan2 is misbehaving on Windows;  this patch
  should fix the problem in the same way that
  the cmath.phase problems were fixed.
........
2008-04-21 13:08:03 +00:00
Christian Heimes dae2a8939d Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r62350 | nick.coghlan | 2008-04-15 12:25:31 +0200 (Tue, 15 Apr 2008) | 1 line

  Issue 2439: add pkgutils.get_data() as a convenience wrapper for the PEP 302 get_data() API (contributed by Paul Moore)
........
  r62351 | nick.coghlan | 2008-04-15 12:28:14 +0200 (Tue, 15 Apr 2008) | 1 line

  Add test file missing from rev 62350
........
  r62352 | benjamin.peterson | 2008-04-15 13:58:46 +0200 (Tue, 15 Apr 2008) | 2 lines

  Add myself to Doc/ACKS.txt
........
  r62353 | andrew.kuchling | 2008-04-15 15:10:07 +0200 (Tue, 15 Apr 2008) | 6 lines

  Add *,**,@ to index, as suggested by
  http://farmdev.com/thoughts/24/what-does-the-def-star-variable-or-def-asterisk-parameter-syntax-do-in-python-/

  The right entry type to use isn't clear; operator seems wrong, because *,**,@
  aren't being used in expressions here.  I put them as 'statement'; 'syntax'
  might be better.
........
  r62354 | andrew.kuchling | 2008-04-15 15:10:41 +0200 (Tue, 15 Apr 2008) | 1 line

  Typo fix
........
  r62355 | mark.dickinson | 2008-04-15 22:51:18 +0200 (Tue, 15 Apr 2008) | 3 lines

  Fix for possible signed overflow:  the behaviour of -LONG_MIN is
  undefined in ANSI C.
........
  r62358 | jeroen.ruigrok | 2008-04-16 14:47:01 +0200 (Wed, 16 Apr 2008) | 2 lines

  Reformat to 80 columns prior to adding documentation.
........
  r62359 | jeroen.ruigrok | 2008-04-16 14:57:43 +0200 (Wed, 16 Apr 2008) | 2 lines

  Add details about the return value for mmap.flush().
........
  r62364 | raymond.hettinger | 2008-04-17 12:48:31 +0200 (Thu, 17 Apr 2008) | 1 line

  Issue 2648: Add leading zero to money format recipe in the docs.
........
  r62365 | jeroen.ruigrok | 2008-04-17 14:39:45 +0200 (Thu, 17 Apr 2008) | 2 lines

  Be consistent in the use of read-only.
........
  r62370 | andrew.kuchling | 2008-04-17 22:44:06 +0200 (Thu, 17 Apr 2008) | 1 line

  Typo fixes
........
  r62372 | andrew.kuchling | 2008-04-18 04:40:47 +0200 (Fri, 18 Apr 2008) | 1 line

  Use correct parameter name
........
  r62373 | andrew.kuchling | 2008-04-18 18:53:09 +0200 (Fri, 18 Apr 2008) | 1 line

  #2654: fix typo
........
  r62374 | andrew.kuchling | 2008-04-18 20:28:23 +0200 (Fri, 18 Apr 2008) | 4 lines

  Remove personal note from Jim Roskind; it no longer applies, and the
  e-mail address is for a previous employer.

  Can we move the big long copyright statement into a sidebar or something?
........
  r62375 | andrew.kuchling | 2008-04-18 20:39:55 +0200 (Fri, 18 Apr 2008) | 1 line

  Rewrite introductory section, and remove old section.  (It was already commented-out, but why keep it?)
........
  r62378 | skip.montanaro | 2008-04-18 22:35:46 +0200 (Fri, 18 Apr 2008) | 1 line

  resolve issue 2014
........
  r62379 | benjamin.peterson | 2008-04-18 22:45:33 +0200 (Fri, 18 Apr 2008) | 2 lines

  Fix indentation in sysmodule.c
........
  r62381 | amaury.forgeotdarc | 2008-04-19 01:31:33 +0200 (Sat, 19 Apr 2008) | 3 lines

  Some tests did not pass on repeated calls (regrtest -R::)
  Perform additional cleanup, mostly deleting from sys.modules, or clearing the warnings registry.
........
2008-04-19 00:55:37 +00:00