mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	GH-113528: Remove a couple of expensive pathlib ABC tests (#113534)
Run expensive tests for walking and globbing from `test_pathlib` but not `test_pathlib_abc`. The ABCs are not as tightly optimised as the classes in top-level `pathlib`, and so these tests are taking rather a long time on some buildbots. Coverage of the main `pathlib` classes should suffice.
This commit is contained in:
		
							parent
							
								
									b664d91599
								
							
						
					
					
						commit
						6ca0e6754e
					
				
					 2 changed files with 43 additions and 42 deletions
				
			
		|  | @ -15,6 +15,7 @@ | ||||||
| 
 | 
 | ||||||
| from test.support import import_helper | from test.support import import_helper | ||||||
| from test.support import is_emscripten, is_wasi | from test.support import is_emscripten, is_wasi | ||||||
|  | from test.support import set_recursion_limit | ||||||
| from test.support import os_helper | from test.support import os_helper | ||||||
| from test.support.os_helper import TESTFN, FakePath | from test.support.os_helper import TESTFN, FakePath | ||||||
| from test.test_pathlib import test_pathlib_abc | from test.test_pathlib import test_pathlib_abc | ||||||
|  | @ -1660,6 +1661,48 @@ def test_walk_many_open_files(self): | ||||||
|                 self.assertEqual(next(it), expected) |                 self.assertEqual(next(it), expected) | ||||||
|             path = path / 'd' |             path = path / 'd' | ||||||
| 
 | 
 | ||||||
|  |     def test_walk_above_recursion_limit(self): | ||||||
|  |         recursion_limit = 40 | ||||||
|  |         # directory_depth > recursion_limit | ||||||
|  |         directory_depth = recursion_limit + 10 | ||||||
|  |         base = self.cls(self.base, 'deep') | ||||||
|  |         path = base.joinpath(*(['d'] * directory_depth)) | ||||||
|  |         path.mkdir(parents=True) | ||||||
|  | 
 | ||||||
|  |         with set_recursion_limit(recursion_limit): | ||||||
|  |             list(base.walk()) | ||||||
|  |             list(base.walk(top_down=False)) | ||||||
|  | 
 | ||||||
|  |     def test_glob_many_open_files(self): | ||||||
|  |         depth = 30 | ||||||
|  |         P = self.cls | ||||||
|  |         p = base = P(self.base) / 'deep' | ||||||
|  |         p.mkdir() | ||||||
|  |         for _ in range(depth): | ||||||
|  |             p /= 'd' | ||||||
|  |             p.mkdir() | ||||||
|  |         pattern = '/'.join(['*'] * depth) | ||||||
|  |         iters = [base.glob(pattern) for j in range(100)] | ||||||
|  |         for it in iters: | ||||||
|  |             self.assertEqual(next(it), p) | ||||||
|  |         iters = [base.rglob('d') for j in range(100)] | ||||||
|  |         p = base | ||||||
|  |         for i in range(depth): | ||||||
|  |             p = p / 'd' | ||||||
|  |             for it in iters: | ||||||
|  |                 self.assertEqual(next(it), p) | ||||||
|  | 
 | ||||||
|  |     def test_glob_above_recursion_limit(self): | ||||||
|  |         recursion_limit = 50 | ||||||
|  |         # directory_depth > recursion_limit | ||||||
|  |         directory_depth = recursion_limit + 10 | ||||||
|  |         base = self.cls(self.base, 'deep') | ||||||
|  |         path = base.joinpath(*(['d'] * directory_depth)) | ||||||
|  |         path.mkdir(parents=True) | ||||||
|  | 
 | ||||||
|  |         with set_recursion_limit(recursion_limit): | ||||||
|  |             list(base.glob('**/')) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| @only_posix | @only_posix | ||||||
| class PosixPathTest(PathTest, PurePosixPathTest): | class PosixPathTest(PathTest, PurePosixPathTest): | ||||||
|  |  | ||||||
|  | @ -8,7 +8,6 @@ | ||||||
| from pathlib._abc import UnsupportedOperation, PurePathBase, PathBase | from pathlib._abc import UnsupportedOperation, PurePathBase, PathBase | ||||||
| import posixpath | import posixpath | ||||||
| 
 | 
 | ||||||
| from test.support import set_recursion_limit |  | ||||||
| from test.support.os_helper import TESTFN | from test.support.os_helper import TESTFN | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -1224,25 +1223,6 @@ def test_rglob_symlink_loop(self): | ||||||
|                   } |                   } | ||||||
|         self.assertEqual(given, {p / x for x in expect}) |         self.assertEqual(given, {p / x for x in expect}) | ||||||
| 
 | 
 | ||||||
|     def test_glob_many_open_files(self): |  | ||||||
|         depth = 30 |  | ||||||
|         P = self.cls |  | ||||||
|         p = base = P(self.base) / 'deep' |  | ||||||
|         p.mkdir() |  | ||||||
|         for _ in range(depth): |  | ||||||
|             p /= 'd' |  | ||||||
|             p.mkdir() |  | ||||||
|         pattern = '/'.join(['*'] * depth) |  | ||||||
|         iters = [base.glob(pattern) for j in range(100)] |  | ||||||
|         for it in iters: |  | ||||||
|             self.assertEqual(next(it), p) |  | ||||||
|         iters = [base.rglob('d') for j in range(100)] |  | ||||||
|         p = base |  | ||||||
|         for i in range(depth): |  | ||||||
|             p = p / 'd' |  | ||||||
|             for it in iters: |  | ||||||
|                 self.assertEqual(next(it), p) |  | ||||||
| 
 |  | ||||||
|     def test_glob_dotdot(self): |     def test_glob_dotdot(self): | ||||||
|         # ".." is not special in globs. |         # ".." is not special in globs. | ||||||
|         P = self.cls |         P = self.cls | ||||||
|  | @ -1286,17 +1266,6 @@ def test_glob_long_symlink(self): | ||||||
|         bad_link.symlink_to("bad" * 200) |         bad_link.symlink_to("bad" * 200) | ||||||
|         self.assertEqual(sorted(base.glob('**/*')), [bad_link]) |         self.assertEqual(sorted(base.glob('**/*')), [bad_link]) | ||||||
| 
 | 
 | ||||||
|     def test_glob_above_recursion_limit(self): |  | ||||||
|         recursion_limit = 50 |  | ||||||
|         # directory_depth > recursion_limit |  | ||||||
|         directory_depth = recursion_limit + 10 |  | ||||||
|         base = self.cls(self.base, 'deep') |  | ||||||
|         path = base.joinpath(*(['d'] * directory_depth)) |  | ||||||
|         path.mkdir(parents=True) |  | ||||||
| 
 |  | ||||||
|         with set_recursion_limit(recursion_limit): |  | ||||||
|             list(base.glob('**/')) |  | ||||||
| 
 |  | ||||||
|     def test_glob_recursive_no_trailing_slash(self): |     def test_glob_recursive_no_trailing_slash(self): | ||||||
|         P = self.cls |         P = self.cls | ||||||
|         p = P(self.base) |         p = P(self.base) | ||||||
|  | @ -1825,17 +1794,6 @@ def test_walk_symlink_location(self): | ||||||
|         else: |         else: | ||||||
|             self.fail("symlink not found") |             self.fail("symlink not found") | ||||||
| 
 | 
 | ||||||
|     def test_walk_above_recursion_limit(self): |  | ||||||
|         recursion_limit = 40 |  | ||||||
|         # directory_depth > recursion_limit |  | ||||||
|         directory_depth = recursion_limit + 10 |  | ||||||
|         base = self.cls(self.base, 'deep') |  | ||||||
|         path = base.joinpath(*(['d'] * directory_depth)) |  | ||||||
|         path.mkdir(parents=True) |  | ||||||
| 
 |  | ||||||
|         with set_recursion_limit(recursion_limit): |  | ||||||
|             list(base.walk()) |  | ||||||
|             list(base.walk(top_down=False)) |  | ||||||
| 
 | 
 | ||||||
| class DummyPathWithSymlinks(DummyPath): | class DummyPathWithSymlinks(DummyPath): | ||||||
|     def readlink(self): |     def readlink(self): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Barney Gale
						Barney Gale