Merge pull request #1844 from nicoddemus/importer-error
Importer loader error
This commit is contained in:
		
						commit
						d99ceb1218
					
				
							
								
								
									
										1
									
								
								AUTHORS
								
								
								
								
							
							
						
						
									
										1
									
								
								AUTHORS
								
								
								
								
							|  | @ -80,6 +80,7 @@ Lukas Bednar | |||
| Maciek Fijalkowski | ||||
| Maho | ||||
| Marc Schlaich | ||||
| Marcin Bachry | ||||
| Mark Abramowitz | ||||
| Markus Unterwaditzer | ||||
| Martijn Faassen | ||||
|  |  | |||
|  | @ -6,11 +6,15 @@ | |||
| 
 | ||||
| * | ||||
| 
 | ||||
| * Fix loader error when running ``pytest`` embedded in a zipfile. | ||||
|   Thanks `@mbachry`_ for the PR. | ||||
| 
 | ||||
| * | ||||
| 
 | ||||
| * | ||||
| 
 | ||||
| 
 | ||||
| .. _@mbachry: https://github.com/mbachry | ||||
| 
 | ||||
| .. _#1822: https://github.com/pytest-dev/pytest/issues/1822 | ||||
| 
 | ||||
|  |  | |||
|  | @ -687,7 +687,7 @@ class Session(FSCollector): | |||
|         # This method is sometimes invoked when AssertionRewritingHook, which | ||||
|         # does not define a get_filename method, is already in place: | ||||
|         try: | ||||
|             path = loader.get_filename() | ||||
|             path = loader.get_filename(x) | ||||
|         except AttributeError: | ||||
|             # Retrieve path from AssertionRewritingHook: | ||||
|             path = loader.modules[x][0].co_filename | ||||
|  |  | |||
|  | @ -763,3 +763,21 @@ class TestDurationWithFixture: | |||
|             * call *test_1* | ||||
|         """) | ||||
| 
 | ||||
| 
 | ||||
| def test_zipimport_hook(testdir, tmpdir): | ||||
|     """Test package loader is being used correctly (see #1837).""" | ||||
|     zipapp = pytest.importorskip('zipapp') | ||||
|     testdir.tmpdir.join('app').ensure(dir=1) | ||||
|     testdir.makepyfile(**{ | ||||
|         'app/foo.py': """ | ||||
|             import pytest | ||||
|             def main(): | ||||
|                 pytest.main(['--pyarg', 'foo']) | ||||
|         """, | ||||
|     }) | ||||
|     target = tmpdir.join('foo.zip') | ||||
|     zipapp.create_archive(str(testdir.tmpdir.join('app')), str(target), main='foo:main') | ||||
|     result = testdir.runpython(target) | ||||
|     assert result.ret == 0 | ||||
|     result.stderr.fnmatch_lines(['*not found*foo*']) | ||||
|     assert 'INTERNALERROR>' not in result.stdout.str() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue