fix issue354: avoid tmpdir fixture to create too long filenames especially
when parametrization is used
This commit is contained in:
		
							parent
							
								
									e49eca8d59
								
							
						
					
					
						commit
						9fdfa155fb
					
				|  | @ -8,6 +8,9 @@ Changes between 2.4.1 and 2.4.2 | |||
| - avoid "IOError: Bad Filedescriptor" on pytest shutdown by not closing | ||||
|   the internal dupped stdout (fix is slightly hand-wavy but work). | ||||
| 
 | ||||
| - avoid tmpdir fixture to create too long filenames especially | ||||
|   when parametrization is used (issue354) | ||||
| 
 | ||||
| Changes between 2.4.0 and 2.4.1 | ||||
| ----------------------------------- | ||||
| 
 | ||||
|  |  | |||
|  | @ -64,5 +64,8 @@ def tmpdir(request): | |||
|     """ | ||||
|     name = request.node.name | ||||
|     name = py.std.re.sub("[\W]", "_", name) | ||||
|     MAXVAL = 30 | ||||
|     if len(name) > MAXVAL: | ||||
|         name = name[:MAXVAL] | ||||
|     x = request.config._tmpdirhandler.mktemp(name, numbered=True) | ||||
|     return x | ||||
|  |  | |||
|  | @ -91,3 +91,12 @@ def test_tmpdir_always_is_realpath(testdir): | |||
|     result = testdir.runpytest("-s", p, '--basetemp=%s/bt' % linktemp) | ||||
|     assert not result.ret | ||||
| 
 | ||||
| def test_tmpdir_too_long_on_parametrization(testdir): | ||||
|     testdir.makepyfile(""" | ||||
|         import pytest | ||||
|         @pytest.mark.parametrize("arg", ["1"*1000]) | ||||
|         def test_some(arg, tmpdir): | ||||
|             tmpdir.ensure("hello") | ||||
|     """) | ||||
|     reprec = testdir.inline_run() | ||||
|     reprec.assertoutcome(passed=1) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue