| 
									
										
										
										
											2014-04-19 00:13:23 -06:00
										 |  |  | from test.support import run_unittest, unload, check_warnings, CleanImport | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | import unittest | 
					
						
							|  |  |  | import sys | 
					
						
							| 
									
										
										
										
											2013-04-14 22:30:42 +10:00
										 |  |  | import importlib | 
					
						
							| 
									
										
										
										
											2014-01-04 15:09:53 -07:00
										 |  |  | from importlib.util import spec_from_file_location | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | import pkgutil | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | import os.path | 
					
						
							|  |  |  | import tempfile | 
					
						
							| 
									
										
										
										
											2013-06-15 17:11:25 -04:00
										 |  |  | import types | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | import shutil | 
					
						
							|  |  |  | import zipfile | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-15 21:19:18 +10:00
										 |  |  | # Note: pkgutil.walk_packages is currently tested in test_runpy. This is | 
					
						
							|  |  |  | # a hack to get a major issue resolved for 3.3b2. Longer term, it should | 
					
						
							|  |  |  | # be moved back here, perhaps by factoring out the helper code for | 
					
						
							|  |  |  | # creating interesting package layouts to a separate module. | 
					
						
							|  |  |  | # Issue #15348 declares this is indeed a dodgy hack ;) | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | 
 | 
					
						
							|  |  |  | class PkgutilTests(unittest.TestCase): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def setUp(self): | 
					
						
							|  |  |  |         self.dirname = tempfile.mkdtemp() | 
					
						
							| 
									
										
										
										
											2011-10-07 12:01:40 -07:00
										 |  |  |         self.addCleanup(shutil.rmtree, self.dirname) | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |         sys.path.insert(0, self.dirname) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def tearDown(self): | 
					
						
							|  |  |  |         del sys.path[0] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_getdata_filesys(self): | 
					
						
							|  |  |  |         pkg = 'test_getdata_filesys' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Include a LF and a CRLF, to test that binary data is read back | 
					
						
							|  |  |  |         RESOURCE_DATA = b'Hello, world!\nSecond line\r\nThird line' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Make a package with some resources | 
					
						
							|  |  |  |         package_dir = os.path.join(self.dirname, pkg) | 
					
						
							|  |  |  |         os.mkdir(package_dir) | 
					
						
							|  |  |  |         # Empty init.py | 
					
						
							|  |  |  |         f = open(os.path.join(package_dir, '__init__.py'), "wb") | 
					
						
							|  |  |  |         f.close() | 
					
						
							|  |  |  |         # Resource files, res.txt, sub/res.txt | 
					
						
							|  |  |  |         f = open(os.path.join(package_dir, 'res.txt'), "wb") | 
					
						
							|  |  |  |         f.write(RESOURCE_DATA) | 
					
						
							|  |  |  |         f.close() | 
					
						
							|  |  |  |         os.mkdir(os.path.join(package_dir, 'sub')) | 
					
						
							|  |  |  |         f = open(os.path.join(package_dir, 'sub', 'res.txt'), "wb") | 
					
						
							|  |  |  |         f.write(RESOURCE_DATA) | 
					
						
							|  |  |  |         f.close() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Check we can read the resources | 
					
						
							|  |  |  |         res1 = pkgutil.get_data(pkg, 'res.txt') | 
					
						
							|  |  |  |         self.assertEqual(res1, RESOURCE_DATA) | 
					
						
							|  |  |  |         res2 = pkgutil.get_data(pkg, 'sub/res.txt') | 
					
						
							|  |  |  |         self.assertEqual(res2, RESOURCE_DATA) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         del sys.modules[pkg] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_getdata_zipfile(self): | 
					
						
							|  |  |  |         zip = 'test_getdata_zipfile.zip' | 
					
						
							|  |  |  |         pkg = 'test_getdata_zipfile' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Include a LF and a CRLF, to test that binary data is read back | 
					
						
							|  |  |  |         RESOURCE_DATA = b'Hello, world!\nSecond line\r\nThird line' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Make a package with some resources | 
					
						
							|  |  |  |         zip_file = os.path.join(self.dirname, zip) | 
					
						
							|  |  |  |         z = zipfile.ZipFile(zip_file, 'w') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Empty init.py | 
					
						
							|  |  |  |         z.writestr(pkg + '/__init__.py', "") | 
					
						
							|  |  |  |         # Resource files, res.txt, sub/res.txt | 
					
						
							|  |  |  |         z.writestr(pkg + '/res.txt', RESOURCE_DATA) | 
					
						
							|  |  |  |         z.writestr(pkg + '/sub/res.txt', RESOURCE_DATA) | 
					
						
							|  |  |  |         z.close() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Check we can read the resources | 
					
						
							|  |  |  |         sys.path.insert(0, zip_file) | 
					
						
							|  |  |  |         res1 = pkgutil.get_data(pkg, 'res.txt') | 
					
						
							|  |  |  |         self.assertEqual(res1, RESOURCE_DATA) | 
					
						
							|  |  |  |         res2 = pkgutil.get_data(pkg, 'sub/res.txt') | 
					
						
							|  |  |  |         self.assertEqual(res2, RESOURCE_DATA) | 
					
						
							| 
									
										
										
										
											2009-07-05 06:42:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         names = [] | 
					
						
							|  |  |  |         for loader, name, ispkg in pkgutil.iter_modules([zip_file]): | 
					
						
							|  |  |  |             names.append(name) | 
					
						
							|  |  |  |         self.assertEqual(names, ['test_getdata_zipfile']) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |         del sys.path[0] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         del sys.modules[pkg] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-06 14:19:06 -07:00
										 |  |  |     def test_unreadable_dir_on_syspath(self): | 
					
						
							|  |  |  |         # issue7367 - walk_packages failed if unreadable dir on sys.path | 
					
						
							|  |  |  |         package_name = "unreadable_package" | 
					
						
							|  |  |  |         d = os.path.join(self.dirname, package_name) | 
					
						
							|  |  |  |         # this does not appear to create an unreadable dir on Windows | 
					
						
							|  |  |  |         #   but the test should not fail anyway | 
					
						
							|  |  |  |         os.mkdir(d, 0) | 
					
						
							| 
									
										
										
										
											2011-10-07 12:01:40 -07:00
										 |  |  |         self.addCleanup(os.rmdir, d) | 
					
						
							| 
									
										
										
										
											2011-10-06 14:19:06 -07:00
										 |  |  |         for t in pkgutil.walk_packages(path=[self.dirname]): | 
					
						
							|  |  |  |             self.fail("unexpected package found") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | class PkgutilPEP302Tests(unittest.TestCase): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class MyTestLoader(object): | 
					
						
							| 
									
										
										
										
											2015-01-09 11:39:21 -05:00
										 |  |  |         def create_module(self, spec): | 
					
						
							|  |  |  |             return None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-04 15:09:53 -07:00
										 |  |  |         def exec_module(self, mod): | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |             # Count how many times the module is reloaded | 
					
						
							| 
									
										
										
										
											2014-01-04 15:09:53 -07:00
										 |  |  |             mod.__dict__['loads'] = mod.__dict__.get('loads', 0) + 1 | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | 
 | 
					
						
							|  |  |  |         def get_data(self, path): | 
					
						
							|  |  |  |             return "Hello, world!" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class MyTestImporter(object): | 
					
						
							| 
									
										
										
										
											2014-01-04 15:09:53 -07:00
										 |  |  |         def find_spec(self, fullname, path=None, target=None): | 
					
						
							|  |  |  |             loader = PkgutilPEP302Tests.MyTestLoader() | 
					
						
							|  |  |  |             return spec_from_file_location(fullname, | 
					
						
							|  |  |  |                                            '<%s>' % loader.__class__.__name__, | 
					
						
							|  |  |  |                                            loader=loader, | 
					
						
							|  |  |  |                                            submodule_search_locations=[]) | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | 
 | 
					
						
							|  |  |  |     def setUp(self): | 
					
						
							|  |  |  |         sys.meta_path.insert(0, self.MyTestImporter()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def tearDown(self): | 
					
						
							|  |  |  |         del sys.meta_path[0] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_getdata_pep302(self): | 
					
						
							|  |  |  |         # Use a dummy importer/loader | 
					
						
							|  |  |  |         self.assertEqual(pkgutil.get_data('foo', 'dummy'), "Hello, world!") | 
					
						
							|  |  |  |         del sys.modules['foo'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_alreadyloaded(self): | 
					
						
							|  |  |  |         # Ensure that get_data works without reloading - the "loads" module | 
					
						
							|  |  |  |         # variable in the example loader should count how many times a reload | 
					
						
							|  |  |  |         # occurs. | 
					
						
							|  |  |  |         import foo | 
					
						
							|  |  |  |         self.assertEqual(foo.loads, 1) | 
					
						
							|  |  |  |         self.assertEqual(pkgutil.get_data('foo', 'dummy'), "Hello, world!") | 
					
						
							|  |  |  |         self.assertEqual(foo.loads, 1) | 
					
						
							|  |  |  |         del sys.modules['foo'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-15 20:44:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-24 20:21:04 -04:00
										 |  |  | # These tests, especially the setup and cleanup, are hideous. They | 
					
						
							|  |  |  | # need to be cleaned up once issue 14715 is addressed. | 
					
						
							| 
									
										
										
										
											2012-05-15 20:44:06 -04:00
										 |  |  | class ExtendPathTests(unittest.TestCase): | 
					
						
							|  |  |  |     def create_init(self, pkgname): | 
					
						
							|  |  |  |         dirname = tempfile.mkdtemp() | 
					
						
							|  |  |  |         sys.path.insert(0, dirname) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         pkgdir = os.path.join(dirname, pkgname) | 
					
						
							|  |  |  |         os.mkdir(pkgdir) | 
					
						
							|  |  |  |         with open(os.path.join(pkgdir, '__init__.py'), 'w') as fl: | 
					
						
							|  |  |  |             fl.write('from pkgutil import extend_path\n__path__ = extend_path(__path__, __name__)\n') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return dirname | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_submodule(self, dirname, pkgname, submodule_name, value): | 
					
						
							|  |  |  |         module_name = os.path.join(dirname, pkgname, submodule_name + '.py') | 
					
						
							|  |  |  |         with open(module_name, 'w') as fl: | 
					
						
							|  |  |  |             print('value={}'.format(value), file=fl) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-24 20:21:04 -04:00
										 |  |  |     def test_simple(self): | 
					
						
							|  |  |  |         pkgname = 'foo' | 
					
						
							|  |  |  |         dirname_0 = self.create_init(pkgname) | 
					
						
							|  |  |  |         dirname_1 = self.create_init(pkgname) | 
					
						
							|  |  |  |         self.create_submodule(dirname_0, pkgname, 'bar', 0) | 
					
						
							|  |  |  |         self.create_submodule(dirname_1, pkgname, 'baz', 1) | 
					
						
							|  |  |  |         import foo.bar | 
					
						
							|  |  |  |         import foo.baz | 
					
						
							|  |  |  |         # Ensure we read the expected values | 
					
						
							|  |  |  |         self.assertEqual(foo.bar.value, 0) | 
					
						
							|  |  |  |         self.assertEqual(foo.baz.value, 1) | 
					
						
							| 
									
										
										
										
											2012-05-15 20:44:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-24 20:21:04 -04:00
										 |  |  |         # Ensure the path is set up correctly | 
					
						
							|  |  |  |         self.assertEqual(sorted(foo.__path__), | 
					
						
							|  |  |  |                          sorted([os.path.join(dirname_0, pkgname), | 
					
						
							|  |  |  |                                  os.path.join(dirname_1, pkgname)])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Cleanup | 
					
						
							|  |  |  |         shutil.rmtree(dirname_0) | 
					
						
							|  |  |  |         shutil.rmtree(dirname_1) | 
					
						
							| 
									
										
										
										
											2012-05-15 20:44:06 -04:00
										 |  |  |         del sys.path[0] | 
					
						
							|  |  |  |         del sys.path[0] | 
					
						
							| 
									
										
										
										
											2012-05-16 04:48:04 -04:00
										 |  |  |         del sys.modules['foo'] | 
					
						
							|  |  |  |         del sys.modules['foo.bar'] | 
					
						
							|  |  |  |         del sys.modules['foo.baz'] | 
					
						
							| 
									
										
										
										
											2012-05-15 20:44:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-14 22:30:42 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Another awful testing hack to be cleaned up once the test_runpy | 
					
						
							|  |  |  |     # helpers are factored out to a common location | 
					
						
							|  |  |  |     def test_iter_importers(self): | 
					
						
							|  |  |  |         iter_importers = pkgutil.iter_importers | 
					
						
							|  |  |  |         get_importer = pkgutil.get_importer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         pkgname = 'spam' | 
					
						
							|  |  |  |         modname = 'eggs' | 
					
						
							|  |  |  |         dirname = self.create_init(pkgname) | 
					
						
							|  |  |  |         pathitem = os.path.join(dirname, pkgname) | 
					
						
							|  |  |  |         fullname = '{}.{}'.format(pkgname, modname) | 
					
						
							| 
									
										
										
										
											2013-11-22 13:55:23 -07:00
										 |  |  |         sys.modules.pop(fullname, None) | 
					
						
							|  |  |  |         sys.modules.pop(pkgname, None) | 
					
						
							| 
									
										
										
										
											2013-04-14 22:30:42 +10:00
										 |  |  |         try: | 
					
						
							|  |  |  |             self.create_submodule(dirname, pkgname, modname, 0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             importlib.import_module(fullname) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             importers = list(iter_importers(fullname)) | 
					
						
							|  |  |  |             expected_importer = get_importer(pathitem) | 
					
						
							|  |  |  |             for finder in importers: | 
					
						
							| 
									
										
										
										
											2014-01-04 15:09:53 -07:00
										 |  |  |                 spec = pkgutil._get_spec(finder, fullname) | 
					
						
							|  |  |  |                 loader = spec.loader | 
					
						
							| 
									
										
										
										
											2013-11-22 09:05:39 -07:00
										 |  |  |                 try: | 
					
						
							|  |  |  |                     loader = loader.loader | 
					
						
							|  |  |  |                 except AttributeError: | 
					
						
							|  |  |  |                     # For now we still allow raw loaders from | 
					
						
							|  |  |  |                     # find_module(). | 
					
						
							|  |  |  |                     pass | 
					
						
							| 
									
										
										
										
											2013-04-14 22:30:42 +10:00
										 |  |  |                 self.assertIsInstance(finder, importlib.machinery.FileFinder) | 
					
						
							|  |  |  |                 self.assertEqual(finder, expected_importer) | 
					
						
							| 
									
										
										
										
											2013-11-22 09:05:39 -07:00
										 |  |  |                 self.assertIsInstance(loader, | 
					
						
							| 
									
										
										
										
											2013-04-14 22:30:42 +10:00
										 |  |  |                                       importlib.machinery.SourceFileLoader) | 
					
						
							| 
									
										
										
										
											2014-01-04 15:09:53 -07:00
										 |  |  |                 self.assertIsNone(pkgutil._get_spec(finder, pkgname)) | 
					
						
							| 
									
										
										
										
											2013-04-14 22:30:42 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |             with self.assertRaises(ImportError): | 
					
						
							|  |  |  |                 list(iter_importers('invalid.module')) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             with self.assertRaises(ImportError): | 
					
						
							|  |  |  |                 list(iter_importers('.spam')) | 
					
						
							|  |  |  |         finally: | 
					
						
							|  |  |  |             shutil.rmtree(dirname) | 
					
						
							|  |  |  |             del sys.path[0] | 
					
						
							| 
									
										
										
										
											2013-11-22 09:05:39 -07:00
										 |  |  |             try: | 
					
						
							|  |  |  |                 del sys.modules['spam'] | 
					
						
							|  |  |  |                 del sys.modules['spam.eggs'] | 
					
						
							|  |  |  |             except KeyError: | 
					
						
							|  |  |  |                 pass | 
					
						
							| 
									
										
										
										
											2013-04-14 22:30:42 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-24 20:21:04 -04:00
										 |  |  |     def test_mixed_namespace(self): | 
					
						
							|  |  |  |         pkgname = 'foo' | 
					
						
							|  |  |  |         dirname_0 = self.create_init(pkgname) | 
					
						
							|  |  |  |         dirname_1 = self.create_init(pkgname) | 
					
						
							|  |  |  |         self.create_submodule(dirname_0, pkgname, 'bar', 0) | 
					
						
							|  |  |  |         # Turn this into a PEP 420 namespace package | 
					
						
							|  |  |  |         os.unlink(os.path.join(dirname_0, pkgname, '__init__.py')) | 
					
						
							|  |  |  |         self.create_submodule(dirname_1, pkgname, 'baz', 1) | 
					
						
							| 
									
										
										
										
											2012-05-15 20:44:06 -04:00
										 |  |  |         import foo.bar | 
					
						
							|  |  |  |         import foo.baz | 
					
						
							|  |  |  |         # Ensure we read the expected values | 
					
						
							|  |  |  |         self.assertEqual(foo.bar.value, 0) | 
					
						
							|  |  |  |         self.assertEqual(foo.baz.value, 1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Ensure the path is set up correctly | 
					
						
							|  |  |  |         self.assertEqual(sorted(foo.__path__), | 
					
						
							| 
									
										
										
										
											2012-05-24 20:21:04 -04:00
										 |  |  |                          sorted([os.path.join(dirname_0, pkgname), | 
					
						
							|  |  |  |                                  os.path.join(dirname_1, pkgname)])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Cleanup | 
					
						
							|  |  |  |         shutil.rmtree(dirname_0) | 
					
						
							|  |  |  |         shutil.rmtree(dirname_1) | 
					
						
							|  |  |  |         del sys.path[0] | 
					
						
							|  |  |  |         del sys.path[0] | 
					
						
							|  |  |  |         del sys.modules['foo'] | 
					
						
							|  |  |  |         del sys.modules['foo.bar'] | 
					
						
							|  |  |  |         del sys.modules['foo.baz'] | 
					
						
							| 
									
										
										
										
											2012-05-15 20:44:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # XXX: test .pkg files | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-09 21:23:58 +02:00
										 |  |  | class NestedNamespacePackageTest(unittest.TestCase): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def setUp(self): | 
					
						
							|  |  |  |         self.basedir = tempfile.mkdtemp() | 
					
						
							|  |  |  |         self.old_path = sys.path[:] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def tearDown(self): | 
					
						
							|  |  |  |         sys.path[:] = self.old_path | 
					
						
							|  |  |  |         shutil.rmtree(self.basedir) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_module(self, name, contents): | 
					
						
							|  |  |  |         base, final = name.rsplit('.', 1) | 
					
						
							|  |  |  |         base_path = os.path.join(self.basedir, base.replace('.', os.path.sep)) | 
					
						
							|  |  |  |         os.makedirs(base_path, exist_ok=True) | 
					
						
							|  |  |  |         with open(os.path.join(base_path, final + ".py"), 'w') as f: | 
					
						
							|  |  |  |             f.write(contents) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_nested(self): | 
					
						
							|  |  |  |         pkgutil_boilerplate = ( | 
					
						
							|  |  |  |             'import pkgutil; ' | 
					
						
							|  |  |  |             '__path__ = pkgutil.extend_path(__path__, __name__)') | 
					
						
							|  |  |  |         self.create_module('a.pkg.__init__', pkgutil_boilerplate) | 
					
						
							|  |  |  |         self.create_module('b.pkg.__init__', pkgutil_boilerplate) | 
					
						
							|  |  |  |         self.create_module('a.pkg.subpkg.__init__', pkgutil_boilerplate) | 
					
						
							|  |  |  |         self.create_module('b.pkg.subpkg.__init__', pkgutil_boilerplate) | 
					
						
							|  |  |  |         self.create_module('a.pkg.subpkg.c', 'c = 1') | 
					
						
							|  |  |  |         self.create_module('b.pkg.subpkg.d', 'd = 2') | 
					
						
							|  |  |  |         sys.path.insert(0, os.path.join(self.basedir, 'a')) | 
					
						
							|  |  |  |         sys.path.insert(0, os.path.join(self.basedir, 'b')) | 
					
						
							|  |  |  |         import pkg | 
					
						
							|  |  |  |         self.addCleanup(unload, 'pkg') | 
					
						
							|  |  |  |         self.assertEqual(len(pkg.__path__), 2) | 
					
						
							|  |  |  |         import pkg.subpkg | 
					
						
							|  |  |  |         self.addCleanup(unload, 'pkg.subpkg') | 
					
						
							|  |  |  |         self.assertEqual(len(pkg.subpkg.__path__), 2) | 
					
						
							|  |  |  |         from pkg.subpkg.c import c | 
					
						
							|  |  |  |         from pkg.subpkg.d import d | 
					
						
							|  |  |  |         self.assertEqual(c, 1) | 
					
						
							|  |  |  |         self.assertEqual(d, 2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-15 18:09:52 +10:00
										 |  |  | class ImportlibMigrationTests(unittest.TestCase): | 
					
						
							|  |  |  |     # With full PEP 302 support in the standard import machinery, the | 
					
						
							|  |  |  |     # PEP 302 emulation in this module is in the process of being | 
					
						
							|  |  |  |     # deprecated in favour of importlib proper | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def check_deprecated(self): | 
					
						
							|  |  |  |         return check_warnings( | 
					
						
							|  |  |  |             ("This emulation is deprecated, use 'importlib' instead", | 
					
						
							|  |  |  |              DeprecationWarning)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_importer_deprecated(self): | 
					
						
							|  |  |  |         with self.check_deprecated(): | 
					
						
							|  |  |  |             x = pkgutil.ImpImporter("") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_loader_deprecated(self): | 
					
						
							|  |  |  |         with self.check_deprecated(): | 
					
						
							|  |  |  |             x = pkgutil.ImpLoader("", "", "", "") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_get_loader_avoids_emulation(self): | 
					
						
							|  |  |  |         with check_warnings() as w: | 
					
						
							|  |  |  |             self.assertIsNotNone(pkgutil.get_loader("sys")) | 
					
						
							|  |  |  |             self.assertIsNotNone(pkgutil.get_loader("os")) | 
					
						
							|  |  |  |             self.assertIsNotNone(pkgutil.get_loader("test.support")) | 
					
						
							|  |  |  |             self.assertEqual(len(w.warnings), 0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-04 20:39:42 +10:00
										 |  |  |     def test_get_loader_handles_missing_loader_attribute(self): | 
					
						
							|  |  |  |         global __loader__ | 
					
						
							|  |  |  |         this_loader = __loader__ | 
					
						
							|  |  |  |         del __loader__ | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             with check_warnings() as w: | 
					
						
							|  |  |  |                 self.assertIsNotNone(pkgutil.get_loader(__name__)) | 
					
						
							|  |  |  |                 self.assertEqual(len(w.warnings), 0) | 
					
						
							|  |  |  |         finally: | 
					
						
							|  |  |  |             __loader__ = this_loader | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-19 00:13:23 -06:00
										 |  |  |     def test_get_loader_handles_missing_spec_attribute(self): | 
					
						
							|  |  |  |         name = 'spam' | 
					
						
							|  |  |  |         mod = type(sys)(name) | 
					
						
							|  |  |  |         del mod.__spec__ | 
					
						
							|  |  |  |         with CleanImport(name): | 
					
						
							|  |  |  |             sys.modules[name] = mod | 
					
						
							|  |  |  |             loader = pkgutil.get_loader(name) | 
					
						
							|  |  |  |         self.assertIsNone(loader) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_get_loader_handles_spec_attribute_none(self): | 
					
						
							|  |  |  |         name = 'spam' | 
					
						
							|  |  |  |         mod = type(sys)(name) | 
					
						
							|  |  |  |         mod.__spec__ = None | 
					
						
							|  |  |  |         with CleanImport(name): | 
					
						
							|  |  |  |             sys.modules[name] = mod | 
					
						
							|  |  |  |             loader = pkgutil.get_loader(name) | 
					
						
							|  |  |  |         self.assertIsNone(loader) | 
					
						
							| 
									
										
										
										
											2014-03-04 20:39:42 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-23 12:30:37 -04:00
										 |  |  |     def test_get_loader_None_in_sys_modules(self): | 
					
						
							|  |  |  |         name = 'totally bogus' | 
					
						
							|  |  |  |         sys.modules[name] = None | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             loader = pkgutil.get_loader(name) | 
					
						
							|  |  |  |         finally: | 
					
						
							|  |  |  |             del sys.modules[name] | 
					
						
							|  |  |  |         self.assertIsNone(loader) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_find_loader_missing_module(self): | 
					
						
							|  |  |  |         name = 'totally bogus' | 
					
						
							|  |  |  |         loader = pkgutil.find_loader(name) | 
					
						
							|  |  |  |         self.assertIsNone(loader) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-04 20:39:42 +10:00
										 |  |  |     def test_find_loader_avoids_emulation(self): | 
					
						
							|  |  |  |         with check_warnings() as w: | 
					
						
							|  |  |  |             self.assertIsNotNone(pkgutil.find_loader("sys")) | 
					
						
							|  |  |  |             self.assertIsNotNone(pkgutil.find_loader("os")) | 
					
						
							|  |  |  |             self.assertIsNotNone(pkgutil.find_loader("test.support")) | 
					
						
							|  |  |  |             self.assertEqual(len(w.warnings), 0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-15 18:09:52 +10:00
										 |  |  |     def test_get_importer_avoids_emulation(self): | 
					
						
							| 
									
										
										
										
											2012-07-17 21:37:58 +10:00
										 |  |  |         # We use an illegal path so *none* of the path hooks should fire | 
					
						
							| 
									
										
										
										
											2012-07-15 18:09:52 +10:00
										 |  |  |         with check_warnings() as w: | 
					
						
							| 
									
										
										
										
											2012-07-17 21:37:58 +10:00
										 |  |  |             self.assertIsNone(pkgutil.get_importer("*??")) | 
					
						
							| 
									
										
										
										
											2012-07-15 18:09:52 +10:00
										 |  |  |             self.assertEqual(len(w.warnings), 0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_iter_importers_avoids_emulation(self): | 
					
						
							|  |  |  |         with check_warnings() as w: | 
					
						
							|  |  |  |             for importer in pkgutil.iter_importers(): pass | 
					
						
							|  |  |  |             self.assertEqual(len(w.warnings), 0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | def test_main(): | 
					
						
							| 
									
										
										
										
											2012-07-09 21:23:58 +02:00
										 |  |  |     run_unittest(PkgutilTests, PkgutilPEP302Tests, ExtendPathTests, | 
					
						
							| 
									
										
										
										
											2012-07-15 18:09:52 +10:00
										 |  |  |                  NestedNamespacePackageTest, ImportlibMigrationTests) | 
					
						
							| 
									
										
										
										
											2014-02-16 14:52:01 -05:00
										 |  |  |     # this is necessary if test is run repeated (like when finding leaks) | 
					
						
							|  |  |  |     import zipimport | 
					
						
							|  |  |  |     import importlib | 
					
						
							|  |  |  |     zipimport._zip_directory_cache.clear() | 
					
						
							|  |  |  |     importlib.invalidate_caches() | 
					
						
							| 
									
										
										
										
											2012-07-15 18:09:52 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |     test_main() |