parent
							
								
									d95c8a2204
								
							
						
					
					
						commit
						89cf943e04
					
				|  | @ -7,7 +7,6 @@ import sys | ||||||
| from time import time | from time import time | ||||||
| 
 | 
 | ||||||
| import py | import py | ||||||
| from _pytest.compat import _PY2 |  | ||||||
| from _pytest._code.code import TerminalRepr, ExceptionInfo | from _pytest._code.code import TerminalRepr, ExceptionInfo | ||||||
| from _pytest.outcomes import skip, Skipped, TEST_OUTCOME | from _pytest.outcomes import skip, Skipped, TEST_OUTCOME | ||||||
| 
 | 
 | ||||||
|  | @ -131,8 +130,7 @@ def _update_current_test_var(item, when): | ||||||
|     var_name = 'PYTEST_CURRENT_TEST' |     var_name = 'PYTEST_CURRENT_TEST' | ||||||
|     if when: |     if when: | ||||||
|         value = '{0} ({1})'.format(item.nodeid, when) |         value = '{0} ({1})'.format(item.nodeid, when) | ||||||
|         if _PY2: |         # don't allow null bytes on environment variables (see #2644, #2957) | ||||||
|             # python 2 doesn't like null bytes on environment variables (see #2644) |  | ||||||
|         value = value.replace('\x00', '(null)') |         value = value.replace('\x00', '(null)') | ||||||
|         os.environ[var_name] = value |         os.environ[var_name] = value | ||||||
|     else: |     else: | ||||||
|  |  | ||||||
|  | @ -0,0 +1 @@ | ||||||
|  | Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. | ||||||
|  | @ -415,17 +415,17 @@ class TestGeneralUsage(object): | ||||||
|         ]) |         ]) | ||||||
| 
 | 
 | ||||||
|     def test_parametrized_with_null_bytes(self, testdir): |     def test_parametrized_with_null_bytes(self, testdir): | ||||||
|         """Test parametrization with values that contain null bytes and unicode characters (#2644)""" |         """Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)""" | ||||||
|         p = testdir.makepyfile(u""" |         p = testdir.makepyfile(u""" | ||||||
|             # encoding: UTF-8 |             # encoding: UTF-8 | ||||||
|             import pytest |             import pytest | ||||||
| 
 | 
 | ||||||
|             @pytest.mark.parametrize("data", ["\\x00", u'ação']) |             @pytest.mark.parametrize("data", [b"\\x00", "\\x00", u'ação']) | ||||||
|             def test_foo(data): |             def test_foo(data): | ||||||
|                 assert data |                 assert data | ||||||
|         """) |         """) | ||||||
|         res = testdir.runpytest(p) |         res = testdir.runpytest(p) | ||||||
|         res.assert_outcomes(passed=2) |         res.assert_outcomes(passed=3) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class TestInvocationVariants(object): | class TestInvocationVariants(object): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue